chengf
2025-08-25 4fafe2304ab5e3df321808f5120b29baf27c7eab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.java110.fee.cmd.fee;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.dict.DictDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.report.ReportQueryRecord;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.dev.IDictV1InnerServiceSMO;
import com.java110.intf.fee.IReportFeeInnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.FeeQueryParams;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
 
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
@Java110Cmd(serviceCode = "fee.whiteOrderReportFeeCmd")
public class ReportFeeWriteOrderCmd extends Cmd {
 
    @Autowired
    private IReportFeeInnerServiceSMO reportFeeInnerServiceSMOImpl;
 
    @Autowired
    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
 
    @Autowired
    private IDictV1InnerServiceSMO dictV1InnerServiceSMOImpl;
 
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        Assert.hasKey(reqJson, "communityId", "请求报文中未包含小区编号");
    }
 
    @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);
            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();
                }
                reportList[i] = strings;
            }
 
            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);
 
            ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
 
            context.setResponseEntity(responseEntity);
        }
    }
}