Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java =================================================================== diff -u -r14910 -r15029 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 14910) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 15029) @@ -830,47 +830,49 @@ String querySql = "where po.departCoding = '" + deptCode + "' and po.tousseName in ('" + tousseNameStr.replace("#,", "','") + "')"; List stocklist = departmentStockManager.getDeptStockBySql(querySql); - for (DepartmentStock departmentStock : stocklist) { - Integer recycleAmount = map.get(departmentStock.getTousseName()); - if (departmentStock != null) { - // 修改库存(库存不能未负数) - Integer stockAmount = 0; - Integer usedAmount = null; - if (departmentStock.getAmount() >= recycleAmount) { - stockAmount = departmentStock.getAmount() - recycleAmount; - - String sqlStr = "select top " - + recycleAmount - + " id from tousseInstance where departmentStock_id = " - + departmentStock.getId() - + " order by id asc"; - - if(dbConnection.isOracle()){ - sqlStr = "select id from (select id from tousseInstance where departmentStock_id = " + if(CollectionUtils.isNotEmpty(stocklist)){ + for (DepartmentStock departmentStock : stocklist) { + Integer recycleAmount = map.get(departmentStock.getTousseName()); + if (recycleAmount != null) { + // 修改库存(库存不能未负数) + Integer stockAmount = 0; + Integer usedAmount = null; + if (departmentStock.getAmount() >= recycleAmount) { + stockAmount = departmentStock.getAmount() - recycleAmount; + + String sqlStr = "select top " + + recycleAmount + + " id from tousseInstance where departmentStock_id = " + departmentStock.getId() - + " order by id asc) where rownum <= " + recycleAmount; + + " order by id asc"; + if(dbConnection.isOracle()){ + sqlStr = "select id from (select id from tousseInstance where departmentStock_id = " + + departmentStock.getId() + + " order by id asc) where rownum <= " + recycleAmount; + + + } + String updateSql = "update tousseInstance set departmentStock_id = null where id in(" + + sqlStr + ")"; + objectDao.excuteSQL(updateSql); } - - String updateSql = "update tousseInstance set departmentStock_id = null where id in(" - + sqlStr + ")"; - objectDao.excuteSQL(updateSql); - } - // 修改已使用数量 - if (departmentStock.getUsedAmount() != null) { - if (recycleAmount >= departmentStock.getUsedAmount()) { - usedAmount = 0; - } else { - usedAmount = departmentStock.getUsedAmount() - recycleAmount; + // 修改已使用数量 + if (departmentStock.getUsedAmount() != null) { + if (recycleAmount >= departmentStock.getUsedAmount()) { + usedAmount = 0; + } else { + usedAmount = departmentStock.getUsedAmount() - recycleAmount; + } } + //保存 + String stockSql = "update DepartmentStock set amount = " + + stockAmount+ ",usedAmount = " + usedAmount + + " where id = " + departmentStock.getId(); + objectDao.excuteSQL(stockSql); } - //保存 - String stockSql = "update DepartmentStock set amount = " - + stockAmount+ ",usedAmount = " + usedAmount - + " where id = " + departmentStock.getId(); - objectDao.excuteSQL(stockSql); } } }