jialh
1 天以前 dd6687b118561100e1677e88a9c2f5842a54c531
service-fee/src/main/java/com/java110/fee/cmd/fee/ReportFeeWriteOrderCmd.java
@@ -7,8 +7,11 @@
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.dict.DictDto;
import com.java110.dto.fee.FeeDetailDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.report.ReportExcelDto;
import com.java110.dto.report.ReportQueryRecord;
import com.java110.fee.smo.impl.FeeDetailInnerServiceSMOImpl;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.dev.IDictV1InnerServiceSMO;
import com.java110.intf.fee.IReportFeeInnerServiceSMO;
@@ -39,6 +42,8 @@
    @Autowired
    private IDictV1InnerServiceSMO dictV1InnerServiceSMOImpl;
    @Autowired
    private FeeDetailInnerServiceSMOImpl feeDetailInnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        Assert.hasKey(reqJson, "communityId", "请求报文中未包含小区编号");
@@ -46,67 +51,37 @@
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
//        int startYear = 2020;
//        CommunityDto communityDto = new CommunityDto();
//        communityDto.setCommunityId(reqJson.getString("communityId"));
//        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
//        FeeQueryParams feeQueryParams = new FeeQueryParams();
//        feeQueryParams.setCommunityId(reqJson.getString("communityId"));
//        feeQueryParams.setStartYear(startYear);
//        int currentYear = java.time.Year.now().getValue();
//        feeQueryParams.setEndYear(currentYear + 2);
//        if(reqJson.containsKey("endYear") && !reqJson.get("endYear").equals("") && reqJson.get("endYear") != null) {
//            currentYear=Integer.parseInt(reqJson.get("endYear")+"");
//            feeQueryParams.setEndYear(Integer.parseInt(reqJson.get("endYear")+"")+2);
//        }
//        int endYear = feeQueryParams.getEndYear();
//        int doYear = endYear - startYear;
//
        ReportQueryRecord reportQueryRecord = new ReportQueryRecord();
        reportQueryRecord.setCommunityId(reqJson.getString("communityId"));
        reportQueryRecord.setQueryStatus("0");
        reportQueryRecord.setOperator("白单流水表");
        List<ReportQueryRecord> reportQueryRecords = reportFeeInnerServiceSMOImpl.queryReport(BeanConvertUtil.beanCovertMap(reportQueryRecord));
        if(reportQueryRecords.size()>0 && !reqJson.containsKey("reload")){
            ResultVo resultVo = new ResultVo(JSONObject.parse(reportQueryRecords.get(reportQueryRecords.size()-1).getReportContent()));
            ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
            context.setResponseEntity(responseEntity);
        }
        else{
            FeeQueryParams feeQueryParams = new FeeQueryParams();
            feeQueryParams.setCommunityId(reqJson.getString("communityId"));
            feeQueryParams.setRow(reqJson.containsKey("row") ? Integer.valueOf(reqJson.getString("row")) : 20);
            feeQueryParams.setPage(reqJson.containsKey("page")? Integer.valueOf(reqJson.get("page").toString()) :1);
            feeQueryParams.setPage(feeQueryParams.getPage() * feeQueryParams.getRow() - feeQueryParams.getRow());
            List<Map> result = reportFeeInnerServiceSMOImpl.repostPaidInFeeByWhiteOrder(feeQueryParams);
            String[][] reportList = new String[feeQueryParams.getRow()][];
            for (int i = 0; i < result.size(); i++) {
                Map map = result.get(i);
                String[] strings = new String[29];
                for (int j = 1; j <= 27; j++) {
                    strings[j-1] = map.get("row"+j).toString();
            String[][] reportList = new String[feeQueryParams.getRow()!=null?feeQueryParams.getRow():100][];
            if (!result.get(0).get("count").toString().equals("0")) {
                for (int i = 0; i < result.size(); i++) {
                    Map map = result.get(i);
                    String[] strings = new String[29];
                    for (int j = 1; j <= 27; j++) {
                        if(map.containsKey("row"+j)){
                            strings[j-1] = map.get("row"+j).toString();
                        }
                    }
                    reportList[i] = strings;
                }
                reportList[i] = strings;
            }
        FeeDetailDto feeDetailDto = new FeeDetailDto();
            feeDetailDto.setCommunityId(reqJson.getString("communityId"));
        int c = feeDetailInnerServiceSMOImpl.queryFeeDetailsCount(feeDetailDto);
            reportQueryRecord.setEndYear("2025");
            reportQueryRecord.setCommunityId(reqJson.getString("communityId"));
            reportQueryRecord.setQueryStatus("0");
            reportQueryRecord.setReportContent(JSONObject.toJSONString(reportList));
            reportQueryRecord.setOperator("白单流水表");
            int i = reportFeeInnerServiceSMOImpl.saveReport(BeanConvertUtil.beanCovertMap(reportQueryRecord));
            ResultVo resultVo = new ResultVo(reportList);
        ResultVo resultVo = new ResultVo(reportList);
        resultVo.setTotal(Integer.parseInt(result.get(0).get("count").toString()));
        resultVo.setRecords((int) (resultVo.getTotal() / feeQueryParams.getRow()));
//            resultVo.setTotal(count);
            ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
            context.setResponseEntity(responseEntity);
        }
//        }
    }
}