فهرست منبع

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

lyr 8 سال پیش
والد
کامیت
44a49847d8

+ 60 - 60
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.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.stereotype.Service;
import org.springframework.util.StringUtils;
import java.text.DecimalFormat;
@ -27,6 +28,7 @@ import java.util.*;
/**
 * Created by lyr-pc on 2016/10/21.
 */
@Service
public class StatisticsAllService extends BaseService {
    @Autowired
    CityDao cityDao;
@ -45,6 +47,15 @@ public class StatisticsAllService extends BaseService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 获取时间戳
     *
     * @return
     */
    public String getQuotaTimeStamp() {
        return redisTemplate.opsForValue().get("quota:timeKey");
    }
    /**
     * 获取一级指标达到量
     *
@ -59,7 +70,7 @@ public class StatisticsAllService extends BaseService {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
@ -109,59 +120,50 @@ public class StatisticsAllService extends BaseService {
     * @return
     */
    public long getWeiJiaoFei(String endDate, String area, int level) {
        int todayAmount = 0;
        long total = 0;
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateCon = endDate;
        if (endDate.compareTo(dateFormat.format(new Date())) == 0) {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
            dateCon = dateFormat.format(calendar.getTime());
        }
        // 查询语句
        String sql = " select " +
                "     ifnull(result,'0') amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '16' " +
                "   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 = ?";
        }
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:16:" + level + ":0:" + area);
        if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:16:" + level + ":"+ area + ":0:" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
                    todayAmount = valJson.getInt("num");
                    total = valJson.getInt("num");
                }
            }
        }
        } else {
            // 查询语句
            String sql = " select " +
                    "     ifnull(result,'0') amount" +
                    " from  " +
                    "     wlyy_quota_result " +
                    " where " +
                    "     quato_code = '16' " +
                    "   and level1_type = ? and del = '1'" +
                    "   and level2_type = '0' " +
                    "   and quota_date = ? ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, dateCon, area});
            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 = ?";
            }
        if (result != null && result.size() > 0) {
            return (result.get(0).get("amount") != null ? (Long.valueOf(result.get(0).get("amount").toString()) + todayAmount) : todayAmount);
        } else {
            return todayAmount;
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
            if (result != null && result.size() > 0) {
                total = (result.get(0).get("amount") != null ? Long.valueOf(result.get(0).get("amount").toString()) : 0L);
            }
        }
        return total;
    }
    /**
@ -381,11 +383,9 @@ public class StatisticsAllService extends BaseService {
    public List<Map<String, Object>> getTodayLowLevelTotal(String date, String area, int level, String index, String lowLevel) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
        String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + low_level);
        if (StringUtils.isEmpty(redisData)) {
        String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + low_level + ":" + getQuotaTimeStamp());
        if (!StringUtils.isEmpty(redisData)) {
            JSONArray jsonArray = new JSONArray(redisData);
            for (int i = 0; i < jsonArray.length(); i++) {
@ -503,9 +503,9 @@ public class StatisticsAllService extends BaseService {
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (endDate.compareTo(datef.format(new Date())) >= 0) {
            resultList =getTodayLevelTwoTotal(area,level,index);
            resultList = getTodayLevelTwoTotal(area, level, index);
        } else {
            resultList = getTodyBeforeLevelTwototal(endDate,area,level,index);
            resultList = getTodyBeforeLevelTwototal(endDate, area, level, index);
        }
        if (resultList != null) {
@ -517,7 +517,7 @@ public class StatisticsAllService extends BaseService {
                // 当天数据统计
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) == 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + code + ":" + area);
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + code + ":" + area + ":" + getQuotaTimeStamp());
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num")) {
@ -634,9 +634,9 @@ public class StatisticsAllService extends BaseService {
     */
    public List<Map<String, Object>> getTodayLevelTwoTotal(String area, int level, String index) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
        String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
        if (StringUtils.isEmpty(redisData)) {
        if (!StringUtils.isEmpty(redisData)) {
            JSONArray jsonArray = new JSONArray(redisData);
            for (int i = 0; i < jsonArray.length(); i++) {
@ -835,10 +835,10 @@ public class StatisticsAllService extends BaseService {
        SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
        List<Map<String, Object>> resultList = new ArrayList<>();
        if(endDate.compareTo(datef.format(new Date())) >= 0) {
            String redisData = redisTemplate.opsForValue().get("quota:12:" + level + ":" + area + ":6");
        if (endDate.compareTo(datef.format(new Date())) >= 0) {
            String redisData = redisTemplate.opsForValue().get("quota:12:" + level + ":" + area + ":6:" + getQuotaTimeStamp());
            if (StringUtils.isEmpty(redisData)) {
            if (!StringUtils.isEmpty(redisData)) {
                JSONArray jsonArray = new JSONArray(redisData);
                for (int i = 0; i < jsonArray.length(); i++) {
@ -950,7 +950,7 @@ public class StatisticsAllService extends BaseService {
        if (endDate.compareTo(datef.format(new Date())) >= 0) {
            String code = "6";
            String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + area + ":" + code );
            String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + area + ":" + code + ":" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
@ -1121,7 +1121,7 @@ public class StatisticsAllService extends BaseService {
            // 当前范围包含当天,则需添加当天的统计数据
            if (startStr.compareTo(df.format(new Date())) == 0) {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num")) {
@ -1298,7 +1298,7 @@ public class StatisticsAllService extends BaseService {
            // 当前范围包含当天,则需添加当天的统计数据
            if (startStr.compareTo(df.format(new Date())) <= 0 && endStr.compareTo(df.format(new Date())) >= 0) {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num")) {
@ -1472,7 +1472,7 @@ public class StatisticsAllService extends BaseService {
            // 当天数据计算
            if (startStr.compareTo(df.format(new Date())) <= 0 && endStr.compareTo(df.format(new Date())) >= 0) {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num")) {

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

@ -70,6 +70,11 @@ public class StatisticsService extends BaseService {
    private StringRedisTemplate redisTemplate;
    /**
     * 获取上次统计时间
     *
     * @return
     */
    public String getStatisticsTime() {
        String date = redisTemplate.opsForValue().get("quota:date");
@ -77,6 +82,15 @@ public class StatisticsService extends BaseService {
    }
    /**
     * 获取时间戳
     *
     * @return
     */
    public String getQuotaTimeStamp() {
        return redisTemplate.opsForValue().get("quota:timeKey");
    }
    /**
     * 缓存人口数据到redis
     *
@ -130,7 +144,7 @@ public class StatisticsService extends BaseService {
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
@ -192,7 +206,7 @@ public class StatisticsService extends BaseService {
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
@ -256,7 +270,7 @@ public class StatisticsService extends BaseService {
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:16:" + level + ":0:" + area);
            String val = redisTemplate.opsForValue().get("quota:16:" + level + ":" + area + ":0:" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
@ -368,7 +382,7 @@ public class StatisticsService extends BaseService {
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
@ -528,7 +542,7 @@ public class StatisticsService extends BaseService {
                // 截止日期包含当天,则从redis查询当天统计数据
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code + ":" + getQuotaTimeStamp());
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num")) {
@ -721,7 +735,7 @@ public class StatisticsService extends BaseService {
                // 截止日期包含当天,则从redis查询当天统计数据
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code + ":" + getQuotaTimeStamp());
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num")) {
@ -844,7 +858,7 @@ public class StatisticsService extends BaseService {
            // 当前范围包含当天,则需添加当天的统计数据
            if (startStr.compareTo(today) == 0) {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num")) {
@ -1008,7 +1022,7 @@ public class StatisticsService extends BaseService {
            // 当前范围包含当天,则需添加当天的统计数据
            if (startStr.compareTo(today) <= 0 && endStr.compareTo(today) >= 0) {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num")) {
@ -1204,7 +1218,7 @@ public class StatisticsService extends BaseService {
            // 当天数据计算
            if (startStr.compareTo(today) <= 0 && endStr.compareTo(today) >= 0) {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num")) {
@ -2796,7 +2810,6 @@ public class StatisticsService extends BaseService {
                        }
                    }
                }
                if (index.equals(GROUP)) {
                    // 分组指标总数算法
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -139,7 +139,7 @@ public class PatientService extends TokenService {
				json.put("token", token.getToken());
				json.put("name", temp.getName());
				json.put("photo", temp.getPhoto());
				new Thread(new SignSsGetTask(patient.getIdcard())).start();
				//new Thread(new SignSsGetTask(patient.getIdcard())).start();
				return json;
			}
		}

+ 8 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -515,14 +515,14 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                        }
                    }
                }
                String resultStr = HttpUtil.sendPost(checkUrl + "/third/sign/LoadSanshiSignFamily?idcard=" + idCard, "");
                if (!StringUtils.isEmpty(resultStr)) {
                    JSONObject checkJson = new JSONObject(resultStr);
                    if (checkJson.getInt("status") != 200) {
                        throw new Exception("sanshi sign get from jw failed");
                    }
                }
//                String resultStr = HttpUtil.sendPost(checkUrl + "/third/sign/LoadSanshiSignFamily?idcard=" + idCard, "");
//
//                if (!StringUtils.isEmpty(resultStr)) {
//                    JSONObject checkJson = new JSONObject(resultStr);
//                    if (checkJson.getInt("status") != 200) {
//                        throw new Exception("sanshi sign get from jw failed");
//                    }
//                }
            } catch (Exception e) {
                e.printStackTrace();
            }

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.statistic;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -24,6 +25,8 @@ public class StatisticsController extends BaseController {
    @Autowired
    StatisticsService statisticsService;
    @Autowired
    StatisticsAllService statisticsAllService;
    /**
     * 获取统计时间
@ -201,7 +204,7 @@ public class StatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getIndexLevelTwototal(endDate, area, level, idx));
                result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(endDate, area, level, idx));
            }
            return write(200, "查询成功", "data", result);
@ -226,10 +229,10 @@ public class StatisticsController extends BaseController {
        try {
            JSONObject result = new JSONObject();
            long sign = statisticsService.getIndexTotal(endDate, area, level, "13");
            long weiJf = statisticsService.getWeiJiaoFei(endDate, area, level);
            JSONObject signRate = statisticsService.getSignRate(endDate, area, level);
            JSONObject signTaskRate = statisticsService.getSignTaskRate(endDate, area, level);
            long sign = statisticsAllService.getIndexTotal(endDate, area, level, "13");
            long weiJf = statisticsAllService.getWeiJiaoFei(endDate, area, level);
            JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level);
            JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level);
            result.put("sign", sign);
            result.put("expenses", weiJf);
@ -256,7 +259,7 @@ public class StatisticsController extends BaseController {
    @ResponseBody
    public String getSixFiveStatistics(String startDate, String endDate, String area, int level) {
        try {
            JSONArray result = statisticsService.getSixFiveStatistics(endDate, area, level);
            JSONArray result = statisticsAllService.getSixFiveStatistics(endDate, area, level);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -285,7 +288,7 @@ public class StatisticsController extends BaseController {
            if (index != null) {
                for (String idx : indexes) {
                    result.put("index_" + idx, statisticsService.getDateTotal(startDate, endDate, interval, area, level, idx));
                    result.put("index_" + idx, statisticsAllService.getDateTotal(startDate, endDate, interval, area, level, idx));
                }
            }
@ -313,7 +316,7 @@ public class StatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getLowLevelTotal(date, area, level, idx, sort, lowLevel));
                result.put("index_" + idx, statisticsAllService.getLowLevelTotal(date, area, level, idx, sort, lowLevel));
            }
            return write(200, "查询成功", "data", result);
@ -340,7 +343,7 @@ public class StatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getIndexLevelTwototal(date, area, level, idx));
                result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(date, area, level, idx));
            }
            return write(200, "查询成功", "data", result);
@ -367,7 +370,7 @@ public class StatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getIndexTotal(endDate, area, level, idx));
                result.put("index_" + idx, statisticsAllService.getIndexTotal(endDate, area, level, idx));
            }
            return write(200, "查询成功", "data", result);