Package org.jeecgframework.core.common.model.json

Examples of org.jeecgframework.core.common.model.json.AjaxJson


   * @return
   */
  @RequestMapping(params = "parserXml")
  @ResponseBody
  public AjaxJson parserXml(HttpServletRequest request, HttpServletResponse response) {
    AjaxJson json = new AjaxJson();
    String fileName = null;
    UploadFile uploadFile = new UploadFile(request);
    String ctxPath = request.getSession().getServletContext().getRealPath("");
    File file = new File(ctxPath);
    if (!file.exists()) {
      file.mkdir();// 创建文件根目录
    }
    MultipartHttpServletRequest multipartRequest = uploadFile.getMultipartRequest();
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
      MultipartFile mf = entity.getValue();// 获取上传文件对象
      fileName = mf.getOriginalFilename();// 获取文件名
      String savePath = file.getPath() + "/" + fileName;
      File savefile = new File(savePath);
      try {
        FileCopyUtils.copy(mf.getBytes(), savefile);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    systemService.parserXml(ctxPath + "/" + fileName);
    json.setSuccess(true);
    return json;
  }
View Full Code Here


   * @return
   */
  @RequestMapping(params = "delObjFile")
  @ResponseBody
  public AjaxJson delObjFile(HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    String fileKey = oConvertUtils.getString(request.getParameter("fileKey"));// 文件ID
    TSAttachment attachment = systemService.getEntity(TSAttachment.class,fileKey);
    String subclassname = attachment.getSubclassname(); // 子类类名
    Object objfile = systemService.getEntity(MyClassLoader.getClassByScn(subclassname), attachment.getId());// 子类对象
    message = "" + attachment.getAttachmenttitle() + "删除成功";
    systemService.delete(objfile);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
   
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "doDel")
  @ResponseBody
  public AjaxJson doDel(CgreportConfigHeadEntity cgreportConfigHead, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    cgreportConfigHead = systemService.getEntity(CgreportConfigHeadEntity.class, cgreportConfigHead.getId());
    message = "动态报表配置抬头删除成功";
    try{
      cgreportConfigHeadService.delete(cgreportConfigHead);
      systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    }catch(Exception e){
      e.printStackTrace();
      message = "动态报表配置抬头删除失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @return
   */
   @RequestMapping(params = "doBatchDel")
  @ResponseBody
  public AjaxJson doBatchDel(String ids,HttpServletRequest request){
    AjaxJson j = new AjaxJson();
    message = "动态报表配置抬头删除成功";
    try{
      for(String id:ids.split(",")){
        CgreportConfigHeadEntity cgreportConfigHead = systemService.getEntity(CgreportConfigHeadEntity.class, id);
        cgreportConfigHeadService.delete(cgreportConfigHead);
        systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
      }
    }catch(Exception e){
      e.printStackTrace();
      message = "动态报表配置抬头删除失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

   */
  @RequestMapping(params = "doAdd")
  @ResponseBody
  public AjaxJson doAdd(CgreportConfigHeadEntity cgreportConfigHead,CgreportConfigHeadPage cgreportConfigHeadPage, HttpServletRequest request) {
    List<CgreportConfigItemEntity> cgreportConfigItemList =  cgreportConfigHeadPage.getCgreportConfigItemList();
    AjaxJson j = new AjaxJson();
    message = "添加成功";
    try{
      cgreportConfigHeadService.addMain(cgreportConfigHead, cgreportConfigItemList);
      systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    }catch(Exception e){
      e.printStackTrace();
      message = "动态报表配置抬头添加失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

   */
  @RequestMapping(params = "doUpdate")
  @ResponseBody
  public AjaxJson doUpdate(CgreportConfigHeadEntity cgreportConfigHead,CgreportConfigHeadPage cgreportConfigHeadPage, HttpServletRequest request) {
    List<CgreportConfigItemEntity> cgreportConfigItemList =  cgreportConfigHeadPage.getCgreportConfigItemList();
    AjaxJson j = new AjaxJson();
    message = "更新成功";
    try{
      cgreportConfigHeadService.updateMain(cgreportConfigHead, cgreportConfigItemList);
      systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }catch(Exception e){
      e.printStackTrace();
      message = "更新动态报表配置抬头失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

  @RequestMapping(params = "transEditor")
  @ResponseBody
  public AjaxJson transEditor(HttpServletRequest request, String id)
      throws Exception {
    AjaxJson j = new AjaxJson();
    String ids[] = id.split(",");
    String no = "";
    String yes = "";
    for (int i = 0; i < ids.length; i++) {
      if (StringUtil.isNotEmpty(ids[i])) {
        List<CgFormHeadEntity> cffList = cgFormFieldService
            .findByProperty(CgFormHeadEntity.class, "tableName",
                ids[i]);
        if (cffList.size() > 0) {
          if (no != "")
            no += ",";
          no += ids[i];
          continue;
        }
        List<Columnt> list = new JeecgReadTable()
            .readOriginalTableColumn(ids[i]);
        CgFormHeadEntity cgFormHead = new CgFormHeadEntity();
        cgFormHead.setJformType(1);
        cgFormHead.setIsCheckbox("Y");
        cgFormHead.setIsDbSynch("Y");
        cgFormHead.setIsTree("N");
        cgFormHead.setQuerymode("group");
        cgFormHead.setTableName(ids[i].toLowerCase());
        cgFormHead.setIsPagination("Y");
        cgFormHead.setContent(ids[i]);
        cgFormHead.setJformVersion("1");
        List<CgFormFieldEntity> columnsList = new ArrayList<CgFormFieldEntity>();
        for (int k = 0; k < list.size(); k++) {
          Columnt columnt = list.get(k);
          String fieldName = columnt.getFieldDbName();
          CgFormFieldEntity cgFormField = new CgFormFieldEntity();
          cgFormField.setFieldName(columnt.getFieldDbName()
              .toLowerCase());
          if (StringUtil.isNotEmpty(columnt.getFiledComment()))
            cgFormField.setContent(columnt.getFiledComment());
          else
            cgFormField.setContent(columnt.getFieldName());
          cgFormField.setIsKey("N");
          cgFormField.setIsShow("Y");
          cgFormField.setIsShowList("Y");
          cgFormField.setOrderNum(k + 2);
          cgFormField.setQueryMode("group");
          cgFormField.setLength(0);
          cgFormField.setFieldLength(120);
          cgFormField.setPointLength(0);
          cgFormField.setShowType("text");
          cgFormField.setIsNull(columnt.getNullable());
          if("id".equalsIgnoreCase(fieldName)){
            String[] pkTypeArr = {"java.lang.Integer","java.lang.Long"};
            String idFiledType = columnt.getFieldType();
            if(Arrays.asList(pkTypeArr).contains(idFiledType)){
              //如果主键是数字类型,则设置为自增长
              cgFormHead.setJformPkType("NATIVE");
            }else{
              //否则设置为UUID
              cgFormHead.setJformPkType("UUID");
            }
            cgFormField.setIsKey("Y");
            cgFormField.setIsShow("N");
            cgFormField.setIsShowList("N");
          }
          if ("java.lang.Integer".equalsIgnoreCase(columnt.getFieldType())){
            cgFormField.setType(DataBaseConst.INT);
          }else if ("java.lang.Long".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.INT);
          } else if ("java.util.Date".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.DATE);
            cgFormField.setShowType("date");
          } else if ("java.lang.Double".equalsIgnoreCase(columnt.getFieldType())
              ||"java.lang.Float".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.DOUBLE);
          } else if ("java.math.BigDecimal".equalsIgnoreCase(columnt.getFieldType())) {
            cgFormField.setType(DataBaseConst.BIGDECIMAL);
          } else if (columnt.getFieldType().contains("blob")) {
            cgFormField.setType(DataBaseConst.BLOB);
            columnt.setCharmaxLength(null);
          } else {
            cgFormField.setType(DataBaseConst.STRING);
          }
          if (StringUtil.isNotEmpty(columnt.getCharmaxLength())) {
            if (Long.valueOf(columnt.getCharmaxLength()) >= 3000) {
              cgFormField.setType(DataBaseConst.TEXT);
              cgFormField.setShowType(DataBaseConst.TEXTAREA);
              try{//有可能长度超出int的长度
                cgFormField.setLength(Integer.valueOf(columnt.getCharmaxLength()));
              }catch(Exception e){}
            } else {
              cgFormField.setLength(Integer.valueOf(columnt
                  .getCharmaxLength()));
            }
          } else {
            if (StringUtil.isNotEmpty(columnt.getPrecision())) {
              cgFormField.setLength(Integer.valueOf(columnt
                  .getPrecision()));
            }
            //update-begin--Author:zhangdaihao  Date:20140212 for:[001]oracle下number类型,数据库表导出表单,默认长度为0同步失败
            else{
              if(cgFormField.getType().equals(DataBaseConst.INT)){
                cgFormField.setLength(10);
              }
            }
            //update-end--Author:zhangdaihao  Date:20140212 for:[001]oracle下number类型,数据库表导出表单,默认长度为0同步失败
            if (StringUtil.isNotEmpty(columnt.getScale()))
              cgFormField.setPointLength(Integer.valueOf(columnt
                  .getScale()));

          }
          columnsList.add(cgFormField);
        }
        cgFormHead.setColumns(columnsList);
        cgFormFieldService.saveTable(cgFormHead, "");
        if (yes != "")
          yes += ",";
        yes += ids[i];
      }
    }
    Map<String, String> map = new HashMap<String, String>();
    map.put("no", no);
    map.put("yes", yes);
    j.setObj(map);
    return j;
  }
View Full Code Here

   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(String configId,String id,
      HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    String jversion = cgFormFieldService.getCgFormVersionByTableName(configId);
    String table = (String) configService.queryConfigs(configId,jversion).get(CgAutoListConstant.TABLENAME);
    cgTableService.delete(table, id);
    String message = "删除成功";
    systemService.addLog(message, Globals.Log_Type_DEL,
        Globals.Log_Leavel_INFO);
    j.setMsg(message);
    return j;
  }
View Full Code Here

   */
  @RequestMapping(params = "delBatch")
  @ResponseBody
  public AjaxJson delBatch(String configId,String ids,
      HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    String jversion = cgFormFieldService.getCgFormVersionByTableName(configId);
    String table = (String) configService.queryConfigs(configId,jversion).get(CgAutoListConstant.TABLENAME);
    String message = "删除成功";
    try {
      String[] id = ids.split(",");
      cgTableService.deleteBatch(table, id);
    } catch (Exception e) {
      message = e.getMessage();
    }
    systemService.addLog(message, Globals.Log_Type_DEL,
        Globals.Log_Leavel_INFO);
    j.setMsg(message);
    return j;
  }
View Full Code Here

  @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  @ResponseBody
  @SuppressWarnings("all")
  public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
    String message = "上传成功";
    AjaxJson j = new AjaxJson();
    String configId = request.getParameter("tableName");
    String jversion = cgFormFieldService.getCgFormVersionByTableName(configId);
    Map<String, Object> configs = configService.queryConfigs(configId,jversion);
    //数据库中版本号
    String version = (String)configs.get(CgAutoListConstant.CONFIG_VERSION);
    List<CgFormFieldEntity> lists = (List<CgFormFieldEntity>) configs.get(CgAutoListConstant.FILEDS);
   
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
      MultipartFile file = entity.getValue();// 获取上传文件对象
      //上传文件的版本号
      String docVersion = getDocVersion(file.getOriginalFilename());
      if (docVersion.equals(version)) {
        List<Map<String, Object>> listDate;
        try {
          //读取excel模版数据
          listDate = (List<Map<String, Object>>) ExcelTempletService.importExcelByIs(file.getInputStream(), lists);
          if (listDate==null) {
            message = "识别模版数据错误";
            logger.error(message);
          }else{
            for (Map<String, Object> map : listDate) {
              map.put("id", UUIDGenerator.generate());
              int num = dataBaseService.insertTable(configId, map);
            }
            message = "文件导入成功!";
          }
        } catch (IOException e) {
          message = "文件导入失败!";
          logger.error(ExceptionUtil.getExceptionMessage(e));
        }
      }else{
        message = "模版文件版本和表达不匹配,请重新下载模版";
        logger.error(message);
      }
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

TOP

Related Classes of org.jeecgframework.core.common.model.json.AjaxJson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.