Przeglądaj źródła

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

lyr 8 lat temu
rodzic
commit
f8aa30d802

+ 2 - 2
src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -112,7 +112,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    continue;
                }
                List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
                // 设置患者标识
@ -132,7 +132,7 @@ public class SignPatientLabelInfoService extends BaseService {
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                //json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }

+ 648 - 14
src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -133,6 +133,40 @@ public class StatisticsService extends BaseService {
        }
    }
    public long getWeiJiaoFei(String endDate,String area,int level){
        // 查询语句
        String sql = " select " +
                "     ifnull(result,'0') amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '14' " +
                "   and level1_type = ? and del = '1'" +
                "   and level2_type = '0' " +
                "   and quota_date = ? ";
        if (level == 4) {
            // 市级别
            sql += " and city = ? ";
        } else if (level == 3) {
            // 区、城镇级别
            sql += " and town = ? ";
        } else if (level == 2) {
            // 机构级别
            sql += " and org_code = ? ";
        } else if (level == 1) {
            sql += " and qkdoctor_code = ?";
        }
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
        if (result != null  && result.size() > 0) {
            return (result.get(0).get("amount") != null ? Long.valueOf(result.get(0).get("amount").toString()) : 0);
        } else {
            return 0;
        }
    }
    /**
     * 查询截止某个日期累计签约率
     *
@ -506,21 +540,20 @@ public class StatisticsService extends BaseService {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
                    if (!low_level.equals("1")) {
                        String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
                        if (StringUtils.isEmpty(redisNum)) {
                            PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                            if (peopleNum != null) {
                                map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            }
                        } else {
                            JSONObject peopleNum = new JSONObject(redisNum);
                            if (peopleNum != null) {
                                map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getInt("num") * 100));
                            }
                        }
                }
                if (!low_level.equals("1")) {
                    String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                        }
                    } else {
                        JSONObject peopleNum = new JSONObject(redisNum);
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getInt("num") * 100));
                        }
                    }
                }
            }
@ -1655,4 +1688,605 @@ public class StatisticsService extends BaseService {
        return total;
    }
    /**
     * 查询某个级别的某个指标到达量
     *
     * @param date
     * @param area
     * @param level
     * @param index
     * @param sort
     * @param lowLevel
     * @return
     * @throws Exception
     */
    public JSONArray getLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel) throws Exception {
        String areaField = "";
        String lowLevelField = "";
        String lowLevelName = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
            lowLevelField = "town";
            lowLevelName = "town_name";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
            lowLevelField = "org_code";
            lowLevelName = "org_name";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
            lowLevelField = "qkdoctor_code";
            lowLevelName = "qkdoctor_name";
        } else if (level == 1) {
            throw new Exception("param level error");
        }
        if (!StringUtils.isEmpty(lowLevel)) {
            if (lowLevel.equals("3")) {
                lowLevelField = "town";
                lowLevelName = "town_name";
            } else if (lowLevel.equals("2")) {
                lowLevelField = "org_code";
                lowLevelName = "org_name";
            } else if (lowLevel.equals("1")) {
                lowLevelField = "qkdoctor_code";
                lowLevelName = "qkdoctor_name";
            } else {
                throw new Exception("param lowLevel error");
            }
        }
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
        // 查询语句
        String sql = " select " +
                "     ifnull(" + lowLevelField + ",'') code " +
                "     ,ifnull(" + lowLevelName + ",'') 'name' " +
                "     ,ifnull(result,'0') amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '" + index + "' " +
                "   and level1_type = ? and del = '1'" +
                "   and quota_date = ? " +
                "   and " + areaField + " = ? ";
        if (sort == 1) {
            sql += " order by amount desc";
        } else {
            sql += " order by amount asc ";
        }
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, date, area});
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0);
                if (!low_level.equals("1")) {
                    String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
                    if (StringUtils.isEmpty(redisNum)) {
                        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Calendar.getInstance().get(Calendar.YEAR));
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                            map.put("num", peopleNum.getNum());
                            map.put("task", peopleNum.getTaskNum());
                        }
                    } else {
                        JSONObject peopleNum = new JSONObject(redisNum);
                        if (peopleNum != null) {
                            map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getInt("num") * 100));
                            map.put("num", peopleNum.getInt("num"));
                            map.put("task", peopleNum.getInt("taskNum"));
                        }
                    }
                }
            }
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    long map1value = (long) o1.get("amount");
                    long map2value = (long) o2.get("amount");
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 查询某个日期范围内的某个指标每天到达量
     *
     * @param startDate
     * @param endDate
     * @param interval
     * @param area
     * @param level
     * @param index
     * @return
     */
    public JSONObject getDateTotal(String startDate, String endDate, int interval, String area, int level, String index) throws Exception {
        int taskNum = 0;
        JSONObject json = new JSONObject();
        if (level > 1) {
            String redisNum = redisTemplate.opsForValue().get("people:num:" + area);
            if (StringUtils.isEmpty(redisNum)) {
                PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
                if (peopleNum != null) {
                    taskNum = peopleNum.getTaskNum();
                }
            } else {
                JSONObject peopleNum = new JSONObject(redisNum);
                if (peopleNum != null) {
                    taskNum = peopleNum.getInt("taskNum");
                }
            }
        }
        json.put("taskNum",taskNum);
        if (interval == 1) {
            JSONArray jsonArray = dateTotalStatistics(startDate, endDate, area, level, index);
            json.put("data",jsonArray);
            return json;
        } else if (interval == 2) {
            JSONArray jsonArray = weekTotalStatistics(startDate, endDate, area, level, index);
            json.put("data",jsonArray);
            return json;
        } else if(interval == 3){
            JSONArray jsonArray = monthTotalStatistics(startDate, endDate, area, level, index);
            json.put("data",jsonArray);
            return json;
        }
        return json;
    }
    /**
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     */
    public JSONArray dateTotalStatistics(String startDate, String endDate,  String area, int level, String index) {
        String areaField = "";
        String sql = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
        } else if (level == 1) {
            // 机构级别
            areaField = "qkdoctor_code";
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
        Calendar start = Calendar.getInstance();
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        //结束日期
        Calendar end = Calendar.getInstance();
        end.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        // 日期集合
        List<Calendar> days = new ArrayList<>();
        days.add(start);
        boolean flag = true;
        if (startDate.compareTo(endDate) == 0) {
            flag = false;
        }
        // 计算统计日期
        while (flag) {
            Calendar next = Calendar.getInstance();
            next.setTime(days.get(days.size() - 1).getTime());
            next.add(Calendar.DATE, 1);
            if (df.format(next.getTime()).compareTo(endDate) < 0) {
                days.add(next);
            } else {
                days.add(end);
                flag = false;
            }
        }
        Map<String, JSONObject> countResult = new HashMap<>();
        // 统计预计构建
        for (int i = 0; i < days.size(); i++) {
            String startStr = "";
            long amount = 0;
            startStr = df.format(days.get(i).getTime());
            JSONObject range = new JSONObject();
            range.put("range", startStr);
            range.put("amount", amount);
            countResult.put(startStr, range);
        }
        sql = " select " +
                "     ifnull(quota_date,'') as 'range' " +
                "     ,ifnull(result,'0') amount " +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '" + index + "' " +
                "   and level1_type = '" + level + "' and del = '1' " +
                "   and quota_date >= '" + startDate + "' " +
                "   and quota_date <= '" + endDate + "' " +
                "   and " + areaField + " = '" + area + "' ";
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
        if (resultList != null) {
            for (Map<String, Object> map : resultList) {
                if (countResult.containsKey(map.get("range").toString())) {
                    JSONObject range = (JSONObject) countResult.get(map.get("range").toString());
                    long amount = range.getLong("amount");
                    long resultAmount = map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L;
                    range.put("amount", amount + resultAmount);
                }
            }
            List<JSONObject> result = new ArrayList<>(countResult.values());
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
                        return 1;
                    } else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(result);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 按周统计
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     */
    private JSONArray weekTotalStatistics(String startDate, String endDate, String area, int level, String index) throws Exception {
        String areaField = "";
        String sql = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
        } else if (level == 1) {
            // 机构级别
            areaField = "qkdoctor_code";
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
        Calendar start = Calendar.getInstance();
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        // 第一个统计周期结束日期
        String firstEnd = "";
        // 结束日期
        Calendar end = Calendar.getInstance();
        end.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        // 起始日期为周几
        int week = start.get(Calendar.DAY_OF_WEEK);
        int incre = 7 - week + 1;
        // 日期集合
        List<Calendar> days = new ArrayList<>();
        days.add(start);
        boolean flag = true;
        int i = 0;
        if (startDate.compareTo(endDate) == 0) {
            flag = false;
            days.add(end);
            firstEnd = df.format(end.getTime());
        }
        // 计算统计日期
        while (flag) {
            Calendar next = Calendar.getInstance();
            next.setTime(days.get(days.size() - 1).getTime());
            if (i == 0) {
                if (incre != 7) {
                    next.add(Calendar.DATE, incre);
                }
            } else {
                next.add(Calendar.DATE, 7);
            }
            if (df.format(next.getTime()).compareTo(df.format(end.getTime())) < 0) {
                days.add(next);
                if (i == 0) {
                    firstEnd = df.format(next.getTime());
                }
            } else {
                days.add(end);
                flag = false;
                if (i == 0) {
                    firstEnd = df.format(end.getTime());
                }
            }
            i++;
        }
        // 结果集
        Map<String, JSONObject> countResult = new HashMap<>();
        // 算出每个查询周期
        for (int j = 0; j < days.size() - 1; j++) {
            String startStr = "";
            String endStr = df.format(days.get(j + 1).getTime());
            long amount = 0;
            // 起始、截止日期
            if (j == 0) {
                startStr = df.format(days.get(j).getTime());
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(days.get(j).getTime());
                cal.add(Calendar.DATE, 1);
                startStr = df.format(cal.getTime());
            }
            JSONObject range = new JSONObject();
            range.put("range", endStr);
            range.put("amount", amount);
            countResult.put(endStr, range);
        }
        // 查询时间范围内所有记录
        sql = " select " +
                "     ifnull(quota_date,'') as 'range' " +
                "     ,ifnull(result,'0') amount " +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '" + index + "' " +
                "   and level1_type = '" + level + "' and del = '1' " +
                "   and quota_date >= '" + startDate + "' " +
                "   and quota_date <= '" + endDate + "' " +
                "   and " + areaField + " = '" + area + "' ";
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
        if (resultList != null) {
            // 计算结果
            for (Map<String, Object> map : resultList) {
                String range = map.get("range").toString();
                JSONObject json = countResult.get(range);
                if(json != null) {
                    long amount = map.get("amount") == null ? 0L : Long.valueOf(map.get("amount").toString());
                    json.put("amount",amount);
                }
            }
            List<JSONObject> result = new ArrayList<>(countResult.values());
            // 排序
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
                        return 1;
                    } else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(result);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 按月统计
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     * @throws Exception
     */
    private JSONArray monthTotalStatistics(String startDate, String endDate, String area, int level, String index) throws Exception {
        String areaField = "";
        String sql = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
        } else if (level == 1) {
            // 机构级别
            areaField = "qkdoctor_code";
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
        Calendar start = Calendar.getInstance();
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        // 结束日期
        Calendar end = Calendar.getInstance();
        end.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        // 第一个结束日期
        String firstEnd = "";
        // 日期集合
        List<Calendar> days = new ArrayList<>();
        days.add(start);
        boolean flag = true;
        int k = 0;
        if (startDate.compareTo(endDate) == 0) {
            flag = false;
            days.add(end);
            firstEnd = df.format(end.getTime());
        }
        // 统计日期计算
        while (flag) {
            Calendar next = Calendar.getInstance();
            next.setTime(days.get(days.size() - 1).getTime());
            if (k == 0) {
                next.add(Calendar.MONTH, 1);
            } else {
                next.add(Calendar.MONTH, 2);
            }
            next.set(Calendar.DAY_OF_MONTH, 1);
            next.add(Calendar.DAY_OF_MONTH, -1);
            if (df.format(next.getTime()).compareTo(df.format(end.getTime())) < 0) {
                days.add(next);
                if (k == 0) {
                    firstEnd = df.format(next.getTime());
                }
            } else {
                days.add(end);
                flag = false;
                if (k == 0) {
                    firstEnd = df.format(end.getTime());
                }
            }
            k++;
        }
        // 统计结果
        Map<String, JSONObject> countResult = new HashMap<>();
        for (int i = 0; i < days.size() - 1; i++) {
            String startStr = "";
            String endStr = df.format(days.get(i + 1).getTime());
            int amount = 0;
            // 起始时间计算
            if (i == 0) {
                startStr = df.format(days.get(i).getTime());
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(days.get(i).getTime());
                cal.add(Calendar.DATE, 1);
                startStr = df.format(cal.getTime());
            }
            JSONObject range = new JSONObject();
            range.put("range", endStr);
            range.put("amount", amount);
            countResult.put(endStr, range);
        }
        // 查询时间范围内所有记录
        sql = " select " +
                "     ifnull(quota_date,'') as 'range' " +
                "     ,ifnull(result,'0') amount " +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '" + index + "' " +
                "   and level1_type = '" + level + "' and del = '1' " +
                "   and quota_date >= '" + startDate + "' " +
                "   and quota_date <= '" + endDate + "' " +
                "   and " + areaField + " = '" + area + "' ";
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
        if (resultList != null) {
            // 计算结果
            for (Map<String, Object> map : resultList) {
                String range = map.get("range").toString();
                JSONObject json = countResult.get(range);
                if(json != null) {
                    long amount = map.get("amount") == null ? 0L : Long.valueOf(map.get("amount").toString());
                    json.put("amount",amount);
                }
            }
            List<JSONObject> result = new ArrayList<>(countResult.values());
            // 排序
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
                        return 1;
                    } else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(result);
        } else {
            return new JSONArray();
        }
    }
}

+ 6 - 5
src/main/java/com/yihu/wlyy/service/common/util/ManageUtilService.java

@ -11,6 +11,7 @@ import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -23,6 +24,7 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ExecutionException;
@ -56,15 +58,14 @@ public class ManageUtilService extends BaseService {
        boolean flag = true;
        while (flag) {
            PageRequest pageRequest = new PageRequest(page, 1000);
            PageRequest pageRequest = new PageRequest(0, 1000);
            Page<SignFamily> signs = signFamilyDao.findByTypeAndSignSource(2, "1", pageRequest);
            if (signs != null && signs.getContent().size() == 1000) {
                page++;
            } else {
            if (signs != null && signs.getContent().size() < 1000) {
                flag = false;
            }
            System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
@ -212,8 +213,8 @@ public class ManageUtilService extends BaseService {
                }
                //事物提交
                transactionManager.commit(status);
                System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            } catch (Exception e) {
                errorPages.add(page - 1);
                transactionManager.rollback(status);
            }
        }

+ 1 - 0
src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.web.BaseController;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

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

@ -131,7 +131,7 @@ public class SignPatientLabelInfoController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/patient_label")
    public String getPatientLabelByLabelType(String patient, String labelType) {
    public String getPatientLabelByLabelType(String patient, @RequestParam(required = false) String labelType) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");

+ 70 - 8
src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -205,17 +205,21 @@ public class StatisticsController extends BaseController {
     * @param type    1:签约率  2:签约完成率
     * @return
     */
    @RequestMapping(value = "/rate")
    @RequestMapping(value = "/sign_info")
    @ResponseBody
    public String getAreaRate(String endDate, String area, int level, String type) {
    public String getAreaSignInfo(String endDate, String area, int level) {
        try {
            JSONObject result = null;
            JSONObject result = new JSONObject();
            if (type.equals("1")) {
                result = statisticsService.getSignRate(endDate,area,level);
            } else {
                result = statisticsService.getSignTaskRate(endDate,area,level);
            }
            long sign = statisticsService.getTotalAmount(endDate, area, level, "1");
            long weiJf = statisticsService.getWeiJiaoFei(endDate, area, level);
            JSONObject signRate = statisticsService.getSignRate(endDate,area,level);
            JSONObject signTaskRate = statisticsService.getSignTaskRate(endDate,area,level);
            result.put("sign",sign);
            result.put("expenses",weiJf);
            result.put("signRate",signRate);
            result.put("signTaskRate",signTaskRate);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -245,4 +249,62 @@ public class StatisticsController extends BaseController {
            return error(-1,"查询失败");
        }
    }
    /**
     * 指标按间隔统计
     *
     * @param startDate 起始日期
     * @param endDate   结束时间
     * @param interval  时间间隔
     * @param area      区域或机构
     * @param level     级别
     * @param index     指标
     * @return
     */
    @RequestMapping(value = "/interval_total")
    @ResponseBody
    public String indexIntervalTotal(String startDate, String endDate, int interval, String area, int level, String index){
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            if (index != null) {
                for (String idx : indexes) {
                    result.put("index_" + idx, statisticsService.getDateTotal(startDate, endDate, interval, area, level, idx));
                }
            }
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
    /**
     * 指标截止日期累积量
     *
     * @param date
     * @param area
     * @param level
     * @param index
     * @return
     */
    @RequestMapping("/lowlevel_all")
    @ResponseBody
    public String getIndexLowLevelTotalSign(String date, String area, int level, String index, int sort, String lowLevel) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getLowLevelTotal(date, area, level, idx, sort, lowLevel));
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}