コード例 #1
0
 @RequestMapping(value = "read.do", method = RequestMethod.GET) // 选择
 public @ResponseBody byte[] read(HttpServletRequest request, HttpServletResponse response)
     throws UnsupportedEncodingException {
   String dwxxId = request.getParameter("companyId");
   String year = request.getParameter("year");
   String month = request.getParameter("month");
   List<String[]> ret = fxCpylspHqlyddzlService.getWriteDataList(dwxxId, year, month);
   String retstr = JSONArray.fromObject(ret).toString().replace("null", "\"\"");
   String result = "{\"values\":" + retstr + "}";
   return result.getBytes("utf-8");
 }
コード例 #2
0
 @RequestMapping(value = "save.do", method = RequestMethod.POST) // 保存
 public @ResponseBody byte[] save(HttpServletRequest request, HttpServletResponse response)
     throws UnsupportedEncodingException {
   String dwxxId = request.getParameter("companyId");
   String year = request.getParameter("year");
   String month = request.getParameter("month");
   String data = request.getParameter("data");
   String ret =
       "" + fxCpylspHqlyddzlService.saveDataList(dwxxId, year, month, JSONArray.fromObject(data));
   String result = "{\"result\":\"" + ret + "\"}";
   return result.getBytes("utf-8");
 }
コード例 #3
0
  @RequestMapping(value = "exportbyq.do")
  public @ResponseBody byte[] exportbyq(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    String dwxxId = "";
    String dwxxname = "";
    dwxxId = request.getParameter("companyId");
    if (dwxxId.equals("900000")) {
      dwxxname = "变压器产业";
    } else if (dwxxId.equals("800000")) {
      dwxxname = "线缆产业";
    } else {
      dwxxname = zzyDWXXService.getDwxx(Integer.parseInt(dwxxId)).getName();
    }

    String year = request.getParameter("year");
    String month = request.getParameter("month");
    List<String[]> data = fxCpylspHqlyddzlService.getViewDataListByq(dwxxId, year, month);
    String fileNameAndSheetName = dwxxname;
    fileNameAndSheetName +=
        request.getParameter("year")
            + "年"
            + Integer.parseInt(request.getParameter("month")) / 3
            + "季度后期履约订单质量";
    JygkZzyExcelTemplate template = JygkZzyExcelTemplate.createJygkTemplate("20002");
    HSSFWorkbook workbook = template.getWorkbook();
    HSSFSheet sheet = workbook.getSheetAt(0);

    JygkZzyFormatterHandler formatterChain =
        this.getFormatterChainWithHeader(new Integer[] {}, new Integer[] {1, 2, 3, 4, 5});

    for (int i = 0, ilen = data.size(); i < ilen; ++i) {
      HSSFRow row = sheet.createRow(1 + i);
      for (int j = 0, jlen = data.get(i).length; j < jlen; ++j) {
        HSSFCell cell = row.createCell(j);
        formatterChain.handle(data.get(i)[0], j, template, cell, data.get(i)[j]);
      }
    }

    template.write(response, fileNameAndSheetName + ".xls");

    return "".getBytes("utf-8");
  }