|
@ -10,6 +10,7 @@ import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedevice;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
@ -176,7 +177,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
" 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.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" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where 1=1\n";
|
|
|
|
|
@ -255,7 +260,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
" 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.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" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where 1=1\n";
|
|
|
|
|
@ -363,7 +372,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
" 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.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" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where\n";
|
|
|
|
|
@ -425,10 +438,13 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
*/
|
|
|
public JSONObject countAll() throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
String sql = "select count(1) from t_mediicine_device a";
|
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
jsonObject.put("count", count);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg", count);
|
|
|
result.put("msg", jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -445,9 +461,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
*/
|
|
|
public JSONObject countOnline() throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
String sql = "select count(1) from t_mediicine_device a where a.status = 1";
|
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("count",deviceDao.countOnline());
|
|
|
jsonObject.put("count",count);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg",jsonObject);
|
|
|
return result;
|
|
@ -498,4 +515,104 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// result.put(ResponseContant.resultMsg,"success");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject getOutOfStockDeviceList(String replenishEr, String address) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tifnull(sum(tmi.qty), 0) AS totalQty,\n" +
|
|
|
"\tifnull(\n" +
|
|
|
"\t\tt.aisles - count(tmi.id),\n" +
|
|
|
"\t\tt.aisles\n" +
|
|
|
"\t) AS unusedAisles,\n" +
|
|
|
"\tifnull(\n" +
|
|
|
"\t\tt.capacity - sum(tmi.qty),\n" +
|
|
|
"\t\tt.capacity\n" +
|
|
|
"\t) AS unuserdCapacity,\n" +
|
|
|
"\tifnull((t.capacity - sum(tmi.qty)) / t.capacity, 0) AS idleRate,\n" +
|
|
|
"\tt.id as id,\n" +
|
|
|
"\tt.belong_community as belongCommunity,\n" +
|
|
|
"\tt.community as community,\n" +
|
|
|
"\tt.del as del,\n" +
|
|
|
"\tt.delivery_address as deliveryAddress,\n" +
|
|
|
"\tt.detail_address as detailAddress,\n" +
|
|
|
"\tt.equ_area as equArea,\n" +
|
|
|
"\tt.equ_class as equClass,\n" +
|
|
|
"\tt.equ_info as equInfo,\n" +
|
|
|
"\tt.equ_name as equName,\n" +
|
|
|
"\tt.equ_num as equNum,\n" +
|
|
|
"\tt.equ_type as equType,\n" +
|
|
|
"\tt.fbelong_community as fbelongCommunity,\n" +
|
|
|
"\tt.machine_code as machineCode,\n" +
|
|
|
"\tt.network_status as networkStatus,\n" +
|
|
|
"\tt.poweron_test as poweronTest,\n" +
|
|
|
"\tt.reg_date as regDate,\n" +
|
|
|
"\tt.sale_status as saleStatus,\n" +
|
|
|
"\tt.signalintensity as signalintensity,\n" +
|
|
|
"\tt.upgr_adesit as upgrAdesit,\n" +
|
|
|
"\tt.`status` as `status`,\n" +
|
|
|
"\tt.card_status as cardStatus,\n" +
|
|
|
"\tt.operator as operator,\n" +
|
|
|
"\tt.pack_age as packAge,\n" +
|
|
|
"\tt.usage_flow as usageFlow,\n" +
|
|
|
"\tt.flow as flow,\n" +
|
|
|
"\tt.create_time as createTime,\n" +
|
|
|
"\tt.create_user as createUser,\n" +
|
|
|
"\tt.create_user_name as createUserName,\n" +
|
|
|
"\tt.update_time as updateTime,\n" +
|
|
|
"\tt.update_user as updateUser,\n" +
|
|
|
"\tt.update_user_name as updateUserName,\n" +
|
|
|
"\tt.aisles as aisles,\n" +
|
|
|
"\tt.capacity as capacity,\n" +
|
|
|
"\tt.ratio as ratio,\n" +
|
|
|
"\tt.cargo_capacity as cargoCapacity\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicine_device t\n" +
|
|
|
"LEFT JOIN t_mediicinecabinet_inventory tmi ON t.id = tmi.id_device\n" +
|
|
|
"WHERE 1=1\n" ;
|
|
|
// 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";
|
|
|
// }
|
|
|
if (!StringUtils.isEmpty(address)) {
|
|
|
sql += " AND CONCAT(t.detail_address,t.delivery_address) like '%" + address + "%'\n";
|
|
|
}
|
|
|
|
|
|
sql += "GROUP BY\n" +
|
|
|
"\tt.id\n" +
|
|
|
"HAVING\n" +
|
|
|
"\tsum(tmi.qty) < t.capacity * t.ratio\n" +
|
|
|
"OR sum(tmi.qty) IS NULL";
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg",list);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject getDetialOutOfStock(String ids) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "select * from t_mediicine_device where id in (" + ids + ",'')";
|
|
|
String sencordSql = "select tmi.layer_no as layerNo,tmi.wayer_no as wayerNo,tmi.qty,tmd.* from t_mediicinecabinet_inventory tmi left join t_mediicine_drugs tmd on tmi.barcode = tmd.id";
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
sencordSql += " where tmi.id_device = " + stringObjectMap.get("id");
|
|
|
List<Map<String, Object>> childList = null;
|
|
|
childList = hibenateUtils.createSQLQuery(sencordSql);
|
|
|
if (childList != null) {
|
|
|
stringObjectMap.put("children", childList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg",list);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|