|
@ -4642,6 +4642,107 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
return array;
|
|
return array;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据设备id查询设备轨道数据
|
|
|
|
*
|
|
|
|
* @param deviceId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public PageEnvelop selectByIdPage(String deviceId,Integer page,Integer pageSize){
|
|
|
|
page = page>0?page-1:0;
|
|
|
|
String sql = " 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`,\n" +
|
|
|
|
"t.cargo_state AS cargoState,\n" +
|
|
|
|
"d.specif AS specif,\n" +
|
|
|
|
"t.fault_state AS faultState\n" ;
|
|
|
|
String sqlCount = " select count(t.id) as total ";
|
|
|
|
String sqlTab =
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicinecabinet_inventory t left join t_mediicine_drugs d on d.id = t.drug_id \n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tt.id_device = '" +deviceId + "'\n" +
|
|
|
|
"ORDER BY\n" +
|
|
|
|
"cast(t.layer_no AS UNSIGNED),cast(t.wayer_no AS UNSIGNED)\n";
|
|
|
|
sql = sql+sqlTab+" limit "+page*pageSize+","+pageSize;
|
|
|
|
|
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
Long total = jdbcTemplate.queryForObject(sqlCount+sqlTab,Long.class);
|
|
|
|
{
|
|
|
|
sql = "SELECT\n" +
|
|
|
|
"\tlayer_no AS layerNo\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicinecabinet_inventory\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tid_device = '" + deviceId +"'\n" +
|
|
|
|
"GROUP BY\n" +
|
|
|
|
"\tlayer_no\n" +
|
|
|
|
"ORDER BY\n" +
|
|
|
|
"\tcast(layer_no AS UNSIGNED)";
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Map<String,Object>> maps = hibenateUtils.createSQLQuery(sql);
|
|
|
|
|
|
|
|
JSONArray array = new JSONArray();
|
|
|
|
for (Map<String,Object> map:maps){
|
|
|
|
String id = map.get("layerNo").toString();
|
|
|
|
JSONObject object = new JSONObject();
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
Map<String, Object> tempInventory = new HashMap<>();
|
|
|
|
for (Map<String, Object> inventoryMap :list){
|
|
|
|
if ("21".equals(inventoryMap.get("state").toString())) {
|
|
|
|
tempInventory = inventoryMap;
|
|
|
|
}
|
|
|
|
if ("20".equals(inventoryMap.get("state").toString())) {
|
|
|
|
if (tempInventory != null) {
|
|
|
|
if (tempInventory.get("cargoCapacity") != null && !StringUtils.isEmpty(tempInventory.get("cargoCapacity").toString())) {
|
|
|
|
inventoryMap.put("cargoCapacity", tempInventory.get("cargoCapacity").toString());
|
|
|
|
}
|
|
|
|
if (tempInventory.get("price") != null && !StringUtils.isEmpty(tempInventory.get("price").toString())) {
|
|
|
|
inventoryMap.put("price", tempInventory.get("price").toString());
|
|
|
|
}
|
|
|
|
if (tempInventory.get("drugName") != null && !StringUtils.isEmpty(tempInventory.get("drugName").toString())) {
|
|
|
|
inventoryMap.put("drugName", tempInventory.get("drugName").toString());
|
|
|
|
}
|
|
|
|
if (tempInventory.get("qty") != null && !StringUtils.isEmpty(tempInventory.get("qty").toString())) {
|
|
|
|
inventoryMap.put("qty", tempInventory.get("qty").toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (id.equalsIgnoreCase(inventoryMap.get("layerNo").toString())){
|
|
|
|
jsonArray.add(inventoryMap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object.put(id,jsonArray);
|
|
|
|
array.add(object);
|
|
|
|
}
|
|
|
|
return PageEnvelop.getSuccessListWithPage("success",array,page,pageSize,total);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更换商品,或者设定商品
|
|
* 更换商品,或者设定商品
|