|
@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
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.MediicinedrugsDao;
|
|
import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
|
|
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.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.restmodel.ResponseContant;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
@ -33,6 +35,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private MediicineDeviceDao deviceDao;
|
|
private MediicineDeviceDao deviceDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private MediicineDeviceUserDao deviceUserDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
@ -153,23 +158,26 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public String updateDeviceAddress(String deviceId, String address){
|
|
|
|
|
|
public String updateDeviceAddress(String deviceIds, String address){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(address)){
|
|
|
|
result.put("msg","deviceId and address is null");
|
|
|
|
|
|
if(StringUtils.isEmpty(deviceIds) && StringUtils.isEmpty(address)){
|
|
|
|
result.put("msg","deviceIds and address is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
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();
|
|
|
|
|
|
for (String deviceId : deviceIds.split(",")) {
|
|
|
|
if(!StringUtils.isEmpty(deviceId)){
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
mediicinedevice.setDeliveryAddress(address);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
}
|
|
}
|
|
}
|
|
mediicinedevice.setDeliveryAddress(address);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("msg",mediicinedevice);
|
|
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
@ -204,7 +212,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
/**
|
|
/**
|
|
* 更新设备销售状态
|
|
* 更新设备销售状态
|
|
* @param deviceId
|
|
* @param deviceId
|
|
* @param status
|
|
|
|
|
|
* @param saleStatus
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@ -228,6 +236,50 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 解绑设备
|
|
|
|
* @param deviceIds
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public String unbindDevice(String deviceIds){
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
if(StringUtils.isEmpty(deviceIds)){
|
|
|
|
result.put("msg","deviceIds is null");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
for (String deviceId : deviceIds.split(",")) {
|
|
|
|
if(!StringUtils.isEmpty(deviceId)){
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
|
if (mediicinedevice == null) {
|
|
|
|
result.put("msg","device doesn't exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> list = null;
|
|
|
|
list = hibenateUtils.createSQLQuery("SELECT * FROM t_mediicine_device_user where del = 1 AND device_id = '" + deviceId + "'");
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
|
if (!StringUtils.isEmpty(stringObjectMap.get("id").toString())) {
|
|
|
|
MediicineDeviceUser mediicineDeviceUser = deviceUserDao.findOne(stringObjectMap.get("id").toString());
|
|
|
|
if (mediicineDeviceUser != null) {
|
|
|
|
mediicineDeviceUser.setDel("0");
|
|
|
|
deviceUserDao.save(mediicineDeviceUser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mediicinedevice.setBelongCommunity(null);
|
|
|
|
mediicinedevice.setCommunity(null);
|
|
|
|
this.save(mediicinedevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 分页查询设备信息
|
|
* 分页查询设备信息
|
|
@ -281,7 +333,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t.aisles as aisles,\n" +
|
|
" t.aisles as aisles,\n" +
|
|
" t.capacity as capacity,\n" +
|
|
" t.capacity as capacity,\n" +
|
|
" t.ratio as ratio,\n" +
|
|
" t.ratio as ratio,\n" +
|
|
" t.cargo_capacity as cargoCapacity\n" +
|
|
|
|
|
|
" t.cargo_capacity as cargoCapacity,\n" +
|
|
|
|
" t.layer as layer,\n" +
|
|
|
|
" t.wayer as wayer\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_device AS t where 1=1 AND t.del = 1\n";
|
|
" t_mediicine_device AS t where 1=1 AND t.del = 1\n";
|
|
|
|
|
|
@ -324,7 +378,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" from " +
|
|
" from " +
|
|
" t_mediicine_device t " +
|
|
" t_mediicine_device t " +
|
|
" where " +
|
|
" where " +
|
|
" 1=1 " +
|
|
|
|
|
|
" 1=1 and t.del = 1 " +
|
|
conditionSql;
|
|
conditionSql;
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
@ -376,7 +430,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t.aisles as aisles,\n" +
|
|
" t.aisles as aisles,\n" +
|
|
" t.capacity as capacity,\n" +
|
|
" t.capacity as capacity,\n" +
|
|
" t.ratio as ratio,\n" +
|
|
" t.ratio as ratio,\n" +
|
|
" t.cargo_capacity as cargoCapacity\n" +
|
|
|
|
|
|
" t.cargo_capacity as cargoCapacity,\n" +
|
|
|
|
" t.layer as layer,\n" +
|
|
|
|
" t.wayer as wayer\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_device AS t where 1=1\n";
|
|
" t_mediicine_device AS t where 1=1\n";
|
|
|
|
|
|
@ -500,12 +556,14 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t.aisles as aisles,\n" +
|
|
" t.aisles as aisles,\n" +
|
|
" t.capacity as capacity,\n" +
|
|
" t.capacity as capacity,\n" +
|
|
" t.ratio as ratio,\n" +
|
|
" t.ratio as ratio,\n" +
|
|
" t.cargo_capacity as cargoCapacity\n" +
|
|
|
|
|
|
" t.cargo_capacity as cargoCapacity,\n" +
|
|
|
|
" t.layer as layer,\n" +
|
|
|
|
" t.wayer as wayer\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_device AS t where\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 = " 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 = " 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;
|
|
|
|
|
|
@ -568,7 +626,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t_mediicine_user AS t where\n";
|
|
" t_mediicine_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 ',"+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;
|
|
|
|
|
|
@ -628,7 +686,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
String sql = "select count(1) from t_mediicine_device a";
|
|
|
|
|
|
String sql = "select count(1) from t_mediicine_device a where a.del = 1";
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
jsonObject.put("count", count);
|
|
jsonObject.put("count", count);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
@ -649,7 +707,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
*/
|
|
*/
|
|
public JSONObject countOnline() throws Exception{
|
|
public JSONObject countOnline() throws Exception{
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
String sql = "select count(1) from t_mediicine_device a where a.status = 1";
|
|
|
|
|
|
String sql = "select count(1) from t_mediicine_device a where a.del = 1 and a.status = 1";
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("count",count);
|
|
jsonObject.put("count",count);
|
|
@ -760,11 +818,13 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"\tt.aisles as aisles,\n" +
|
|
"\tt.aisles as aisles,\n" +
|
|
"\tt.capacity as capacity,\n" +
|
|
"\tt.capacity as capacity,\n" +
|
|
"\tt.ratio as ratio,\n" +
|
|
"\tt.ratio as ratio,\n" +
|
|
"\tt.cargo_capacity as cargoCapacity\n" +
|
|
|
|
|
|
"\tt.cargo_capacity as cargoCapacity,\n" +
|
|
|
|
"\tt.layer as layer,\n" +
|
|
|
|
"\tt.wayer as wayer\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_mediicine_device t\n" +
|
|
"\tt_mediicine_device t\n" +
|
|
"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\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 t_mediicine_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.account) like '%" + replenishEr + "%')\n";
|
|
sql +=" AND t.id in (select device_id from t_mediicine_device_user tmdu left join t_mediicine_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.account) like '%" + replenishEr + "%')\n";
|
|
}
|
|
}
|
|
@ -844,9 +904,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t.aisles AS aisles,\n" +
|
|
" t.aisles AS aisles,\n" +
|
|
" t.capacity AS capacity,\n" +
|
|
" t.capacity AS capacity,\n" +
|
|
" t.ratio AS ratio,\n" +
|
|
" t.ratio AS ratio,\n" +
|
|
" t.cargo_capacity AS cargoCapacity\n" +
|
|
|
|
|
|
" t.cargo_capacity AS cargoCapacity,\n" +
|
|
|
|
" t.layer AS layer,\n" +
|
|
|
|
" t.wayer AS wayer\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_device AS t WHERE ',"+ ids +",' LIKE CONCAT('%,',t.id,',%')";
|
|
|
|
|
|
" t_mediicine_device AS t WHERE t.del = 1 and ',"+ ids +",' LIKE CONCAT('%,',t.id,',%')";
|
|
String sencordSql = "SELECT\n" +
|
|
String sencordSql = "SELECT\n" +
|
|
"\ttmi.layer_no AS layerNo,\n" +
|
|
"\ttmi.layer_no AS layerNo,\n" +
|
|
"\ttmi.wayer_no AS wayerNo,\n" +
|
|
"\ttmi.wayer_no AS wayerNo,\n" +
|
|
@ -962,9 +1024,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t.aisles AS aisles,\n" +
|
|
" t.aisles AS aisles,\n" +
|
|
" t.capacity AS capacity,\n" +
|
|
" t.capacity AS capacity,\n" +
|
|
" t.ratio AS ratio,\n" +
|
|
" t.ratio AS ratio,\n" +
|
|
" t.cargo_capacity AS cargoCapacity\n" +
|
|
|
|
|
|
" t.cargo_capacity AS cargoCapacity,\n" +
|
|
|
|
" t.layer AS layer,\n" +
|
|
|
|
" t.wayer AS wayer\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_device AS t WHERE 1=1";
|
|
|
|
|
|
" t_mediicine_device AS t WHERE 1=1 and t.del = 1";
|
|
|
|
|
|
if (!StringUtils.isEmpty(deviceId)) {
|
|
if (!StringUtils.isEmpty(deviceId)) {
|
|
sql += " AND t.id = '" + deviceId + "'";
|
|
sql += " AND t.id = '" + deviceId + "'";
|