标签:cep rem class type ems none get 信息 bean
public int modifyMiss(RESINFO bean, List<MISSINGISTEMS> missings, List<MISSINGISTEMS> missList) throws Exception { int result = StatusType.DEFAULT ; RESINFO resinfo = new RESINFO(); resinfo.setID(bean.getID()); resinfo = this.bean(resinfo); List<MISSINGISTEMS> missingModify = new ArrayList<MISSINGISTEMS>();//存储添加和删除的缺件信息 List<MISSINGISTEMS> missingDel = new ArrayList<MISSINGISTEMS>();//存储删除的缺件信息列表 List<MISSINGISTEMS> missingAdd = new ArrayList<MISSINGISTEMS>();//存储添加进来的缺件信息列表 if (NoneType.isNullOrEmpty(missings) && NoneType.isNullOrEmpty(missList)) {//说明修改前后都没有缺件 result = this.daoProvider().modify(bean); }else if (NoneType.isNullOrEmpty(missings) && !NoneType.isNullOrEmpty(missList) ) {//修改前没有缺件,修改后存在缺件 for(MISSINGISTEMS missingistems : missList ){ missingistems.setID(KeyGenerator.instance().getKey()); missingistems.setRESID(resinfo.getID()); } this.daoProvider(false).batchInsert(missList); result = this.daoProvider().modify(bean); }else if (!NoneType.isNullOrEmpty(missings) && NoneType.isNullOrEmpty(missList)) {//修改后删除全部的缺件 this.daoProvider(false).batchDelete(missings); result = this.daoProvider().modify(bean); }else { missingModify = getDiffrent(missings, missList);//找到新增和删除掉的缺件 for(MISSINGISTEMS miss : missingModify){ if (NoneType.isNullOrEmpty(miss.getID())) {//找到新增的缺件信息 missingAdd.add(miss); }else{ missingDel.add(miss); } } for(MISSINGISTEMS missing : missingAdd ){ missing.setID(KeyGenerator.instance().getKey()); missing.setRESID(resinfo.getID()); } if(!NoneType.isNullOrEmpty(missingAdd)){ this.daoProvider(false).batchInsert(missingAdd); } if(!NoneType.isNullOrEmpty(missingDel)){ this.daoProvider(false).batchDelete(missingDel); } result = this.daoProvider().modify(bean); } return result ; } /** * 获取两个List的不同元素 * @param missings 表示修改前的缺件信息列表 * @param missList 表示修改后的缺件信息列表 * @return */ private static List<MISSINGISTEMS> getDiffrent(List<MISSINGISTEMS> missings, List<MISSINGISTEMS> missList) { List<MISSINGISTEMS> missingistems = new ArrayList<MISSINGISTEMS>(); for(MISSINGISTEMS miss : missList){ if (NoneType.isNullOrEmpty(miss.getID())) {//找到新增的缺件信息 missingistems.add(miss); } } for(MISSINGISTEMS missing : missings){ if(!missList.contains(missing)){//找到删除掉的缺件信息 missingistems.add(missing); } } return missingistems; } }
标签:cep rem class type ems none get 信息 bean
原文地址:https://www.cnblogs.com/singworld/p/9927249.html