|  | @ -1211,6 +1211,61 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         jsonObject.put("device",device);
 | 
	
		
			
				|  |  |         jsonObject.put("totalCargo", device.getAisles());   //货道合并/解离
 | 
	
		
			
				|  |  |         //设备容量
 | 
	
		
			
				|  |  |         jsonObject.put("deviceCapacity", device.getCapacity());
 | 
	
		
			
				|  |  |         String tempSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tsum(t.qty)\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\tt_mediicinecabinet_inventory t\n" +
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\tt.id_device = '"+device.getId()+"'\n" +
 | 
	
		
			
				|  |  |                 "AND (t.state = '1' OR t.state = '21')\n" +
 | 
	
		
			
				|  |  |                 "AND t.shelf_status = '1'";
 | 
	
		
			
				|  |  |         int inStock = jdbcTemplate.queryForObject(tempSql, Integer.class);
 | 
	
		
			
				|  |  |         //在架库存数
 | 
	
		
			
				|  |  |         jsonObject.put("inStock", inStock);
 | 
	
		
			
				|  |  |         jsonObject.put("inStockRate", new BigDecimal((inStock * 1.0) / Integer.parseInt(device.getCapacity())).setScale(2, BigDecimal.ROUND_HALF_UP));
 | 
	
		
			
				|  |  |         //缺货库存Out of stock
 | 
	
		
			
				|  |  |         tempSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tsum(\n" +
 | 
	
		
			
				|  |  |                 "\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" +
 | 
	
		
			
				|  |  |                 "\t)\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\tt_mediicinecabinet_inventory t\n" +
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\tt.id_device = '"+ device.getId() +"'\n" +
 | 
	
		
			
				|  |  |                 "AND (t.state = '1' OR t.state = '21')";
 | 
	
		
			
				|  |  |         int outOfStock = jdbcTemplate.queryForObject(tempSql, Integer.class);
 | 
	
		
			
				|  |  |         //在架库存数
 | 
	
		
			
				|  |  |         jsonObject.put("outOfStock", outOfStock);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         tempSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT(t.id))\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\tt_mediicinecabinet_inventory t\n" +
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\tt.id_device = '"+device.getId()+"'\n" +
 | 
	
		
			
				|  |  |                 "and cast(t.qty AS UNSIGNED) < t.num\n" +
 | 
	
		
			
				|  |  |                 "AND (t.state = '1'\n" +
 | 
	
		
			
				|  |  |                 "OR t.state = '21')";
 | 
	
		
			
				|  |  |         //预警货道
 | 
	
		
			
				|  |  |         int earlyWarningCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
 | 
	
		
			
				|  |  |         jsonObject.put("earlyWarningCargo", earlyWarningCargo);
 | 
	
		
			
				|  |  |         tempSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT(t.id))\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\tt_mediicinecabinet_inventory t\n" +
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\tt.id_device = '\" + device.getId() + \"'\n" +
 | 
	
		
			
				|  |  |                 "and t.cargo_state = '0'\n" +
 | 
	
		
			
				|  |  |                 "AND (t.state = '1'\n" +
 | 
	
		
			
				|  |  |                 "OR t.state = '21')";
 | 
	
		
			
				|  |  |         //关闭货道
 | 
	
		
			
				|  |  |         int closedCargo = jdbcTemplate.queryForObject(tempSql, Integer.class);
 | 
	
		
			
				|  |  |         jsonObject.put("closedCargo", closedCargo);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //1补货,2换货,3上架,4下架
 | 
	
		
			
				|  |  |         jsonObject.put("inventoryList",inventoryRecordDao.findMedicineDrugInventoryRecordsByDeviceIdAndEquNumAndType(device.getId(), device.getEquNum(),"1"));
 | 
	
		
			
				|  |  |         result.put("response",ConstantUtils.SUCCESS);
 |