| 
					
				 | 
			
			
				@ -2346,34 +2346,68 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> stringObjectMap : deviceList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String tempSql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int number; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //待补商品数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tsum(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\t\tt.cargo_capacity - cast(t.qty AS UNSIGNED)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\t)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //当前设备的库存信息-货道容量、药品数量、货道开关状态1开启,0关闭、货道正常故障状态1故障,0正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String tempConditionSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tifnull(t.cargo_capacity, 0) AS cargoCapacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tifnull(t.qty, 0) AS qty,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt.cargo_state AS cargoState,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt.fault_state AS faultState\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt.id_device = '"+stringObjectMap.get("id").toString()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt.id_device = '" + String.valueOf(stringObjectMap.get("id")) + "'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            number = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("daibushangpinshuliang", number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //设备列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //待补商品数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            int number; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            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 = '"+stringObjectMap.get("id").toString()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            number = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            stringObjectMap.put("daibushangpinshuliang", number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int normalOpenCargoCapacity = list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .filter(item -> "1".equals(String.valueOf(item.get("cargoState")))  && "0".equals(String.valueOf(item.get("faultState")))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .mapToInt(item -> Integer.parseInt(String.valueOf(item.get("cargoCapacity")))).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int usedCargoCapacity = list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .filter(item -> "1".equals(String.valueOf(item.get("cargoState")))  && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "0".equals(String.valueOf(item.get("faultState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer.parseInt(String.valueOf(item.get("qty"))) > 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .mapToInt(item -> Integer.parseInt(String.valueOf(item.get("qty")))).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("daibushangpinshuliang", normalOpenCargoCapacity - usedCargoCapacity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //未设置商品货道 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tcount(DISTINCT(t.id))\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tt.id_device = '" + stringObjectMap.get("id").toString() + "'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "AND t.org_code IS NULL\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "AND t.drug_code IS NULL\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            number = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("weishezhishangpinhuodao", number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //空置率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tcount(DISTINCT(t.id))\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tt.id_device = '" + stringObjectMap.get("id").toString() + "'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "AND t.org_code IS NULL\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "AND t.drug_code IS NULL\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            number = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            stringObjectMap.put("weishezhishangpinhuodao", number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            //空置率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            stringObjectMap.put("kongzhilv", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    new BigDecimal((number * 1.0) / Integer.parseInt(stringObjectMap.get("aisles").toString())).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //newVersion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //正常货道数(正常的、开启的) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int normalCargoNumber = ((int) list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && "0".equals(String.valueOf(item.get("faultState")))).count()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //已用货道数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int usedCargoNumber = ((int) list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "0".equals(String.valueOf(item.get("faultState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer.parseInt(String.valueOf(item.get("qty"))) > 0).count()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("kongzhilv", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BigDecimal((number * 1.0) / Integer.parseInt(stringObjectMap.get("aisles").toString())).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BigDecimal(((normalCargoNumber-usedCargoNumber) * 1.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //上一次补货时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\t(\n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2390,7 +2424,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\t\t\t0\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\t\t)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\t)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            number = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int number = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (number != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "\tcreate_time\n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2628,7 +2662,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String daibuSql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int daibuNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            int daibuNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //当前设备的库存信息-货道容量、药品数量、货道开关状态1开启,0关闭、货道正常故障状态1故障,0正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String tempConditionSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\tifnull(t.cargo_capacity, 0) AS cargoCapacity,\n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2643,16 +2677,16 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //设备列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //待补商品数量(待入库药品数量) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            daibuSql = "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 = '"+stringObjectMap.get("id").toString()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            daibuNumber = jdbcTemplate.queryForObject(daibuSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            daibuSql = "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 = '"+stringObjectMap.get("id").toString()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            daibuNumber = jdbcTemplate.queryForObject(daibuSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            stringObjectMap.put("daibushangpinshuliang", daibuNumber); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //newVersion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //所有正常状态货道容量 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2697,7 +2731,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //空置率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            stringObjectMap.put("kongzhilv", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    new BigDecimal((number * 1.0) / Integer.parseInt(stringObjectMap.get("aisles").toString())).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //newVersion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //正常货道数(正常的、开启的) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int normalCargoNumber = ((int) list.stream() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2709,7 +2742,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer.parseInt(String.valueOf(item.get("qty"))) > 0).count()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("kongzhilv", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BigDecimal(((normalCargoNumber-usedCargoNumber) * 100.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BigDecimal(((normalCargoNumber-usedCargoNumber) * 1.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //商品庫存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Integer inventoryNum = inventoryDao.sumInventoryWithEquNum(stringObjectMap.get("equNum")+"", "1", "21"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4741,6 +4774,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                MediicinecabinetInventory inventory =  inventoryDao.findOne(str[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //更新设备缺货状态的该药品的已变动数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                InventoryDO inventoryDO = new InventoryDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                inventoryDO.setCargoId(inventory.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                inventoryDO.setDrugCode(inventory.getDrugCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                inventoryDO.setOrgCode(inventory.getOrgCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                inventoryDO.setRatedInventory(inventory.getRatedInventory()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4857,7 +4891,8 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        updateDeviceState(inventory.getId(), inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //如果正常开启的总计库存为0强制更新设备为缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                setDeviceInventoryStatusByOneInventory(inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                mediicinecabinetInventory = inventoryDao.save(inventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //重算设备容量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (cargoCapacityChanged && i == str.length - 1) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4888,6 +4923,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            MediicinecabinetInventory inventory =  inventoryDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //更新设备缺货状态的该药品的已变动数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            InventoryDO inventoryDO = new InventoryDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            inventoryDO.setCargoId(inventory.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            inventoryDO.setDrugCode(inventory.getDrugCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            inventoryDO.setOrgCode(inventory.getOrgCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            inventoryDO.setRatedInventory(inventory.getRatedInventory()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5005,8 +5041,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    updateDeviceState(inventory.getId(), inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //如果正常开启的总计库存为0强制更新设备为缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            setDeviceInventoryStatusByOneInventory(inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            inventoryDao.save(inventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //重算设备容量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (cargoCapacityChanged) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5035,6 +5073,37 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * (正常,开启的)库存为零更新设备为缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param inventory 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void setDeviceInventoryStatusByOneInventory(InventoryDO inventory) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Mediicinedevice device = deviceDao.findOne(inventory.getIdDevice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(device == null) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //当前设备的库存信息-货道容量、药品数量、货道开关状态1开启,0关闭、货道正常故障状态1故障,0正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String tempConditionSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tifnull(t.cargo_capacity, 0) AS cargoCapacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tifnull(t.qty, 0) AS qty,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.cargo_state AS cargoState,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.fault_state AS faultState\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.id_device = '" + device.getId() + "'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.id != '" + inventory.getCargoId() + "'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND (t.state = '1' OR t.state = '21')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempConditionSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int totalDrugNumber = list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                .filter(item -> "1".equals(String.valueOf(item.get("cargoState")))  && "0".equals(String.valueOf(item.get("faultState")))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                .mapToInt(item -> Integer.parseInt(String.valueOf(item.get("qty")))).sum() + inventory.getQty(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (totalDrugNumber == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            device.setStatus("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceDao.save(device); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 物联网大屏统计数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 |