|
@ -1,11 +1,13 @@
|
|
package com.yihu.wlyy.service.app.statistics;
|
|
package com.yihu.wlyy.service.app.statistics;
|
|
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
import com.yihu.wlyy.entity.address.Town;
|
|
import com.yihu.wlyy.entity.address.Town;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.statistics.PopulationBase;
|
|
import com.yihu.wlyy.entity.statistics.PopulationBase;
|
|
import com.yihu.wlyy.repository.address.CityDao;
|
|
import com.yihu.wlyy.repository.address.CityDao;
|
|
import com.yihu.wlyy.repository.address.TownDao;
|
|
import com.yihu.wlyy.repository.address.TownDao;
|
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
import com.yihu.wlyy.repository.statistics.PopulationBaseDao;
|
|
import com.yihu.wlyy.repository.statistics.PopulationBaseDao;
|
|
@ -37,6 +39,8 @@ public class StatisticsService extends BaseService {
|
|
DoctorDao doctorDao;
|
|
DoctorDao doctorDao;
|
|
@Autowired
|
|
@Autowired
|
|
HospitalDao hospitalDao;
|
|
HospitalDao hospitalDao;
|
|
|
|
@Autowired
|
|
|
|
DoctorAdminTeamDao adminTeamDao;
|
|
|
|
|
|
|
|
|
|
/******************************************数据库统计指标***************************************/
|
|
/******************************************数据库统计指标***************************************/
|
|
@ -134,6 +138,8 @@ public class StatisticsService extends BaseService {
|
|
}
|
|
}
|
|
|
|
|
|
public long getWeiJiaoFei(String endDate, String area, int level) {
|
|
public long getWeiJiaoFei(String endDate, String area, int level) {
|
|
|
|
int todayAmount = 0;
|
|
|
|
|
|
// 查询语句
|
|
// 查询语句
|
|
String sql = " select " +
|
|
String sql = " select " +
|
|
" ifnull(result,'0') amount" +
|
|
" ifnull(result,'0') amount" +
|
|
@ -158,6 +164,17 @@ public class StatisticsService extends BaseService {
|
|
sql += " and qkdoctor_code = ?";
|
|
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 + ":" + area);
|
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
|
if (valJson.has("num") && valJson.getInt("num") > 0) {
|
|
|
|
todayAmount = valJson.getInt("num");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
|
|
|
|
|
|
if (result != null && result.size() > 0) {
|
|
if (result != null && result.size() > 0) {
|
|
@ -488,6 +505,7 @@ public class StatisticsService extends BaseService {
|
|
}
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, endDate, area});
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, endDate, area});
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
// 结果为空时,自建结果集
|
|
if (resultList == null || resultList.size() < 1) {
|
|
if (resultList == null || resultList.size() < 1) {
|
|
resultList = new ArrayList<>();
|
|
resultList = new ArrayList<>();
|
|
@ -498,29 +516,57 @@ public class StatisticsService extends BaseService {
|
|
Map<String, Object> obj = new HashMap<>();
|
|
Map<String, Object> obj = new HashMap<>();
|
|
obj.put("code", town.getCode());
|
|
obj.put("code", town.getCode());
|
|
obj.put("name", town.getName());
|
|
obj.put("name", town.getName());
|
|
obj.put("amount", Double.valueOf("0.0"));
|
|
|
|
|
|
obj.put("amount", "0");
|
|
obj.put("rate", Double.valueOf("0.0000"));
|
|
obj.put("rate", Double.valueOf("0.0000"));
|
|
|
|
resultList.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (low_level.equals("2")) {
|
|
} else if (low_level.equals("2")) {
|
|
List<Hospital> hospitals = hospitalDao.findByTownCode(area);
|
|
|
|
if (hospitals != null) {
|
|
|
|
for (Hospital hos : hospitals) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", hos.getCode());
|
|
|
|
obj.put("name", hos.getName());
|
|
|
|
obj.put("amount", Double.valueOf("0.0"));
|
|
|
|
obj.put("rate", Double.valueOf("0.0000"));
|
|
|
|
|
|
List<Town> towns = new ArrayList<>();
|
|
|
|
if(level == 4){
|
|
|
|
towns = townDao.findByCityCode(area);
|
|
|
|
}else if(level == 3){
|
|
|
|
Town town = townDao.findByCode(area);
|
|
|
|
towns.add(town);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (towns != null && towns.size() > 0 ) {
|
|
|
|
for(Town town : towns){
|
|
|
|
List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
|
|
|
|
|
|
|
|
for (Hospital hos : hospitals) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", hos.getCode());
|
|
|
|
obj.put("name", hos.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (low_level.equals("1")) {
|
|
} else if (low_level.equals("1")) {
|
|
List<Doctor> doctors = doctorDao.findDoctorByLevelAndHospital(area, 2);
|
|
|
|
if (doctors != null) {
|
|
|
|
for (Doctor doc : doctors) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", doc.getCode());
|
|
|
|
obj.put("name", doc.getName());
|
|
|
|
obj.put("amount", Double.valueOf("0.0"));
|
|
|
|
|
|
List<Hospital> hospitals = new ArrayList<>();
|
|
|
|
if(level == 4){
|
|
|
|
hospitals = hospitalDao.findByCity(area);
|
|
|
|
}else if(level == 3){
|
|
|
|
hospitals = hospitalDao.findByTownCode(area);
|
|
|
|
}else{
|
|
|
|
Hospital hos = hospitalDao.findByCode(area);
|
|
|
|
if(hos != null){
|
|
|
|
hospitals.add(hos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hospitals != null && hospitals.size() > 0 ) {
|
|
|
|
for(Hospital hos : hospitals){
|
|
|
|
List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
|
|
|
|
|
|
|
|
for (AdminTeam team : teams) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", String.valueOf(team.getId()));
|
|
|
|
obj.put("name", team.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -541,6 +587,7 @@ public class StatisticsService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (!low_level.equals("1")) {
|
|
if (!low_level.equals("1")) {
|
|
String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
|
|
String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
|
|
|
|
|
|
@ -663,30 +710,57 @@ public class StatisticsService extends BaseService {
|
|
Map<String, Object> obj = new HashMap<>();
|
|
Map<String, Object> obj = new HashMap<>();
|
|
obj.put("code", town.getCode());
|
|
obj.put("code", town.getCode());
|
|
obj.put("name", town.getName());
|
|
obj.put("name", town.getName());
|
|
obj.put("amount", Double.valueOf("0.0"));
|
|
|
|
|
|
obj.put("amount", "0");
|
|
|
|
obj.put("rate", Double.valueOf("0.0000"));
|
|
resultList.add(obj);
|
|
resultList.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (low_level.equals("2")) {
|
|
} else if (low_level.equals("2")) {
|
|
List<Hospital> hospitals = hospitalDao.findByTownCode(area);
|
|
|
|
if (hospitals != null) {
|
|
|
|
for (Hospital hos : hospitals) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", hos.getCode());
|
|
|
|
obj.put("name", hos.getName());
|
|
|
|
obj.put("amount", Double.valueOf("0.0"));
|
|
|
|
resultList.add(obj);
|
|
|
|
|
|
List<Town> towns = new ArrayList<>();
|
|
|
|
if(level == 4){
|
|
|
|
towns = townDao.findByCityCode(area);
|
|
|
|
}else if(level == 3){
|
|
|
|
Town town = townDao.findByCode(area);
|
|
|
|
towns.add(town);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (towns != null && towns.size() > 0 ) {
|
|
|
|
for(Town town : towns){
|
|
|
|
List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
|
|
|
|
|
|
|
|
for (Hospital hos : hospitals) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", hos.getCode());
|
|
|
|
obj.put("name", hos.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (low_level.equals("1")) {
|
|
} else if (low_level.equals("1")) {
|
|
List<Doctor> doctors = doctorDao.findDoctorByLevelAndHospital(area, 2);
|
|
|
|
if (doctors != null) {
|
|
|
|
for (Doctor doc : doctors) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", doc.getCode());
|
|
|
|
obj.put("name", doc.getName());
|
|
|
|
obj.put("amount", Double.valueOf("0.0"));
|
|
|
|
resultList.add(obj);
|
|
|
|
|
|
List<Hospital> hospitals = new ArrayList<>();
|
|
|
|
if(level == 4){
|
|
|
|
hospitals = hospitalDao.findByCity(area);
|
|
|
|
}else if(level == 3){
|
|
|
|
hospitals = hospitalDao.findByTownCode(area);
|
|
|
|
}else{
|
|
|
|
Hospital hos = hospitalDao.findByCode(area);
|
|
|
|
if(hos != null){
|
|
|
|
hospitals.add(hos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hospitals != null && hospitals.size() > 0 ) {
|
|
|
|
for(Hospital hos : hospitals){
|
|
|
|
List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
|
|
|
|
|
|
|
|
for (AdminTeam team : teams) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", String.valueOf(team.getId()));
|
|
|
|
obj.put("name", team.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -1737,6 +1811,14 @@ public class StatisticsService extends BaseService {
|
|
String areaField = "";
|
|
String areaField = "";
|
|
String lowLevelField = "";
|
|
String lowLevelField = "";
|
|
String lowLevelName = "";
|
|
String lowLevelName = "";
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
String dateCon = date;
|
|
|
|
|
|
|
|
if (date.compareTo(dateFormat.format(new Date())) == 0) {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
|
dateCon = dateFormat.format(calendar.getTime());
|
|
|
|
}
|
|
|
|
|
|
if (level == 4) {
|
|
if (level == 4) {
|
|
// 市级别
|
|
// 市级别
|
|
@ -1793,16 +1875,96 @@ public class StatisticsService extends BaseService {
|
|
sql += " order by amount asc ";
|
|
sql += " order by amount asc ";
|
|
}
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, date, area});
|
|
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, dateCon, area});
|
|
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
|
resultList = new ArrayList<>();
|
|
|
|
if (low_level.equals("3")) {
|
|
|
|
List<Town> towns = townDao.findByCityCode(area);
|
|
|
|
if (towns != null) {
|
|
|
|
for (Town town : towns) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", town.getCode());
|
|
|
|
obj.put("name", town.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
obj.put("rate", Double.valueOf("0.0000"));
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (low_level.equals("2")) {
|
|
|
|
List<Town> towns = new ArrayList<>();
|
|
|
|
if(level == 4){
|
|
|
|
towns = townDao.findByCityCode(area);
|
|
|
|
}else if(level == 3){
|
|
|
|
Town town = townDao.findByCode(area);
|
|
|
|
towns.add(town);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (towns != null && towns.size() > 0 ) {
|
|
|
|
for(Town town : towns){
|
|
|
|
List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
|
|
|
|
|
|
|
|
for (Hospital hos : hospitals) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", hos.getCode());
|
|
|
|
obj.put("name", hos.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (low_level.equals("1")) {
|
|
|
|
List<Hospital> hospitals = new ArrayList<>();
|
|
|
|
if(level == 4){
|
|
|
|
hospitals = hospitalDao.findByCity(area);
|
|
|
|
}else if(level == 3){
|
|
|
|
hospitals = hospitalDao.findByTownCode(area);
|
|
|
|
}else{
|
|
|
|
Hospital hos = hospitalDao.findByCode(area);
|
|
|
|
if(hos != null){
|
|
|
|
hospitals.add(hos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hospitals != null && hospitals.size() > 0 ) {
|
|
|
|
for(Hospital hos : hospitals){
|
|
|
|
List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
|
|
|
|
|
|
|
|
for (AdminTeam team : teams) {
|
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
|
obj.put("code", String.valueOf(team.getId()));
|
|
|
|
obj.put("name", team.getName());
|
|
|
|
obj.put("amount", "0");
|
|
|
|
resultList.add(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resultList != null) {
|
|
if (resultList != null) {
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
for (Map<String, Object> map : resultList) {
|
|
for (Map<String, Object> map : resultList) {
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0);
|
|
|
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
|
|
|
|
|
// 截止日期包含当天,则从redis查询当天统计数据
|
|
|
|
if (date.compareTo(dateFormat.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);
|
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
|
if (valJson.has("num") && valJson.getInt("num") > 0) {
|
|
|
|
map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (!low_level.equals("1")) {
|
|
if (!low_level.equals("1")) {
|
|
String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
|
|
String redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(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(), Calendar.getInstance().get(Calendar.YEAR));
|
|
if (peopleNum != null) {
|
|
if (peopleNum != null) {
|
|
@ -1905,6 +2067,14 @@ public class StatisticsService extends BaseService {
|
|
public JSONArray dateTotalStatistics(String startDate, String endDate, String area, int level, String index) {
|
|
public JSONArray dateTotalStatistics(String startDate, String endDate, String area, int level, String index) {
|
|
String areaField = "";
|
|
String areaField = "";
|
|
String sql = "";
|
|
String sql = "";
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
String dateCon = endDate;
|
|
|
|
|
|
|
|
if (endDate.compareTo(df.format(new Date())) == 0) {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
|
dateCon = df.format(calendar.getTime());
|
|
|
|
}
|
|
|
|
|
|
if (level == 4) {
|
|
if (level == 4) {
|
|
// 市级别
|
|
// 市级别
|
|
@ -1920,7 +2090,6 @@ public class StatisticsService extends BaseService {
|
|
areaField = "qkdoctor_code";
|
|
areaField = "qkdoctor_code";
|
|
}
|
|
}
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// 起始日期
|
|
// 起始日期
|
|
Calendar start = Calendar.getInstance();
|
|
Calendar start = Calendar.getInstance();
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
@ -1957,6 +2126,18 @@ public class StatisticsService extends BaseService {
|
|
long amount = 0;
|
|
long amount = 0;
|
|
|
|
|
|
startStr = df.format(days.get(i).getTime());
|
|
startStr = df.format(days.get(i).getTime());
|
|
|
|
|
|
|
|
// 当前范围包含当天,则需添加当天的统计数据
|
|
|
|
if (startStr.compareTo(df.format(new Date())) == 0) {
|
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
|
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
|
if (valJson.has("num") && valJson.getInt("num") > 0) {
|
|
|
|
amount = (long) valJson.getInt("num");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
JSONObject range = new JSONObject();
|
|
JSONObject range = new JSONObject();
|
|
range.put("range", startStr);
|
|
range.put("range", startStr);
|
|
range.put("amount", amount);
|
|
range.put("amount", amount);
|
|
@ -1972,7 +2153,7 @@ public class StatisticsService extends BaseService {
|
|
" quato_code = '" + index + "' " +
|
|
" quato_code = '" + index + "' " +
|
|
" and level1_type = '" + level + "' and del = '1' " +
|
|
" and level1_type = '" + level + "' and del = '1' " +
|
|
" and quota_date >= '" + startDate + "' " +
|
|
" and quota_date >= '" + startDate + "' " +
|
|
" and quota_date <= '" + endDate + "' " +
|
|
|
|
|
|
" and quota_date <= '" + dateCon + "' " +
|
|
" and " + areaField + " = '" + area + "' ";
|
|
" and " + areaField + " = '" + area + "' ";
|
|
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
|
|
@ -2021,6 +2202,14 @@ public class StatisticsService extends BaseService {
|
|
private JSONArray weekTotalStatistics(String startDate, String endDate, String area, int level, String index) throws Exception {
|
|
private JSONArray weekTotalStatistics(String startDate, String endDate, String area, int level, String index) throws Exception {
|
|
String areaField = "";
|
|
String areaField = "";
|
|
String sql = "";
|
|
String sql = "";
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
String dateCon = endDate;
|
|
|
|
|
|
|
|
if (endDate.compareTo(df.format(new Date())) == 0) {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
|
dateCon = df.format(calendar.getTime());
|
|
|
|
}
|
|
|
|
|
|
if (level == 4) {
|
|
if (level == 4) {
|
|
// 市级别
|
|
// 市级别
|
|
@ -2036,7 +2225,6 @@ public class StatisticsService extends BaseService {
|
|
areaField = "qkdoctor_code";
|
|
areaField = "qkdoctor_code";
|
|
}
|
|
}
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// 起始日期
|
|
// 起始日期
|
|
Calendar start = Calendar.getInstance();
|
|
Calendar start = Calendar.getInstance();
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
@ -2108,6 +2296,17 @@ public class StatisticsService extends BaseService {
|
|
startStr = df.format(cal.getTime());
|
|
startStr = df.format(cal.getTime());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 当前范围包含当天,则需添加当天的统计数据
|
|
|
|
if (startStr.compareTo(df.format(new Date())) <= 0 && endStr.compareTo(df.format(new Date())) >= 0) {
|
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
|
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
|
if (valJson.has("num") && valJson.getInt("num") > 0) {
|
|
|
|
amount = valJson.getInt("num");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
JSONObject range = new JSONObject();
|
|
JSONObject range = new JSONObject();
|
|
|
|
|
|
range.put("range", endStr);
|
|
range.put("range", endStr);
|
|
@ -2126,7 +2325,7 @@ public class StatisticsService extends BaseService {
|
|
" quato_code = '" + index + "' " +
|
|
" quato_code = '" + index + "' " +
|
|
" and level1_type = '" + level + "' and del = '1' " +
|
|
" and level1_type = '" + level + "' and del = '1' " +
|
|
" and quota_date >= '" + startDate + "' " +
|
|
" and quota_date >= '" + startDate + "' " +
|
|
" and quota_date <= '" + endDate + "' " +
|
|
|
|
|
|
" and quota_date <= '" + dateCon + "' " +
|
|
" and " + areaField + " = '" + area + "' ";
|
|
" and " + areaField + " = '" + area + "' ";
|
|
|
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
|
|
@ -2179,6 +2378,14 @@ public class StatisticsService extends BaseService {
|
|
private JSONArray monthTotalStatistics(String startDate, String endDate, String area, int level, String index) throws Exception {
|
|
private JSONArray monthTotalStatistics(String startDate, String endDate, String area, int level, String index) throws Exception {
|
|
String areaField = "";
|
|
String areaField = "";
|
|
String sql = "";
|
|
String sql = "";
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
String dateCon = endDate;
|
|
|
|
|
|
|
|
if (endDate.compareTo(df.format(new Date())) == 0) {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
|
dateCon = df.format(calendar.getTime());
|
|
|
|
}
|
|
|
|
|
|
if (level == 4) {
|
|
if (level == 4) {
|
|
// 市级别
|
|
// 市级别
|
|
@ -2194,7 +2401,6 @@ public class StatisticsService extends BaseService {
|
|
areaField = "qkdoctor_code";
|
|
areaField = "qkdoctor_code";
|
|
}
|
|
}
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// 起始日期
|
|
// 起始日期
|
|
Calendar start = Calendar.getInstance();
|
|
Calendar start = Calendar.getInstance();
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
@ -2263,6 +2469,17 @@ public class StatisticsService extends BaseService {
|
|
startStr = df.format(cal.getTime());
|
|
startStr = df.format(cal.getTime());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 当天数据计算
|
|
|
|
if (startStr.compareTo(df.format(new Date())) <= 0 && endStr.compareTo(df.format(new Date())) >= 0) {
|
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
|
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
|
if (valJson.has("num") && valJson.getInt("num") > 0) {
|
|
|
|
amount = valJson.getInt("num");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
JSONObject range = new JSONObject();
|
|
JSONObject range = new JSONObject();
|
|
|
|
|
|
range.put("range", endStr);
|
|
range.put("range", endStr);
|