|
@ -1645,7 +1645,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//模拟补货员未绑定设备
|
|
//模拟补货员未绑定设备
|
|
deviceIds = "";
|
|
|
|
|
|
// deviceIds = "";
|
|
|
|
|
|
conditionSql = "AND ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
|
|
conditionSql = "AND ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
|
|
} else {
|
|
} else {
|
|
@ -2313,6 +2313,236 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备库存,有携带userId
|
|
|
|
* @param belongCommunity
|
|
|
|
* @param deviceId
|
|
|
|
* @param networkStatus
|
|
|
|
* @param userId
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public JSONObject getDevInventoryByUserId(String belongCommunity, String deviceId, String networkStatus,String userId) throws Exception {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
|
List<Map<String, Object>> deviceList = null;
|
|
|
|
//查询控制语句
|
|
|
|
String conditionSql = "";
|
|
|
|
if ("replenisher".equals(role.getCode())) {
|
|
|
|
//补货员所分配的设备
|
|
|
|
String deviceIds = "";
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//模拟补货员未绑定设备
|
|
|
|
// deviceIds = "";
|
|
|
|
conditionSql = "AND ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
|
|
|
|
} else {
|
|
|
|
String belongCommunitys = "";
|
|
|
|
String tempSql = "";
|
|
|
|
//获取管理员所在社区id字符串
|
|
|
|
{
|
|
|
|
//市管理员
|
|
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
|
|
tempSql = "SELECT\n" +
|
|
|
|
"\tid\tas community\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tdm_hospital\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tdel = 1";
|
|
|
|
}
|
|
|
|
//区域管理员
|
|
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
|
|
tempSql = "SELECT\n" +
|
|
|
|
"\tdh.id AS community\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\twlyy_user_area t\n" +
|
|
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tt.user_id = '" + userId + "'\n" +
|
|
|
|
"AND t.del = 1\n" +
|
|
|
|
"AND dh.del = 1";
|
|
|
|
}
|
|
|
|
//社区管理员
|
|
|
|
if ("communityAdmin".equals(role.getCode())) {
|
|
|
|
tempSql = "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(tempSql);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
|
|
conditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String sql = "";
|
|
|
|
{
|
|
|
|
sql += "SELECT\n" +
|
|
|
|
" t.id AS id,\n" +
|
|
|
|
" t.belong_community AS belongCommunity,\n" +
|
|
|
|
" t.community AS community,\n" +
|
|
|
|
" t.del AS del,\n" +
|
|
|
|
" t.delivery_address AS deliveryAddress,\n" +
|
|
|
|
" t.detail_address AS detailAddress,\n" +
|
|
|
|
" t.equ_area AS equArea,\n" +
|
|
|
|
" t.equ_class AS equClass,\n" +
|
|
|
|
" t.equ_info AS equInfo,\n" +
|
|
|
|
" t.equ_name AS equName,\n" +
|
|
|
|
" t.equ_num AS equNum,\n" +
|
|
|
|
" t.equ_type AS equType,\n" +
|
|
|
|
" t.fbelong_community AS fbelongCommunity,\n" +
|
|
|
|
" t.machine_code AS machineCode,\n" +
|
|
|
|
" t.network_status AS networkStatus,\n" +
|
|
|
|
" t.poweron_test AS poweronTest,\n" +
|
|
|
|
" t.reg_date AS regDate,\n" +
|
|
|
|
" t.sale_status AS saleStatus,\n" +
|
|
|
|
" t.signalintensity AS signalintensity,\n" +
|
|
|
|
" t.upgr_adesit AS upgrAdesit,\n" +
|
|
|
|
" t.`status` AS `status`,\n" +
|
|
|
|
" t.card_status AS cardStatus,\n" +
|
|
|
|
" t.operator AS operator,\n" +
|
|
|
|
" t.pack_age AS packAge,\n" +
|
|
|
|
" t.usage_flow AS usageFlow,\n" +
|
|
|
|
" t.flow AS flow,\n" +
|
|
|
|
" t.create_time AS createTime,\n" +
|
|
|
|
" t.create_user AS createUser,\n" +
|
|
|
|
" t.create_user_name AS createUserName,\n" +
|
|
|
|
" t.update_time AS updateTime,\n" +
|
|
|
|
" t.update_user AS updateUser,\n" +
|
|
|
|
" t.update_user_name AS updateUserName,\n" +
|
|
|
|
" t.aisles AS aisles,\n" +
|
|
|
|
" t.capacity AS capacity,\n" +
|
|
|
|
" t.ratio AS ratio,\n" +
|
|
|
|
" t.cargo_capacity AS cargoCapacity,\n" +
|
|
|
|
" t.layer AS layer,\n" +
|
|
|
|
" t.wayer AS wayer\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
" t_mediicine_device AS t\n" +
|
|
|
|
"WHERE 1=1 AND t.del = 1\n";
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(networkStatus)) {
|
|
|
|
conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(belongCommunity)) {
|
|
|
|
conditionSql += "AND t.belong_community = '" + belongCommunity +"'\n";
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(deviceId)) {
|
|
|
|
conditionSql += "AND t.id = '" + deviceId +"'\n";
|
|
|
|
}
|
|
|
|
conditionSql += "AND t.belong_community IS NOT NULL\n";
|
|
|
|
sql = sql + conditionSql;
|
|
|
|
deviceList = hibenateUtils.createSQLQuery(sql);
|
|
|
|
Map<String, String> equTypeMap = new HashMap<>();
|
|
|
|
equTypeMap.put("1", "测试类型1");
|
|
|
|
equTypeMap.put("2", "测试类型2");
|
|
|
|
equTypeMap.put("3", "测试类型3");
|
|
|
|
for (Map<String, Object> stringObjectMap : deviceList) {
|
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("equType"))){
|
|
|
|
stringObjectMap.put("equTypeName", equTypeMap.get(stringObjectMap.get("equType")));
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
|
|
|
|
if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
|
|
|
|
stringObjectMap.put("networkStatusName", "在线");
|
|
|
|
}
|
|
|
|
if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
|
|
|
|
stringObjectMap.put("networkStatusName", "离线");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
|
|
|
|
if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
|
|
|
|
stringObjectMap.put("saleStatusName", "在售");
|
|
|
|
}
|
|
|
|
if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
|
|
|
|
stringObjectMap.put("saleStatusName", "停售");
|
|
|
|
}
|
|
|
|
if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
|
|
|
|
stringObjectMap.put("saleStatusName", "故障");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
|
|
|
|
if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
|
|
|
|
stringObjectMap.put("cardStatusName", "正常");
|
|
|
|
}
|
|
|
|
if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
|
|
|
|
stringObjectMap.put("cardStatusName", "到期");
|
|
|
|
}
|
|
|
|
if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
|
|
|
|
stringObjectMap.put("cardStatusName", "未知");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取库存
|
|
|
|
String tempSql = "SELECT\n" +
|
|
|
|
"t.id AS id,\n" +
|
|
|
|
"t.id_device AS idDevice,\n" +
|
|
|
|
"t.num AS num,\n" +
|
|
|
|
"t.sku AS sku,\n" +
|
|
|
|
"t.state AS state,\n" +
|
|
|
|
"t.longtime AS longtime,\n" +
|
|
|
|
"t.drug_id AS drugId,\n" +
|
|
|
|
"t.drug_sku AS drugSku,\n" +
|
|
|
|
"t.drug_code AS drugCode,\n" +
|
|
|
|
"t.org_code AS orgCode,\n" +
|
|
|
|
"t.layer_no AS layerNo,\n" +
|
|
|
|
"t.wayer_no AS wayerNo,\n" +
|
|
|
|
"t.qty AS qty,\n" +
|
|
|
|
"t.create_time AS createTime,\n" +
|
|
|
|
"t.create_user AS createUser,\n" +
|
|
|
|
"t.create_user_name AS createUserName,\n" +
|
|
|
|
"t.update_time AS updateTime,\n" +
|
|
|
|
"t.update_user AS updateUser,\n" +
|
|
|
|
"t.update_user_name AS updateUserName,\n" +
|
|
|
|
"t.drug_name AS drugName,\n" +
|
|
|
|
"t.cargo_capacity AS cargoCapacity,\n" +
|
|
|
|
"t.shelf_status AS shelfStatus,\n" +
|
|
|
|
"t.price AS price,\n" +
|
|
|
|
"t.pic AS pic,\n" +
|
|
|
|
"t.equ_num AS equNum,\n" +
|
|
|
|
"t.`merge` AS `merge`" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tt.id_device = '" + stringObjectMap.get("id").toString() + "'\n" +
|
|
|
|
"AND t.equ_num = '" + stringObjectMap.get("equNum").toString() + "'\n" +
|
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
|
List<Map<String, Object>> inventoryList = hibenateUtils.createSQLQuery(sql);
|
|
|
|
}
|
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(deviceList));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取社区投放地址
|
|
* 获取社区投放地址
|