Index: ssts-web/src/main/webapp/disinfectsystem/toussemanager/toussemaintain/tousseMaintainForm.js =================================================================== diff -u -r13962 -r13979 --- ssts-web/src/main/webapp/disinfectsystem/toussemanager/toussemaintain/tousseMaintainForm.js (.../tousseMaintainForm.js) (revision 13962) +++ ssts-web/src/main/webapp/disinfectsystem/toussemanager/toussemaintain/tousseMaintainForm.js (.../tousseMaintainForm.js) (revision 13979) @@ -247,7 +247,9 @@ success : function(form, action) { tousseMaintainWin.close(); showResult('保存成功'); - grid.dwrReload(); + if("undefined" != typeof(grid)){ + grid.dwrReload(); + } }, failure : function(form, action) { showResult('failure = ' + action.result.message,'error'); Index: ssts-idcard/src/main/java/com/forgon/disinfectsystem/idcardinstance/util/IDCardInstanceUtils.java =================================================================== diff -u -r13963 -r13979 --- ssts-idcard/src/main/java/com/forgon/disinfectsystem/idcardinstance/util/IDCardInstanceUtils.java (.../IDCardInstanceUtils.java) (revision 13963) +++ ssts-idcard/src/main/java/com/forgon/disinfectsystem/idcardinstance/util/IDCardInstanceUtils.java (.../IDCardInstanceUtils.java) (revision 13979) @@ -106,54 +106,45 @@ .format(" where po.idCardInstanceIDBarcode= \'%s\' and po.beenUseCount=(select max(beenUseCount) from %s where idCardInstanceIDBarcode= \'%s\' )", idCardBardcode, TousseMaintain.class.getSimpleName(), idCardBardcode); - TousseMaintain tousseMaintain = (TousseMaintain) objectDao.getBySql( + TousseMaintain tousseMaintainMaxCount = (TousseMaintain) objectDao.getBySql( TousseMaintain.class.getSimpleName(), sql); - // 已经保养过的处理 - if(tousseMaintain != null) - { + // 通过最新的保养时间判断是否保养 + String sql1 = String + .format(" where po.idCardInstanceIDBarcode= \'%s\' order by maintainTime desc )", + idCardBardcode, TousseMaintain.class.getSimpleName(), + idCardBardcode); + List tms = (List)objectDao.findBySql(TousseMaintain.class.getSimpleName(), sql1); + if(tms != null && tms.size() > 0 ){ + TousseMaintain tousseMaintainLastTime = tms.get(0); // 如果要校验时间 那上次保养时间跟现在的时间比较 if(intervalTime > 0) { - String lastMaintainTime = tousseMaintain.getOperationTime(); + String lastMaintainTime = tousseMaintainLastTime.getMaintainTime(); SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm"); Date lastMaintainDate = sim.parse(lastMaintainTime); Date now = new Date(); long diff = now.getTime() - lastMaintainDate.getTime(); long days = diff / (1000 * 60 * 60 * 24); - if( days > intervalTime){ + if( days >= intervalTime){ return true; } } + } + + // 已经保养过的处理 + if(tousseMaintainMaxCount != null) + { // 如果要校验使用次数 上次保养时候的使用次数和现在的次数比较 if(intervalCount > 0) { - int ic = (int)(idCardInstance.getIDCardDefinition(objectDao).getUseAmount() - tousseMaintain.getBeenUseCount()); + int ic = (int)(idCardInstance.getIDCardDefinition(objectDao).getUseAmount() - tousseMaintainMaxCount.getBeenUseCount()); if( ic >= intervalCount) { return true; } - } }else{ - // 还没有进行保养过的情况 -// if(intervalTime > 0){ -// // 找到该标识牌的器械包实例首次使用时间(装配时间) -// sql = String.format(" where po.idCardInstanceID=%s and po.id = (select min(id) from %s where idCardInstanceID=%s)", -// idCardInstanceID, TousseInstance.class.getSimpleName(), -// idCardInstanceID); -// TousseInstance tousseInstance = (TousseInstance) objectDao.getBySql( -// TousseInstance.class.getSimpleName(), sql); -// if(tousseInstance != null) -// { -// Date firstUseDate = tousseInstance.getOperationTime(); -// Date now = new Date(); -// long diff = now.getTime() - firstUseDate.getTime(); -// long days = diff / (1000 * 60 * 60 * 24); -// if( days >= intervalTime){ -// return true; -// } -// } -// } + // 没有保养过,通过判断标识牌定义的使用次数判断是否保养 if(intervalCount > 0){ if(idCardInstance.getIDCardDefinition(objectDao).getUseAmount() >= intervalCount) {