示例#1
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/component/save",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object saveComponent(@RequestBody AreaComponentEntity componentEntity) {

    if (componentEntity.getId() == null) {
      DoorTemplateEntity doorTemplateEntity =
          (DoorTemplateEntity)
              baseService.getObject(
                  DoorTemplateEntity.class, componentEntity.getDoor_template_id());
      componentEntity.setDoorTemplateEntity(doorTemplateEntity);
      doorTemplateEntity.getAreaComponentEntities().add(componentEntity);
      baseService.saveEntity(componentEntity);

    } else {
      AreaComponentEntity entity =
          (AreaComponentEntity)
              baseService.getObject(AreaComponentEntity.class, componentEntity.getId());
      entity.setName(componentEntity.getName());
      entity.setFnumber(componentEntity.getFnumber());
      baseService.updateEntity(entity);
    }

    return componentEntity;
  }
示例#2
0
  private List<TreeNode> getCompoentTree(List<AreaComponentEntity> compoents, Long id) {
    List<TreeNode> result = new ArrayList<TreeNode>();
    if (id == null) {
      for (AreaComponentEntity _component : compoents) {
        if (_component.getSuper_id() == null) {
          TreeNode treeNode = new TreeNode();
          treeNode.setId(_component.getId());
          treeNode.setText(_component.getName());
          MaterialBean department =
              materialListManager.getDepartmentEntityByFNumber(_component.getFnumber());

          if (department != null) {
            treeNode.setIdx(department.getFname());
          }

          result.add(treeNode);
        }
      }
    } else {
      for (AreaComponentEntity _component : compoents) {
        if (id.equals(_component.getSuper_id())) {
          TreeNode treeNode = new TreeNode();
          treeNode.setId(_component.getId());
          treeNode.setText(_component.getName());
          MaterialBean department =
              materialListManager.getDepartmentEntityByFNumber(_component.getFnumber());
          if (department != null) {
            treeNode.setIdx(department.getFname());
          }
          result.add(treeNode);
        }
      }
    }
    for (TreeNode _node : result) {
      _node.setChildren(getCompoentTree(compoents, _node.getId()));
    }

    return result;
  }