|
@ -8,15 +8,21 @@ import com.yihu.jw.base.dao.a2dao.MedicineDeviceDeliveryDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicineDeviceDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicineDeviceDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicineDeviceUserDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicineDeviceUserDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
|
|
|
|
import com.yihu.jw.base.dao.role.RoleDao;
|
|
|
|
import com.yihu.jw.base.dao.user.UserDao;
|
|
|
|
import com.yihu.jw.base.useragent.UserAgent;
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
import com.yihu.jw.entity.a1entity.MedicineDeviceDelivery;
|
|
import com.yihu.jw.entity.a1entity.MedicineDeviceDelivery;
|
|
import com.yihu.jw.entity.a1entity.MediicineDeviceUser;
|
|
import com.yihu.jw.entity.a1entity.MediicineDeviceUser;
|
|
import com.yihu.jw.entity.a1entity.Mediicinedevice;
|
|
import com.yihu.jw.entity.a1entity.Mediicinedevice;
|
|
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
|
|
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
|
|
|
|
import com.yihu.jw.entity.base.role.RoleDO;
|
|
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -48,6 +54,14 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private UserDao userDao;
|
|
|
|
@Autowired
|
|
|
|
private RoleDao roleDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private UserAgent userAgent;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private HibenateUtils hibenateUtils;
|
|
private HibenateUtils hibenateUtils;
|
|
@ -874,7 +888,87 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
//获取当前设备数量
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备总计
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public JSONObject countAllDevice(String userId) throws Exception {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
// String userId = userAgent.getUID();
|
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
|
int count = 0;
|
|
|
|
int onlineCount = 0;
|
|
|
|
int saleCount = 0;
|
|
|
|
if ("replenisher".equals(role.getCode())) {
|
|
|
|
String sql = "SELECT\n" +
|
|
|
|
"\tdevice_id\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicine_device_user\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tuser_id = '" + userId +"'\n" +
|
|
|
|
"AND del = 1";
|
|
|
|
//设备列表
|
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
String deviceIds = "";
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
|
if (stringObjectMap.get("device_id") != null && !StringUtils.isEmpty(stringObjectMap.get("device_id").toString())) {
|
|
|
|
if (StringUtils.isEmpty(deviceIds)) {
|
|
|
|
deviceIds += stringObjectMap.get("device_id").toString();
|
|
|
|
} else {
|
|
|
|
deviceIds += "," + stringObjectMap.get("device_id").toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String sencodSql = "select count(distinct(id)) from t_mediicine_device a where a.del = 1 and ',"+ deviceIds +",' LIKE CONCAT('%,',a.id,',%')";
|
|
|
|
count = jdbcTemplate.queryForObject(sencodSql,Integer.class);
|
|
|
|
jsonObject.put("total", count);
|
|
|
|
sencodSql = "select count(distinct(id)) from t_mediicine_device a where a.del = 1 and a.network_status = 1 and ',"+ deviceIds +",' LIKE CONCAT('%,',a.id,',%')";
|
|
|
|
onlineCount = jdbcTemplate.queryForObject(sencodSql, Integer.class);
|
|
|
|
sencodSql = "select count(distinct(id)) from t_mediicine_device a where a.del = 1 and a.sale_status = 1 and ',"+ deviceIds +",' LIKE CONCAT('%,',a.id,',%')";
|
|
|
|
saleCount = jdbcTemplate.queryForObject(sencodSql, Integer.class);
|
|
|
|
} else {
|
|
|
|
String sql = "SELECT\n" +
|
|
|
|
"t.hospital AS community\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"wlyy_user_area AS t\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"t.user_id = '" + userId + "'\n" +
|
|
|
|
"AND t.del = 1";
|
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
String belongCommunitys = "";
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
|
if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
|
|
|
|
if (StringUtils.isEmpty(belongCommunitys)) {
|
|
|
|
belongCommunitys += stringObjectMap.get("community").toString();
|
|
|
|
} else {
|
|
|
|
belongCommunitys += "," + stringObjectMap.get("community").toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//多个社区
|
|
|
|
|
|
|
|
String sencodSql = "select count(1) from t_mediicine_device a where a.del = 1 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
|
|
|
|
count = jdbcTemplate.queryForObject(sencodSql,Integer.class);
|
|
|
|
jsonObject.put("total", count);
|
|
|
|
sencodSql = "select count(distinct(id)) from t_mediicine_device a where a.del = 1 and a.network_status = 1 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
|
|
|
|
onlineCount = jdbcTemplate.queryForObject(sencodSql, Integer.class);
|
|
|
|
sencodSql = "select count(distinct(id)) from t_mediicine_device a where a.del = 1 and a.sale_status = 1 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
|
|
|
|
saleCount = jdbcTemplate.queryForObject(sencodSql, Integer.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
jsonObject.put("total", count);
|
|
|
|
jsonObject.put("onlineTotal", onlineCount);
|
|
|
|
jsonObject.put("saleTotal", saleCount);
|
|
|
|
jsonObject.put("onlineRate", onlineCount * 1.0 / count);
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
result.put("msg", jsonObject);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取当前设备数量countAllDevice
|
|
// public long countAll() {
|
|
// public long countAll() {
|
|
// return deviceDao.countAll();
|
|
// return deviceDao.countAll();
|
|
// }
|
|
// }
|