java110
2022-04-25 6143e4184fb40e0d40f2d69fd08a7a38ae6a9ca2
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
package com.java110.report.bmo.reportOwnerPayFee.impl;
 
import com.java110.dto.fee.FeeDto;
import com.java110.dto.reportOwnerPayFee.ReportOwnerPayFeeDto;
import com.java110.intf.report.IReportOwnerPayFeeInnerServiceSMO;
import com.java110.report.bmo.reportOwnerPayFee.IGetReportOwnerPayFeeBMO;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
 
@Service("getReportOwnerPayFeeBMOImpl")
public class GetReportOwnerPayFeeBMOImpl implements IGetReportOwnerPayFeeBMO {
 
    @Autowired
    private IReportOwnerPayFeeInnerServiceSMO reportOwnerPayFeeInnerServiceSMOImpl;
 
    /**
     * @param reportOwnerPayFeeDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> get(ReportOwnerPayFeeDto reportOwnerPayFeeDto) {
        if(!StringUtil.isEmpty(reportOwnerPayFeeDto.getPfYear())) {
            reportOwnerPayFeeDto.setFeeEndTime(reportOwnerPayFeeDto.getPfYear()+"-01-01");
        }else{
            Calendar calendar =Calendar.getInstance();
            reportOwnerPayFeeDto.setFeeEndTime(calendar.get(Calendar.YEAR)+"-01-01");
        }
        int count = reportOwnerPayFeeInnerServiceSMOImpl.queryReportOwnerPayFeesCount(reportOwnerPayFeeDto);
 
        List<ReportOwnerPayFeeDto> reportOwnerPayFeeDtos = null;
        if (count > 0) {
            reportOwnerPayFeeDtos = reportOwnerPayFeeInnerServiceSMOImpl.queryReportOwnerPayFees(reportOwnerPayFeeDto);
            refreshOwnerPayFeeDto(reportOwnerPayFeeDtos, reportOwnerPayFeeDto);
        } else {
            reportOwnerPayFeeDtos = new ArrayList<>();
        }
 
        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportOwnerPayFeeDto.getRow()), count, reportOwnerPayFeeDtos);
 
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
 
        return responseEntity;
    }
 
    /**
     * @param reportOwnerPayFeeDtos
     */
    private void refreshOwnerPayFeeDto(List<ReportOwnerPayFeeDto> reportOwnerPayFeeDtos, ReportOwnerPayFeeDto tmpReportOwnerPayFeeDto) {
        if (reportOwnerPayFeeDtos == null || reportOwnerPayFeeDtos.size() < 1) {
            return;
        }
        List<String> feeIds = new ArrayList<>();
        for (ReportOwnerPayFeeDto reportOwnerPayFeeDto : reportOwnerPayFeeDtos) {
            if (!StringUtil.isEmpty(reportOwnerPayFeeDto.getImportFeeName())) {
                reportOwnerPayFeeDto.setFeeName(reportOwnerPayFeeDto.getImportFeeName());
            }
            if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(reportOwnerPayFeeDto.getPayerObjType())) {
                reportOwnerPayFeeDto.setObjName(reportOwnerPayFeeDto.getRoomName());
            } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(reportOwnerPayFeeDto.getPayerObjType())) {
                reportOwnerPayFeeDto.setObjName(reportOwnerPayFeeDto.getCarNum());
            } else if (FeeDto.PAYER_OBJ_TYPE_CONTRACT.equals(reportOwnerPayFeeDto.getPayerObjType())) {
                reportOwnerPayFeeDto.setObjName(reportOwnerPayFeeDto.getContractCode());
            }
            feeIds.add(reportOwnerPayFeeDto.getFeeId());
        }
 
        ReportOwnerPayFeeDto reportOwnerPayFeeDto = new ReportOwnerPayFeeDto();
        reportOwnerPayFeeDto.setFeeIds(feeIds.toArray(new String[feeIds.size()]));
        reportOwnerPayFeeDto.setPfYear(tmpReportOwnerPayFeeDto.getPfYear());
        reportOwnerPayFeeDto.setConfigId(tmpReportOwnerPayFeeDto.getConfigId());
 
        if (StringUtil.isEmpty(reportOwnerPayFeeDto.getPfYear())) {
            reportOwnerPayFeeDto.setPfYear(DateUtil.getYear() + "");
        }
        List<ReportOwnerPayFeeDto> tmpReportOwnerPayFeeDtos
                = reportOwnerPayFeeInnerServiceSMOImpl.queryReportOwnerMonthPayFees(reportOwnerPayFeeDto);
 
 
        List<ReportOwnerPayFeeDto> tmoNewReportOwnerPayFeeDtos = null;
 
        for (ReportOwnerPayFeeDto oldReportOwnerPayFeeDto : reportOwnerPayFeeDtos) {
            tmoNewReportOwnerPayFeeDtos = new ArrayList<>();
            for (ReportOwnerPayFeeDto newReportOwnerPayFeeDto : tmpReportOwnerPayFeeDtos) {
                if (oldReportOwnerPayFeeDto.getFeeId().equals(newReportOwnerPayFeeDto.getFeeId())) {
                    tmoNewReportOwnerPayFeeDtos.add(newReportOwnerPayFeeDto);
                }
            }
            oldReportOwnerPayFeeDto.setReportOwnerPayFeeDtos(tmoNewReportOwnerPayFeeDtos);
        }
 
 
    }
 
}