Exemplo n.º 1
0
  public void saveOrganization() throws DocumentException {
    String id = getRequestParameter("id");
    Organization organization = null;
    if (!StringUtils.isEmpty(id)) {
      organization = ServiceProvider.getService(OrganizationService.class).findById(id);
    }
    String code = getRequestParameter("code");
    String name = getRequestParameter("name");
    String version = getRequestParameter("version");
    String remark = getRequestParameter("remark");
    String publish = getRequestParameter("publish");

    String codeId = ServiceProvider.getService(OrganizationService.class).findNextCodeId(version);

    if (organization == null) {
      organization = new Organization();
    }
    organization.setCodeId(codeId);
    organization.setCode(code);
    organization.setName(name);
    organization.setRemarks(remark);
    organization.setVersion(version);
    organization.setPublish(publish);
    ServiceProvider.getService(OrganizationService.class).save(organization);
  }
Exemplo n.º 2
0
 public void getAllOrganization() throws DocumentException, IOException {
   String version = getRequestParameter("version");
   List<Organization> list = null;
   if (StringUtils.isNotEmpty(version)) {
     list = ServiceProvider.getService(OrganizationService.class).findAllByVersion(version);
   } else {
     list = ServiceProvider.getService(OrganizationService.class).findByPublish();
   }
   renderJson(list);
 }
Exemplo n.º 3
0
  /**
   * 显示view页面
   *
   * @throws Exception
   */
  public String showView() throws Exception {
    String id = ServletActionContext.getRequest().getParameter("id");
    assetTask = ServiceProvider.getService(AssetTaskService.class).findById(id);

    List<Attach> attachList =
        ServiceProvider.getService(AssetTaskService.class).findAttachByGroupId(id);

    request.setAttribute("assetTask", assetTask);
    request.setAttribute("attachList", attachList);

    return "success";
  }
Exemplo n.º 4
0
 public void checkUniqueness() throws DocumentException, IOException {
   String id = getRequestParameter("id");
   String code = getRequestParameter("code");
   String name = getRequestParameter("name");
   String version = getRequestParameter("version");
   boolean stats =
       ServiceProvider.getService(OrganizationService.class).isUnique(id, code, name, version);
   if (!stats) {
     renderJson("false");
   } else {
     renderJson("true");
   }
 }
Exemplo n.º 5
0
  public void uploadAttach() throws DocumentException {
    System.out.println("upload start*************");
    String id = getRequestParameter("id");
    if (id.isEmpty()) return;

    Properties p = PropertiesUtil.loadProperties("config.properties");
    String saveDir = p.getProperty("attachPath");

    File savePath = new File(saveDir);
    if (!savePath.exists()) {
      savePath.mkdirs();
    }

    String saveFileName =
        saveDir
            + File.separator
            + sdf.format(new Date())
            + "-"
            + (new Random().nextInt(10000))
            + ".dat";
    File newFile = new File(saveFileName);
    uploadify.renameTo(newFile); // 将文件移到制定位置并且改名

    String fileName = uploadifyFileName.substring(0, uploadifyFileName.lastIndexOf("."));
    String fileExt =
        uploadifyFileName.substring(
            uploadifyFileName.lastIndexOf(".") + 1, uploadifyFileName.length());
    Attach attach = new Attach();
    attach.setFilename(fileName);
    attach.setFileextname(fileExt);
    attach.setFilesize(newFile.length());
    attach.setPath(saveDir);
    // attach.setUploader("");		//上传人
    attach.setUploaddate(sdfToDate.format(new Date()));
    attach.setRemoved(0l);
    // attach.setOperator("");			//操作人
    attach.setSavefilename(saveFileName);
    // attach.setOperateTime(sdf.format(new Date()));		//数据库中设计的字段是number类型的
    attach.setAppname("AssetWeb");
    // attach.setUploaderLoginName("");		//登陆的人
    //		attach.setStatus("upload");

    attach.setGroupid(id);

    ServiceProvider.getService(AssetTaskService.class).saveAttach(attach);
    System.out.println("upload end*************");
  }
Exemplo n.º 6
0
  public void downloadAttach() throws DocumentException {
    String id = getRequestParameter("id");
    if (id.isEmpty()) return;
    Attach attach =
        ServiceProvider.getService(AssetTaskService.class).findAttachById(Long.valueOf(id));
    if (attach == null) return;

    String filename = attach.getFilename() + "." + attach.getFileextname();
    InputStream is = null;
    try {
      is = new FileInputStream(attach.getSavefilename());

      int len = 0;
      byte[] buffers = new byte[1024];
      response.setCharacterEncoding("utf-8");
      response.reset();
      response.setContentType("application/x-msdownload");

      response.addHeader(
          "Content-Disposition",
          "attachment;filename=" + new String(filename.getBytes("gb2312"), "ISO8859-1"));
      OutputStream os = response.getOutputStream();
      // 把文件内容通过输出流打印到页面上供下载
      while ((len = is.read(buffers)) != -1) {
        os.write(buffers, 0, len);
        os.flush();
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (is != null) is.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 7
0
 public String getCheckInfoAndAsset() throws IOException, DocumentException {
   String id = request.getParameter("id");
   int startIndex = NumberUtils.toInt(getRequestParameter("jtStartIndex"), 0);
   int pageSize = NumberUtils.toInt(getRequestParameter("jtPageSize"), 10);
   List<Object[]> list =
       ServiceProvider.getService(AssetTaskService.class)
           .findCheckInfoAndAssetByTaskId(id, startIndex, pageSize);
   List<Map<String, String>> result = new ArrayList<Map<String, String>>();
   for (Object[] obj : list) {
     Map map = new HashMap();
     map.put("assetNo", obj[0]);
     map.put("assetName", obj[1]);
     map.put("line", obj[2]);
     map.put("station", obj[3]);
     map.put("beginUseDate", obj[4]);
     map.put("checkInfo", obj[5]);
     map.put("checkDate", obj[6]);
     map.put("checkPerson", obj[7]);
     result.add(map);
   }
   renderJson(result, list.size());
   return Action.NONE;
 }
Exemplo n.º 8
0
  /**
   * 显示list页面,普通权限,无法新增任务
   *
   * @throws Exception
   */
  public void inquery() throws Exception {

    request.setAttribute("today", sdfToDate.format(new Date()));

    String pageNo = request.getParameter("pageNo");
    if (StringUtils.isEmpty(pageNo)) {
      pageNo = "0";
    }

    Map<String, String> mapFilter = createFilterMap();

    String start1 = getRequestParameter("start1");
    String start2 = getRequestParameter("start2");

    int startIndex = NumberUtils.toInt(getRequestParameter("jtStartIndex"), 0);
    int pageSize = NumberUtils.toInt(getRequestParameter("jtPageSize"), 10);
    Map<String, String> sort = createSortMap();
    Pagination<AssetTask> page =
        ServiceProvider.getService(AssetTaskService.class)
            .findBy(mapFilter, sort, startIndex, pageSize);

    JsonConfig jsonConfig = basicJsonCfg.copy();
    renderJson(page.getResult(), page.getTotalCount(), jsonConfig);
  }
Exemplo n.º 9
0
 public void deleteAttach() throws NumberFormatException, DocumentException {
   String id = getRequestParameter("id");
   ServiceProvider.getService(AssetTaskService.class).deleteAttachById(Long.valueOf(id));
 }
Exemplo n.º 10
0
 public void publish() throws DocumentException {
   String version = getRequestParameter("version");
   ServiceProvider.getService(OrganizationService.class).publish(version);
 }
Exemplo n.º 11
0
 public void copyCurrentVersion() throws DocumentException, IOException {
   String version = getRequestParameter("version");
   String newVersion =
       ServiceProvider.getService(OrganizationService.class).copyCurrentVersion(version);
   renderJson(newVersion);
 }
Exemplo n.º 12
0
 public void deleteOrganization() throws DocumentException {
   String id = getRequestParameter("id");
   ServiceProvider.getService(OrganizationService.class).deleteById(id);
 }
Exemplo n.º 13
0
 public void findAllVersion() throws DocumentException, IOException {
   List<String> versions = ServiceProvider.getService(OrganizationService.class).showVersion();
   renderJson(versions);
 }