@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;
}
原文地址:http://9966064.blog.51cto.com/9956064/1649053