Esempio n. 1
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/areaMaterialConfigs/clone/list",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object cloneMaterialConfigsEntitys(@RequestBody IdLongsBean bean) {

    if (bean.getId() == null || bean.getId() == 0L) {
      return bean;
    }
    AreaComponentEntity componentEntity =
        (AreaComponentEntity) baseService.getObject(AreaComponentEntity.class, bean.getId());
    //    	List<AreaMaterialsConfigEntity> old_entities =
    // componentEntity.getAreaMaterialsConfigEntities();
    String hql = "from AreaMaterialsConfigEntity entity where entity.id in(:ids)";
    Map<String, Object> params = new ConcurrentHashMap<String, Object>();
    params.put("ids", bean.getLongs());
    List<AreaMaterialsConfigEntity> clone_entities = baseService.getlist(hql, params);

    for (AreaMaterialsConfigEntity _clone_entity : clone_entities) {
      AreaMaterialsConfigEntity has = null;
      has = new AreaMaterialsConfigEntity();
      has.setUsageScript(_clone_entity.getUsageScript());
      has.setHelpCodeScript(_clone_entity.getHelpCodeScript());
      has.setParamScript(_clone_entity.getParamScript());
      has.setConditionScript(_clone_entity.getConditionScript());
      has.setQuerySqlId(_clone_entity.getQuerySqlId());
      has.setFname(_clone_entity.getFname());
      has.setAreaComponentEntity(componentEntity);
      componentEntity.getAreaMaterialsConfigEntities().add(has);
      baseService.saveEntity(has);
    }

    return bean;
  }
Esempio n. 2
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;
  }
Esempio n. 3
0
 @SuppressWarnings("unchecked")
 private void findComponentTree(List<AreaComponentEntity> result, Long componentId) {
   List<AreaComponentEntity> componentEntities =
       baseService.getlist(
           "from AreaComponentEntity componentEntity where componentEntity.super_id = "
               + componentId);
   for (AreaComponentEntity _entity : componentEntities) {
     result.add(_entity);
     findComponentTree(result, _entity.getId());
   }
 }
Esempio n. 4
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();
 }
Esempio n. 5
0
 @SuppressWarnings("unchecked")
 @RequestMapping(
     value = "/component/areaMaterials/{componentId}",
     method = {RequestMethod.GET, RequestMethod.POST})
 @ResponseBody
 public Object getAreaMaterialConfigs(@PathVariable Long componentId) {
   AreaComponentEntity componentEntity =
       (AreaComponentEntity) baseService.getObject(AreaComponentEntity.class, componentId);
   List<AreaMaterialsConfigEntity> materialsConfigEntities =
       componentEntity.getAreaMaterialsConfigEntities();
   //		for(AreaMaterialsConfigEntity materialsConfigEntity : materialsConfigEntities){
   //			MaterialBean bean =
   // materialListManager.getEntityByFNumber(materialsConfigEntity.getFNumber());
   //			if(bean == null){
   //				continue;
   //			}
   //			materialsConfigEntity.setFname(bean.getFname());
   //			materialsConfigEntity.setFmodel(bean.getFmodel());
   //			materialsConfigEntity.setUnit(bean.getUnit());
   //		}
   return materialsConfigEntities;
 }
Esempio n. 6
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;
  }
Esempio n. 7
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/component/remove/{componentId}",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object delComponentEntity(@PathVariable Long componentId) {
    AreaComponentEntity componentEntity =
        (AreaComponentEntity) baseService.getObject(AreaComponentEntity.class, componentId);
    componentEntity.getDoorTemplateEntity().getAreaComponentEntities().remove(componentEntity);
    componentEntity.setDoorTemplateEntity(null);
    baseService.deleteEntity(componentEntity);

    List<AreaComponentEntity> result = new ArrayList<AreaComponentEntity>();
    findComponentTree(result, componentId);
    for (AreaComponentEntity _entity : result) {
      _entity.getDoorTemplateEntity().getAreaComponentEntities().remove(_entity);
      _entity.setDoorTemplateEntity(null);
      baseService.deleteEntity(_entity);
    }

    return componentEntity;
  }