|
@ -3097,26 +3097,105 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray selectById(String deviceId){
|
|
|
List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByDeviceId(deviceId);
|
|
|
List<Map<String,Object>> maps = inventoryDao.selectByDeviceIdGroup(deviceId);
|
|
|
// List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByDeviceId(deviceId);
|
|
|
// List<Map<String,Object>> maps = inventoryDao.selectByDeviceIdGroup(deviceId);
|
|
|
// JSONArray array = new JSONArray();
|
|
|
// for (Map<String,Object> map:maps){
|
|
|
// String id = map.get("layerNo").toString();
|
|
|
// JSONObject object = new JSONObject();
|
|
|
// JSONArray jsonArray = new JSONArray();
|
|
|
// MediicinecabinetInventory tempInventory = new MediicinecabinetInventory();
|
|
|
// for (MediicinecabinetInventory inventory:list){
|
|
|
// if ("21".equals(inventory.getState())) {
|
|
|
// tempInventory = inventory;
|
|
|
// }
|
|
|
// if ("20".equals(inventory.getState())) {
|
|
|
// inventory.setCargoCapacity(tempInventory.getCargoCapacity());
|
|
|
// inventory.setPrice(tempInventory.getPrice());
|
|
|
// inventory.setDrugName(tempInventory.getDrugName());
|
|
|
// inventory.setQty(tempInventory.getQty());
|
|
|
// }
|
|
|
// if (id.equalsIgnoreCase(inventory.getLayerNo())){
|
|
|
// jsonArray.add(inventory);
|
|
|
// }
|
|
|
// }
|
|
|
// object.put(id,jsonArray);
|
|
|
// array.add(object);
|
|
|
// }
|
|
|
// return array;
|
|
|
|
|
|
String sql = "";
|
|
|
{
|
|
|
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" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '" +deviceId + "'\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"cast(t.layer_no AS UNSIGNED),cast(t.wayer_no AS UNSIGNED)\n";
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
{
|
|
|
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();
|
|
|
MediicinecabinetInventory tempInventory = new MediicinecabinetInventory();
|
|
|
for (MediicinecabinetInventory inventory:list){
|
|
|
if ("21".equals(inventory.getState())) {
|
|
|
tempInventory = inventory;
|
|
|
}
|
|
|
if ("20".equals(inventory.getState())) {
|
|
|
inventory.setCargoCapacity(tempInventory.getCargoCapacity());
|
|
|
inventory.setPrice(tempInventory.getPrice());
|
|
|
inventory.setDrugName(tempInventory.getDrugName());
|
|
|
inventory.setQty(tempInventory.getQty());
|
|
|
}
|
|
|
if (id.equalsIgnoreCase(inventory.getLayerNo())){
|
|
|
jsonArray.add(inventory);
|
|
|
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())) {
|
|
|
inventoryMap.put("cargoCapacity", tempInventory.get("cargoCapacity").toString());
|
|
|
inventoryMap.put("price", tempInventory.get("price").toString());
|
|
|
inventoryMap.put("drugName", tempInventory.get("drugName").toString());
|
|
|
inventoryMap.put("qty", tempInventory.get("qty").toString());
|
|
|
}
|
|
|
if (id.equalsIgnoreCase(inventoryMap.get("layerNo").toString())){
|
|
|
jsonArray.add(inventoryMap);
|
|
|
}
|
|
|
}
|
|
|
object.put(id,jsonArray);
|