Пример #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
 @SuppressWarnings("unchecked")
 @RequestMapping(
     value = "/department/group/list",
     method = {RequestMethod.GET, RequestMethod.POST})
 @ResponseBody
 public Object getT_departments_group() {
   List<AreaComponentEntity> componentEntities =
       baseService.getlist("from AreaComponentEntity entity group by entity.name");
   Map<String, StrObjData> maps = new ConcurrentHashMap<String, StrObjData>();
   for (AreaComponentEntity _component : componentEntities) {
     String name = _component.getName();
     if (maps.get(name) == null) {
       maps.put(name, new StrObjData(_component.getName(), _component.getName()));
     }
   }
   return maps.values();
 }
Пример #3
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;
  }