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.intf.community.ICommunityInnerServiceSMO;
|
import com.java110.intf.dev.IDictV1InnerServiceSMO;
|
import com.java110.intf.fee.IReportFeeInnerServiceSMO;
|
import com.java110.po.fee.PayFeePo;
|
import com.java110.utils.exception.CmdException;
|
import com.java110.utils.util.Assert;
|
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.*;
|
|
@Java110Cmd(serviceCode = "fee.reportFeeCmd")
|
public class ReportFeeCmd 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);
|
int endYear = feeQueryParams.getEndYear();
|
|
List<Map> result = reportFeeInnerServiceSMOImpl.repostPaidInFee(feeQueryParams);
|
List<Map> resultTwo = reportFeeInnerServiceSMOImpl.repostPaidInFeeTwo(feeQueryParams);
|
DictDto dictDto = new DictDto();
|
dictDto.setTableName("pay_fee_config");
|
dictDto.setTableColumns("fee_type_cd");
|
List<DictDto> dictDtos = dictV1InnerServiceSMOImpl.queryDicts(dictDto);
|
int doYear = endYear - startYear;
|
List<List<FeeDto>> reportFeeDtoLists = new LinkedList<>();
|
reportFeeDtoLists.add(new LinkedList<FeeDto>());
|
reportFeeDtoLists.add(new LinkedList<FeeDto>());
|
reportFeeDtoLists.add(new LinkedList<FeeDto>());
|
reportFeeDtoLists.add(new LinkedList<FeeDto>());
|
int ind = 1;
|
for (DictDto dictDto1 : dictDtos) {//类型
|
List<FeeDto> reportFeeDtos = new LinkedList<>();
|
FeeDto feeDto = new FeeDto();
|
LinkedList<FeeDto> feeDtos = new LinkedList<>();
|
reportFeeDtoLists.add(feeDtos);
|
for (int i = startYear; i <= endYear; i++) {//年份
|
double[] doubles = new double[doYear+12+1+5];
|
feeDto = new FeeDto();
|
//0~5
|
if(resultTwo != null){
|
for (Map map : resultTwo) {
|
if(map.isEmpty()){
|
break;
|
}
|
else if (map.get("统计周期")!=null&&map.get("统计周期").equals(i)&&map.get("费用类型编码").equals(dictDto1.getStatusCd())){
|
feeDto.setCurYear((i)+"");
|
feeDto.setFeeTypeCdName(map.get("费用类型")+"");
|
doubles[0] = map.get("当年应缴总金额") == null ? 0 : (double) map.get("当年应缴总金额");
|
doubles[1] = map.get("每月费用(合计/月份数)") == null ? 0 : (double) map.get("每月费用(合计/月份数)");
|
doubles[2] = map.get("每月费用月份数") == null ? 0 : ((Long) map.get("每月费用月份数")).intValue();
|
}
|
}
|
}
|
|
if(result != null){
|
for (Map map : result) {//类型+年份
|
if(map.isEmpty()){
|
break;
|
}
|
//5 ~ 25
|
else if (map.get("统计周期")!=null&&map.get("统计周期").equals(i)&&map.get("费用类型编码").equals(dictDto1.getStatusCd())){
|
|
for (int j = startYear ; j <= endYear ; j++) {// 5~(endYear - startYear + 5) = 5 ~ 13
|
if(map.get((j)+"年收费金额(元)")!=null){
|
feeDto.setCurYear((i)+"");
|
feeDto.setFeeTypeCdName(map.get("费用类型名称") == null ? null : map.get("费用类型名称")+"");
|
doubles[j-startYear+5] = ((BigDecimal)map.get((j)+"年收费金额(元)")).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
}
|
for (int x = 1 ;x <= 12 ;x++ ){// (endYear - startYear + 6) ~ (endYear - startYear + 6 + 12) = 13 ~ 25
|
if (map.get((currentYear)+"年"+x+"月收费金额(元)")!=null){
|
feeDto.setCurYear((i)+"");
|
feeDto.setFeeTypeCdName(map.get("费用类型名称") == null ? null : map.get("费用类型名称")+"");
|
doubles[endYear - startYear + x +5] = ((BigDecimal)map.get((currentYear)+"年"+x+"月收费金额(元)")).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
}
|
}
|
}
|
}
|
}
|
}
|
if(feeDto.getCurYear() != null){
|
feeDto.setReport(doubles);
|
reportFeeDtos.add(feeDto);
|
}
|
}
|
if (ind == 3 || ind == 7){
|
reportFeeDtoLists.add(new LinkedList<>());
|
}
|
reportFeeDtoLists.add(reportFeeDtos);
|
if(ind == 1 || ind == 2){
|
reportFeeDtoLists.add(new LinkedList<>());
|
}
|
ind ++;
|
}
|
int[] arr = new int[endYear - startYear + 1];
|
for (int i = startYear; i <= endYear; i++) {
|
arr[i-startYear] = i;
|
}
|
FeeDto feeDto = new FeeDto();
|
feeDto.setRepostList(reportFeeDtoLists);
|
feeDto.setYearArr(arr);
|
|
|
ResultVo resultVo = new ResultVo(feeDto);
|
|
ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
|
|
context.setResponseEntity(responseEntity);
|
}
|
}
|