|
@ -8,6 +8,7 @@ import com.yihu.ehr.redis.client.RedisClient;
|
|
|
import com.yihu.ehr.redis.schema.OrgKeySchema;
|
|
|
import com.yihu.ehr.redis.schema.RsAdapterMetaKeySchema;
|
|
|
import com.yihu.ehr.solr.SolrUtil;
|
|
|
import com.yihu.ehr.util.datetime.DateTimeUtil;
|
|
|
import com.yihu.ehr.util.datetime.DateUtil;
|
|
|
import com.yihu.ehr.util.rest.Envelop;
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
@ -37,6 +38,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@ -860,4 +862,101 @@ public class PackQcReportService extends BaseJpaService {
|
|
|
list.add(0,profileInfo);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<String> getOrgCodes(String orgArea,String orgCode){
|
|
|
StringBuffer sql = new StringBuffer("select org_code from organizations where 1=1");
|
|
|
if(StringUtils.isNotBlank(orgArea)){
|
|
|
sql.append(" and administrative_division= '"+orgArea+"'");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(orgCode)){
|
|
|
sql.append(" and org_code='"+ orgCode+"'");
|
|
|
}
|
|
|
List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计某段接收时间,影像采集情况,入库情况
|
|
|
* @param orgArea
|
|
|
* @param orgCode
|
|
|
* @param startDate
|
|
|
* @param endDate 为空,默认获取到当天数据
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getImageInfo(String orgArea, String orgCode, String startDate, String endDate) throws Exception {
|
|
|
List<Map<String,Object>> res = new ArrayList<>();
|
|
|
List<String> fields = new ArrayList<>();
|
|
|
StringBuffer sqlSb = new StringBuffer();
|
|
|
if(StringUtils.isBlank(orgArea) && StringUtils.isBlank(orgCode)){
|
|
|
sqlSb = new StringBuffer("select org_area,count(*) as count from json_archives where pack_type=3");
|
|
|
}else{
|
|
|
sqlSb = new StringBuffer("select org_code,count(*) as count from json_archives where pack_type=3");
|
|
|
}
|
|
|
if(StringUtils.isBlank(endDate)){
|
|
|
endDate = DateTimeUtil.simpleDateFormat(new Date());
|
|
|
}
|
|
|
sqlSb.append(" and receive_date<='"+endDate+" 23:59:59'");
|
|
|
if(!StringUtils.isBlank(startDate)){
|
|
|
sqlSb.append(" and receive_date>='"+startDate+" 00:00:00'");
|
|
|
}
|
|
|
if(!StringUtils.isBlank(orgCode)){
|
|
|
sqlSb.append(" and org_code='"+orgCode+"'");
|
|
|
}
|
|
|
if(!StringUtils.isBlank(orgArea)){
|
|
|
sqlSb.append(" and org_area='"+orgArea+"'");
|
|
|
}
|
|
|
if(StringUtils.isBlank(orgArea) && StringUtils.isBlank(orgCode)){
|
|
|
sqlSb.append(" group by org_area");
|
|
|
fields.add("org_area");
|
|
|
}else{
|
|
|
sqlSb.append(" group by org_code");
|
|
|
fields.add("org_code");
|
|
|
}
|
|
|
// sqlSb.append(" order by count desc");
|
|
|
fields.add("count");
|
|
|
List<Map<String, Object>> resultList = elasticSearchUtil.findBySql(fields, sqlSb.toString());
|
|
|
if (resultList != null && resultList.size() > 0) {
|
|
|
for (Map<String,Object> map : resultList){
|
|
|
Map info = new HashMap();
|
|
|
if(StringUtils.isBlank(orgArea) && StringUtils.isBlank(orgCode)){
|
|
|
String org_area = map.get("org_area").toString();
|
|
|
String name = redisClient.get("area:" + org_area + ":name");
|
|
|
info.put("orgArea",org_area);
|
|
|
info.put("orgAreaName",name);
|
|
|
info.put("total",map.get("count"));
|
|
|
|
|
|
//查找该地区入库量
|
|
|
String sql = "";
|
|
|
if(!StringUtils.isBlank(startDate)){
|
|
|
sql = "select count(*) from json_archives where org_area ='"+org_area+"' and archive_staus=3 and pack_type=3 and receive_date<='"+endDate+"' group by profile_id";
|
|
|
}else{
|
|
|
sql = "select count(*) from json_archives where org_area ='"+org_area+"' and archive_staus=3 and pack_type=3 and receive_date<='"+endDate+"' and receive_date>='"+startDate+"' group by profile_id";
|
|
|
}
|
|
|
ResultSet resultSet = elasticSearchUtil.findBySql(sql);
|
|
|
resultSet.next();
|
|
|
info.put("resourceCount",resultSet.getObject("COUNT(*)"));
|
|
|
}else {
|
|
|
String org_code = map.get("org_code").toString();
|
|
|
String name = redisClient.get("organizations:" + org_code + ":name");
|
|
|
info.put("orgCode",org_code);
|
|
|
info.put("orgCodeName",name);
|
|
|
info.put("total",map.get("count"));
|
|
|
|
|
|
//查找该地区入库量
|
|
|
String sql = "";
|
|
|
if(!StringUtils.isBlank(startDate)){
|
|
|
sql = "select count(*) from json_archives where org_code ='"+org_code+"' and archive_staus=3 and pack_type=3 and receive_date<='"+endDate+"' group by profile_id";
|
|
|
}else{
|
|
|
sql = "select count(*) from json_archives where org_code ='"+org_code+"' and archive_staus=3 and pack_type=3 and receive_date<='"+endDate+"' and receive_date>='"+startDate+"' group by profile_id";
|
|
|
}
|
|
|
ResultSet resultSet = elasticSearchUtil.findBySql(sql);
|
|
|
resultSet.next();
|
|
|
info.put("resourceCount",resultSet.getObject("COUNT(*)"));
|
|
|
}
|
|
|
res.add(info);
|
|
|
}
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
}
|