| 
					
				 | 
			
			
				@ -1610,25 +1610,29 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("device",device); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //货道总数----->行*列计算得出货道总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tcount(distinct(t.layer_no)) as layerNum\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.id_device = '"+device.getId()+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int layerNum = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tcount(distinct(t.wayer_no)) as wayerNum\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.id_device = '"+device.getId()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND t.layer_no = '1'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int wayerNum = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("totalCargo", layerNum * wayerNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tcount(distinct(t.layer_no)) as layerNum\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tt.id_device = '"+device.getId()+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        int layerNum = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tcount(distinct(t.wayer_no)) as wayerNum\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tt_mediicinecabinet_inventory t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tt.id_device = '"+device.getId()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "AND t.layer_no = '1'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        int wayerNum = jdbcTemplate.queryForObject(tempSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //补货员端设备页面上的总货道 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        jsonObject.put("totalCargo", layerNum * wayerNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备总货道容量---初始1200 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("deviceCapacity", device.getCapacity()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tIFNULL(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\t(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\t\tSELECT\n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1685,6 +1689,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int drugNumber = 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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //总货道(合并货道的算一道) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("totalCargo", list.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //关闭容量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        tempSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tifnull(sum(t.cargo_capacity), 0) AS closedCapacity\n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2415,10 +2423,12 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int noSetDrugCargoNumber =  normalCargoNumber  - alreadySetDrugNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("weishezhishangpinhuodao", noSetDrugCargoNumber); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //newVersion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //已用货道数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //已用货道数(有绑定数量的就行) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int usedCargoNumber = ((int) list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "0".equals(String.valueOf(item.get("faultState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    !StringUtils.isEmpty(item.get("orgCode")) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    !StringUtils.isEmpty(item.get("drugCode")) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer.parseInt(String.valueOf(item.get("qty"))) > 0).count()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("kongzhilv", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BigDecimal(((normalCargoNumber-usedCargoNumber) * 1.0) / normalCargoNumber).setScale(2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2768,6 +2778,8 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int usedCargoNumber = ((int) list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    .filter(item -> "1".equals(String.valueOf(item.get("cargoState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "0".equals(String.valueOf(item.get("faultState"))) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            !StringUtils.isEmpty(item.get("orgCode")) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            !StringUtils.isEmpty(item.get("drugCode")) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer.parseInt(String.valueOf(item.get("qty"))) > 0).count()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            stringObjectMap.put("kongzhilv", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4793,7 +4805,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MediicinecabinetInventory updateMediicinecabineInventoryInfoById(String id,String qty,String cargoCapacity,String status,Boolean refreshStatus,String userId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MediicinecabinetInventory updateMediicinecabineInventoryInfoById(String id,String qty,String cargoCapacity,String status, Boolean refreshStatus, String userId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (id.contains(",")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String str[] = id.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            MediicinecabinetInventory mediicinecabinetInventory = new MediicinecabinetInventory(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4916,14 +4928,14 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //默认false,通过规则判断是否缺货 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!refreshStatus) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //更改设备缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        updateDeviceState(inventory.getId(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        updateDeviceState(inventory.getId(), inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        updateDeviceState(inventory.getId(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        updateDeviceState(inventory.getId(), inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //如果正常开启的总计库存为0强制更新设备为缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                setDeviceInventoryStatusByOneInventory(inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                setDeviceInventoryStatusByOneInventory(inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                mediicinecabinetInventory = inventoryDao.save(inventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //重算设备容量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (cargoCapacityChanged && i == str.length - 1) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5068,14 +5080,14 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //默认false,通过规则判断是否缺货 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!refreshStatus) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //更改设备缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    updateDeviceState(inventory.getId(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    updateDeviceState(inventory.getId(), inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    updateDeviceState(inventory.getId(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    updateDeviceState(inventory.getId(), inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //如果正常开启的总计库存为0强制更新设备为缺货状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            setDeviceInventoryStatusByOneInventory(inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            setDeviceInventoryStatusByOneInventory(inventoryDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            inventoryDao.save(inventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //重算设备容量 
			 |