|
@ -522,6 +522,34 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
result.put("msg",mediicinedevice);
|
|
result.put("msg",mediicinedevice);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更新设备名称
|
|
|
|
* @param deviceId
|
|
|
|
* @param equName
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String updateDevEquName(String deviceId, String equName){
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(equName)){
|
|
|
|
result.put("msg","deviceId and equName is null");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
mediicinedevice.setEquName(equName);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
result.put("msg",mediicinedevice);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 解绑设备
|
|
* 解绑设备
|
|
* @param deviceIds
|
|
* @param deviceIds
|
|
@ -716,7 +744,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
String conditionSql = "";
|
|
String conditionSql = "";
|
|
if (!StringUtils.isEmpty(content)){
|
|
if (!StringUtils.isEmpty(content)){
|
|
conditionSql += " AND CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
|
|
|
|
|
|
conditionSql += " AND CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(equClass)){
|
|
if (!StringUtils.isEmpty(equClass)){
|
|
conditionSql += " AND t.equ_class = '"+equClass + "'";
|
|
conditionSql += " AND t.equ_class = '"+equClass + "'";
|
|
@ -843,7 +871,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
String conditionSql = "";
|
|
String conditionSql = "";
|
|
if (!StringUtils.isEmpty(content)){
|
|
if (!StringUtils.isEmpty(content)){
|
|
conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
|
|
|
|
|
|
conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(equClass)){
|
|
if (!StringUtils.isEmpty(equClass)){
|
|
conditionSql += " and t.equ_class = '"+equClass + "'";
|
|
conditionSql += " and t.equ_class = '"+equClass + "'";
|
|
@ -997,7 +1025,6 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_device AS t where t.del = 1\n";
|
|
" t_mediicine_device AS t where t.del = 1\n";
|
|
|
|
|
|
// String conditionSql = " t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and ',"+userId+",' LIKE CONCAT('%,',du.user_id,',%'))";
|
|
|
|
String conditionSql = " and t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and du.user_id = '" + userId + "')";
|
|
String conditionSql = " and t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and du.user_id = '" + userId + "')";
|
|
|
|
|
|
sql = sql + conditionSql;
|
|
sql = sql + conditionSql;
|
|
@ -1096,7 +1123,6 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" base_user AS t where\n";
|
|
" base_user AS t where\n";
|
|
|
|
|
|
// String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and ',"+deviceId+",' LIKE CONCAT('%,',du.device_id,',%'))";
|
|
|
|
String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and du.device_id = '" + deviceId + "')";
|
|
String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and du.device_id = '" + deviceId + "')";
|
|
|
|
|
|
sql = sql + conditionSql;
|
|
sql = sql + conditionSql;
|
|
@ -1229,7 +1255,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//市管理员
|
|
//市管理员
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
sql = "SELECT\n" +
|
|
sql = "SELECT\n" +
|
|
"\tid\tas community\n" +
|
|
|
|
|
|
"\t`code`\tas community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tdm_hospital\n" +
|
|
"\tdm_hospital\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
@ -1238,7 +1264,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//区域管理员
|
|
//区域管理员
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
sql = "SELECT\n" +
|
|
sql = "SELECT\n" +
|
|
"\tdh.id AS community\n" +
|
|
|
|
|
|
"\tdh.`code` AS community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
@ -1434,10 +1460,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"LEFT JOIN t_mediicinecabinet_inventory tmi ON t.id = tmi.id_device\n" +
|
|
"LEFT JOIN t_mediicinecabinet_inventory tmi ON t.id = tmi.id_device\n" +
|
|
"WHERE 1=1 and t.del = 1\n" ;
|
|
"WHERE 1=1 and t.del = 1\n" ;
|
|
if (!StringUtils.isEmpty(replenishEr)) {
|
|
if (!StringUtils.isEmpty(replenishEr)) {
|
|
sql +=" AND t.id in (select device_id from t_mediicine_device_user tmdu left join base_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.mobile) like '%" + replenishEr + "%')\n";
|
|
|
|
|
|
sql +=" AND t.id in (select device_id from t_mediicine_device_user tmdu left join base_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(IFNULL(tmu.`name`,''),IFNULL(tmu.`mobile`,'')) like '%" + replenishEr + "%')\n";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(address)) {
|
|
if (!StringUtils.isEmpty(address)) {
|
|
sql += " AND CONCAT(t.detail_address,t.delivery_address) like '%" + address + "%'\n";
|
|
|
|
|
|
sql += " AND CONCAT(IFNULL(tmu.`detail_address`,''),IFNULL(tmu.`delivery_address`,'')) like '%" + address + "%'\n";
|
|
}
|
|
}
|
|
|
|
|
|
sql += "GROUP BY\n" +
|
|
sql += "GROUP BY\n" +
|
|
@ -1582,7 +1608,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"t.del = 1 AND \n" +
|
|
"t.del = 1 AND \n" +
|
|
"t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
|
|
"t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
|
|
if (!StringUtils.isEmpty(content)) {
|
|
if (!StringUtils.isEmpty(content)) {
|
|
sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'";
|
|
|
|
|
|
sencodSql += " AND CONCAT(IFNULL(tmu.`equ_num`,''), IFNULL(tmu.`equ_name`,'')) like '%" + content +"%'";
|
|
}
|
|
}
|
|
deviceList = hibenateUtils.createSQLQuery(sencodSql);
|
|
deviceList = hibenateUtils.createSQLQuery(sencodSql);
|
|
} else {
|
|
} else {
|
|
@ -1591,7 +1617,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//市管理员
|
|
//市管理员
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
sql = "SELECT\n" +
|
|
sql = "SELECT\n" +
|
|
"\tid\tas community\n" +
|
|
|
|
|
|
"\t`code`\tas community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tdm_hospital\n" +
|
|
"\tdm_hospital\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
@ -1600,7 +1626,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//区域管理员
|
|
//区域管理员
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
sql = "SELECT\n" +
|
|
sql = "SELECT\n" +
|
|
"\tdh.id AS community\n" +
|
|
|
|
|
|
"\tdh.`code` AS community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
@ -1675,7 +1701,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"t.del = 1 AND \n" +
|
|
"t.del = 1 AND \n" +
|
|
"t.`status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
|
|
"t.`status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
|
|
if (!StringUtils.isEmpty(content)) {
|
|
if (!StringUtils.isEmpty(content)) {
|
|
sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'";
|
|
|
|
|
|
sencodSql += " AND CONCAT(IFNULL(tmu.`equ_num`,''), IFNULL(tmu.`equ_name`,'')) like '%" + content +"%'";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1687,7 +1713,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"\tconcat(t.id_device, t.equ_num) like '%" + stringObjectMap.get("equNum") +"%'\n" +
|
|
|
|
|
|
"\tconcat(IFNULL(t.`id_device`, ''), IFNULL(t.`equ_num`, '')) like '%" + stringObjectMap.get("equNum") +"%'\n" +
|
|
"AND t.shelf_status = 1";
|
|
"AND t.shelf_status = 1";
|
|
//库存
|
|
//库存
|
|
Integer qty = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
Integer qty = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
@ -1698,7 +1724,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"\tconcat(t.id_device, t.equ_num) like '%" + stringObjectMap.get("equNum") +"%'\n" +
|
|
|
|
|
|
"\tconcat(IFNULL(t.`id_device`, ''), IFNULL(t.`equ_num`, '')) like '%" + stringObjectMap.get("equNum") +"%'\n" +
|
|
"AND t.shelf_status = 0";
|
|
"AND t.shelf_status = 0";
|
|
Integer xiajiaQty = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
Integer xiajiaQty = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
if (xiajiaQty != null) {
|
|
if (xiajiaQty != null) {
|
|
@ -1781,7 +1807,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//市管理员
|
|
//市管理员
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
tempSql = "SELECT\n" +
|
|
tempSql = "SELECT\n" +
|
|
"\tid\tas community\n" +
|
|
|
|
|
|
"\t`code`\tas community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tdm_hospital\n" +
|
|
"\tdm_hospital\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
@ -1790,7 +1816,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//区域管理员
|
|
//区域管理员
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
tempSql = "SELECT\n" +
|
|
tempSql = "SELECT\n" +
|
|
"\tdh.id AS community\n" +
|
|
|
|
|
|
"\tdh.`code` AS community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
@ -1871,7 +1897,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"WHERE 1=1 AND t.del = 1\n";
|
|
"WHERE 1=1 AND t.del = 1\n";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(content)) {
|
|
if (!StringUtils.isEmpty(content)) {
|
|
conditionSql += "AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'\n";
|
|
|
|
|
|
conditionSql += "AND CONCAT(IFNULL(t.`equ_num`, ''), IFNULL(t.`equ_name`, '')) like '%" + content +"%'\n";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(networkStatus)) {
|
|
if (!StringUtils.isEmpty(networkStatus)) {
|
|
conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
|
|
conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
|
|
@ -2015,7 +2041,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"WHERE 1=1 AND t.del = 1\n";
|
|
"WHERE 1=1 AND t.del = 1\n";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(content)) {
|
|
if (!StringUtils.isEmpty(content)) {
|
|
conditionSql += "AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"'%\n";
|
|
|
|
|
|
conditionSql += "AND CONCAT(IFNULL(t.`equ_num`, ''), IFNULL(t.`equ_name`, '')) like '%" + content +"%'\n";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(networkStatus)) {
|
|
if (!StringUtils.isEmpty(networkStatus)) {
|
|
conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
|
|
conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
|
|
@ -2485,12 +2511,12 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
} else {
|
|
} else {
|
|
String belongCommunitys = "";
|
|
String belongCommunitys = "";
|
|
String tempSql = "";
|
|
String tempSql = "";
|
|
//获取管理员所在社区id字符串
|
|
|
|
|
|
//获取管理员所在社区code字符串
|
|
{
|
|
{
|
|
//市管理员
|
|
//市管理员
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
tempSql = "SELECT\n" +
|
|
tempSql = "SELECT\n" +
|
|
"\tid\tas community\n" +
|
|
|
|
|
|
"\t`code`\tas community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tdm_hospital\n" +
|
|
"\tdm_hospital\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
@ -2499,7 +2525,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
//区域管理员
|
|
//区域管理员
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
tempSql = "SELECT\n" +
|
|
tempSql = "SELECT\n" +
|
|
"\tdh.id AS community\n" +
|
|
|
|
|
|
"\tdh.`code` AS community\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"\twlyy_user_area t\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
@ -2784,12 +2810,20 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
public MediicinecabinetInventory updateMediicinecabineInventoryInfoById(String id,String qty,String cargoCapacity,String status) throws Exception {
|
|
public MediicinecabinetInventory updateMediicinecabineInventoryInfoById(String id,String qty,String cargoCapacity,String status) throws Exception {
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(id);
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(id);
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(qty)){
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(qty)){
|
|
|
|
//提升容量至库存数(修改的库存数大于容量时)
|
|
|
|
if (Integer.parseInt(qty) > Integer.parseInt(inventory.getCargoCapacity())) {
|
|
|
|
inventory.setCargoCapacity(qty);
|
|
|
|
}
|
|
inventory.setQty(qty);
|
|
inventory.setQty(qty);
|
|
}
|
|
}
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoCapacity)){
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoCapacity)){
|
|
inventory.setCargoCapacity(cargoCapacity);
|
|
inventory.setCargoCapacity(cargoCapacity);
|
|
}
|
|
}
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
|
//下架时,清空库存
|
|
|
|
if ("0".equals(status)) {
|
|
|
|
inventory.setQty("0");
|
|
|
|
}
|
|
inventory.setShelfStatus(status);
|
|
inventory.setShelfStatus(status);
|
|
}
|
|
}
|
|
inventory.setUpdateTime(new Date());
|
|
inventory.setUpdateTime(new Date());
|