码迷,mamicode.com
首页 > 编程语言 > 详细

java使用Iterator、for循环同步数据

时间:2015-05-08 15:11:41      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:java、iterator 、同步

 @Override

 public List<AaVO> getAllData() {

//根据库存组织查询基础数据表、部门表

List<PlanDeptpower> planDeptpowers = aaServiceDao.getByOrganizationId(86L);

List<BomDepartmentsVO> bomDepartments = bomDepartmentsService.findByOrganizationId(86L);

Iterator<PlanDeptpower> planDeptpowerItrator = planDeptpowers.iterator();

Boolean beFound = false;

//Iterator<BomDepartmentsVO> bomDepartmentsItrator = bomDepartments.iterator();

//基础表匹配bomDepartment表没有则删除

while (planDeptpowerItrator.hasNext()) {

PlanDeptpower pd = planDeptpowerItrator.next();

for(BomDepartmentsVO bm: bomDepartments) {

   if (pd.getDeptPtr().equals(bm.getDepartmentId())) {

   beFound = true;

   break;

   } 

}

if (beFound == false) {

aaServiceDao.deleteById(pd.getRkey());

planDeptpowerItrator.remove();

}

beFound = false;

}

//bomDepartment表匹配基础表,没有则增加

for(BomDepartmentsVO bm: bomDepartments) {

for (PlanDeptpower pd:planDeptpowers) {

if (bm.getDepartmentId().equals(pd.getDeptPtr())) {

   beFound = true;

   break;

   }

}

 if (beFound == false) {

 System.out.println("增加");

 PlanDeptpower planDeptpower = new PlanDeptpower();

 planDeptpower.setDeptPtr(bm.getDepartmentId());

 planDeptpower.setTtype(1);

 planDeptpower.setData0000Ptr(86L);

 aaServiceDao.save(planDeptpower);

 }

 beFound = false;

}

List<AaVO> aaVOs = aaServiceDao.getAllData();

return aaVOs;

}


java使用Iterator、for循环同步数据

标签:java、iterator 、同步

原文地址:http://9966064.blog.51cto.com/9956064/1649053

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!