|
@ -39,6 +39,8 @@ import java.io.IOException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static cn.hutool.core.util.ObjectUtil.hasEmpty;
|
|
|
|
|
|
/**
|
|
|
* Created by yeshijie on 2020/5/11.
|
|
|
*/
|
|
@ -86,7 +88,7 @@ public class MonitorPlatformService {
|
|
|
* @param diseaseCondition
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type, String deviceType, String deviceName) throws IOException {
|
|
|
public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type, String deviceType, String deviceName, String town) throws IOException {
|
|
|
MixEnvelop<LocationDataVO, LocationDataVO> envelop = new MixEnvelop<>();
|
|
|
MixEnvelop<LocationDataVO, LocationDataVO> envelopTmp = null;
|
|
|
Integer total = 0;
|
|
@ -96,7 +98,11 @@ public class MonitorPlatformService {
|
|
|
JSONArray list = json.getJSONArray("list");
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
String sql = "select id, idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
|
|
|
"create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and device_sn='" + list.getString(i) + "'";
|
|
|
"create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and device_sn='" + list.getString(i) + "'";
|
|
|
//判断地区是否等于null
|
|
|
if (!hasEmpty(town)){
|
|
|
sql += "and town ='" + town + "'";
|
|
|
}
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
|
|
|
List<LocationDataVO> locationDataVOList = new ArrayList<>();
|
|
|
result.forEach(map -> {
|
|
@ -145,6 +151,10 @@ public class MonitorPlatformService {
|
|
|
"from device.wlyy_patient_device_location ");
|
|
|
StringBuffer sqlCounts = new StringBuffer("select count(*) from device.wlyy_patient_device_location ");
|
|
|
StringBuffer sqlCondition = new StringBuffer("where del=0 ");
|
|
|
//如果地区不为空 则增加地区
|
|
|
if (!hasEmpty(town)){
|
|
|
sqlCondition.append("and town = '" + town + "'" );
|
|
|
}
|
|
|
if (diseaseCondition != null) {
|
|
|
sqlCondition.append(" and disease_condition =" + diseaseCondition);
|
|
|
}
|
|
@ -1198,7 +1208,7 @@ public class MonitorPlatformService {
|
|
|
*/
|
|
|
public JSONObject getBrandsAndManufacturer() {
|
|
|
try {
|
|
|
String sql = "select count(DISTINCT A.device_name) as total,A.device_name,A.manufacturer from (\n" +
|
|
|
String sql = "select count(DISTINCT A.device_name) as total,A.device_name, IF(A.manufacturer = '健康之路', '福建健康之路信息技术有限公司', A.manufacturer) manufacturer from (\n" +
|
|
|
"select pd.device_name,wd.manufacturer from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
|
|
|
"where pd.device_sn = wd.device_code and pd.del=0 \n" +
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
|
|
@ -1364,24 +1374,24 @@ public class MonitorPlatformService {
|
|
|
Integer usingTmp = 0;
|
|
|
Integer totalTmp = 0;
|
|
|
Integer stockTmp = 0;
|
|
|
if (deviceTypeTmp.contains("5")&&deviceName.contains("健康小屋")){
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)){
|
|
|
typeTmp+="5";
|
|
|
}else {
|
|
|
typeTmp+=",5";
|
|
|
if (deviceTypeTmp.contains("5") && deviceName.contains("健康小屋")) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)) {
|
|
|
typeTmp += "5";
|
|
|
} else {
|
|
|
typeTmp += ",5";
|
|
|
}
|
|
|
usingTmp +=count;
|
|
|
totalTmp +=count;
|
|
|
usingTmp += count;
|
|
|
totalTmp += count;
|
|
|
}
|
|
|
if (deviceTypeTmp.contains("22")&&deviceName.contains("智慧药房")){
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)){
|
|
|
typeTmp+="22";
|
|
|
}else {
|
|
|
typeTmp+=",22";
|
|
|
if (deviceTypeTmp.contains("22") && deviceName.contains("智慧药房")) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(typeTmp)) {
|
|
|
typeTmp += "22";
|
|
|
} else {
|
|
|
typeTmp += ",22";
|
|
|
}
|
|
|
usingTmp +=ygusing;
|
|
|
totalTmp +=ygtotal;
|
|
|
stockTmp +=ygstock;
|
|
|
usingTmp += ygusing;
|
|
|
totalTmp += ygtotal;
|
|
|
stockTmp += ygstock;
|
|
|
}
|
|
|
|
|
|
tmp.put("device_name", "组合一体机");
|
|
@ -1396,7 +1406,7 @@ public class MonitorPlatformService {
|
|
|
/*string用,分割*/
|
|
|
String[] arrays = deviceType.split(",");
|
|
|
for (String string : arrays) {
|
|
|
if ("5".equals(string)&&deviceName.contains("健康小屋")) {
|
|
|
if ("5".equals(string) && deviceName.contains("健康小屋")) {
|
|
|
/*健康小屋*/
|
|
|
tmp.put("device_name", "健康小屋");
|
|
|
tmp.put("Subdivision", false);
|
|
@ -1407,7 +1417,7 @@ public class MonitorPlatformService {
|
|
|
tmp.put("showLevel", Integer.parseInt(showLevel));
|
|
|
result.getJSONArray("deviceInfo").add(tmp);
|
|
|
}
|
|
|
if ("22".equals(string)&&deviceName.contains("智慧药房")) {
|
|
|
if ("22".equals(string) && deviceName.contains("智慧药房")) {
|
|
|
//智慧药房
|
|
|
medicinecabinetCount.put("Subdivision", false);
|
|
|
medicinecabinetCount.put("showLevel", Integer.parseInt(showLevel));
|
|
@ -1416,15 +1426,15 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (deviceTypeTmp.contains("5")&&deviceName.contains("健康小屋")){
|
|
|
result.put("grantCount", result.getInteger("grantCount") +count);
|
|
|
if (deviceTypeTmp.contains("5") && deviceName.contains("健康小屋")) {
|
|
|
result.put("grantCount", result.getInteger("grantCount") + count);
|
|
|
//统计健康小屋数据/ 小屋全部统计为正常使用
|
|
|
sql = "select count(*) from xmiot.iot_equipmet_detail where device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m)";
|
|
|
count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
result.put("iotCount", result.getInteger("iotCount") + count);//小屋物联
|
|
|
}
|
|
|
if (deviceTypeTmp.contains("22")&&deviceName.contains("智慧药房")){
|
|
|
result.put("grantCount", result.getInteger("grantCount") +ygtotal);
|
|
|
if (deviceTypeTmp.contains("22") && deviceName.contains("智慧药房")) {
|
|
|
result.put("grantCount", result.getInteger("grantCount") + ygtotal);
|
|
|
}
|
|
|
|
|
|
}
|
|
@ -1663,7 +1673,7 @@ public class MonitorPlatformService {
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
JSONArray result = new JSONArray();
|
|
|
for (Map<String, Object> map : list) {
|
|
|
sql = "select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and del=1 and code!=10 and code!=11 and parent_code='" + map.get("id").toString() + "'";
|
|
|
sql = "select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' AND del=1 AND code!=10 AND code!=11 AND parent_code='" + map.get("id").toString() + "'";
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
List<Map<String, Object>> reList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> reMap : reList) {
|
|
@ -1673,13 +1683,14 @@ public class MonitorPlatformService {
|
|
|
buffer.append("," + reMap.get("code").toString());
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(buffer.toString())) {
|
|
|
buffer.deleteCharAt(0);
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
tmp.put("name", map.get("value").toString());
|
|
|
tmp.put("code", buffer.toString());
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
//组合一体机 单体征测量仪 数据
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(buffer.toString())) {
|
|
|
// buffer.deleteCharAt(0);
|
|
|
// JSONObject tmp = new JSONObject();
|
|
|
// tmp.put("name", map.get("value").toString());
|
|
|
// tmp.put("code", buffer.toString());
|
|
|
// result.add(tmp);
|
|
|
// }
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@ -1729,13 +1740,13 @@ public class MonitorPlatformService {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
String deviceTypes[] = deviceType.split(",");
|
|
|
boolean flag = false;
|
|
|
for(String type : deviceTypes){
|
|
|
if("1".equals(type)||"2".equals(type)){
|
|
|
for (String type : deviceTypes) {
|
|
|
if ("1".equals(type) || "2".equals(type)) {
|
|
|
flag = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if(flag){
|
|
|
if (flag) {
|
|
|
Integer allCount = jdbcTemplate.queryForObject(allCountSql, Integer.class);//单体征总数
|
|
|
totalAll += allCount;
|
|
|
|
|
@ -2038,7 +2049,7 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
|
|
|
/*取药信息*/
|
|
|
public JSONObject getBuyDrugMessage(String deviceid, String startTime,String endTime) throws Exception {
|
|
|
public JSONObject getBuyDrugMessage(String deviceid, String startTime, String endTime) throws Exception {
|
|
|
Map parameterMap = new HashMap<String, String>();
|
|
|
parameterMap.put("deviceId", deviceid);
|
|
|
parameterMap.put("startTime", startTime);
|
|
@ -2097,5 +2108,54 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 同步病人地址
|
|
|
*
|
|
|
* @author cx
|
|
|
* @date 2023/4/11 16:44
|
|
|
*/
|
|
|
public void findLocationByAddress() {
|
|
|
|
|
|
String sql = "SELECT DISTINCT * FROM (" +
|
|
|
"SELECT l.patient, h.city, h.city_name, h.town, h.town_name FROM wlyy.wlyy_sign_family f\n" +
|
|
|
"INNER JOIN device.wlyy_patient_device_location l \n" +
|
|
|
"ON l.patient = f.patient\n" +
|
|
|
"INNER JOIN wlyy.dm_hospital h ON h.`code` = f.hospital) sf ";
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
|
|
|
|
|
|
int num = 0;
|
|
|
for (Map map: result){
|
|
|
String patient = (String)map.get("patient");
|
|
|
//判断 病人不为空
|
|
|
String town = (String)map.get("town");
|
|
|
String townName = (String)map.get("town_name");
|
|
|
String update = "UPDATE device.wlyy_patient_device_location " +
|
|
|
"SET city = '350200' , city_name = '"+"厦门市"+"',town = '" + town + "' , town_name = '" + townName + "' " +
|
|
|
"WHERE patient = '" + patient + "' ";
|
|
|
jdbcTemplate.update(update.toString());
|
|
|
// System.out.println("添加成功!!!!" + num);
|
|
|
if (num % 300 == 0){
|
|
|
try {
|
|
|
Thread.sleep(1000);
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
num++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过区名称查询 list
|
|
|
*
|
|
|
*
|
|
|
* @return String
|
|
|
* @author cx
|
|
|
* @date 2023/4/13 11:07
|
|
|
*/
|
|
|
public List<Map<String, Object>> getTown() {
|
|
|
String sql = " SELECT town_name, town FROM wlyy.dm_hospital WHERE city = 350200 GROUP BY town_name ";
|
|
|
return jdbcTemplate.queryForList(sql.toString());
|
|
|
}
|
|
|
|
|
|
}
|