HisFundjourAction.java 3.72 KB
package com.cjs.cms.action.report;

import java.io.File;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cjs.cms.biz.report.FundJourBiz;
import com.cjs.cms.biz.report.ReportBiz;
import com.cjs.cms.dao.report.FundJourDao;
import com.cjs.cms.dao.report.HisFundjourDao;
import com.cjs.cms.util.lang.JsonUtil;
import com.cjs.cms.util.lang.PageUtils;

/**
 * 
 * 出入金汇总
 * 
 * @author kongmingke
 *
 */
@RestController
@RequestMapping("/report/hisFundjour")
public class HisFundjourAction {

    @Autowired
    private HisFundjourDao hisFundJour;
    @Autowired
    private ReportBiz      reportBiz;
    @Autowired
    private FundJourBiz    jourBiz;

    @Autowired
    private FundJourDao    fundJour;

    @RequestMapping("/search")
    public String search(@RequestParam Map<String, Object> params) {
        PageUtils.processOralcePage(params);
        reportBiz.formatDate(params);
        return JsonUtil.toPageJson(hisFundJour.queryFundSum(params),
            hisFundJour.queryFundSumTotal(params), hisFundJour.queryFundAmount(params));
    }

    @RequestMapping("/export")
    public ResponseEntity<byte[]> export(@RequestParam Map<String, Object> params,
                                         HttpServletRequest request) throws Exception {
        reportBiz.formatDate(params);
        params.put("rows", 999999);
        PageUtils.processOralcePage(params);
        File targetFile = reportBiz.exportHisFundJour(params);
        HttpHeaders head = new HttpHeaders();
        head.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        // 下载的文件名
        head.setContentDispositionFormData("attachment",
            new String(targetFile.getName().getBytes("UTF-8"), "ISO8859-1"));
        return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(targetFile), head,
            HttpStatus.CREATED);
    }

    /**
     * 用户资金流水
     */
    @RequestMapping("/queryAccount")
    public String queryAccount(@RequestParam Map<String, Object> params) {
        PageUtils.processOralcePage(params);
        if (params.get("currDate") != null && !"".equals(params.get("currDate") + "")) {
            params.put("currDate", reportBiz.formatDate(params.get("currDate") + ""));
        }
        return JsonUtil.toPageJson(jourBiz.queryAccount(params),
            fundJour.queryAccountTotal(params));
    }

    @RequestMapping("/exportAccount")
    public ResponseEntity<byte[]> exportAccount(@RequestParam Map<String, Object> params,
                                                HttpServletRequest request) throws Exception {
        reportBiz.formatDate(params);
        params.put("rows", 999999);
        if (params.get("currDate") != null && !"".equals(params.get("currDate") + "")) {
            params.put("currDate", reportBiz.formatDate(params.get("currDate") + ""));
        }
        File targetFile = jourBiz.exportFundJour(params);
        HttpHeaders head = new HttpHeaders();
        head.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        // 下载的文件名
        head.setContentDispositionFormData("attachment",
            new String(targetFile.getName().getBytes("UTF-8"), "ISO8859-1"));
        return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(targetFile), head,
            HttpStatus.CREATED);
    }
}