| | |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.entity.component.ComponentValidateResult; |
| | | import com.java110.dto.system.ComponentValidateResult; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.DateUtil; |
| | |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName AssetImportSmoImpl |
| | |
| | | public static final String REPORT_YEAR_COLLECTION = "reportYearCollection"; |
| | | public static final String REPORT_LIST_OWE_FEE = "listOweFee"; |
| | | public static final String REPORT_REPAIR_DETAIL = "reportRepairDetail"; |
| | | public static final String REPORT_PREPAYMENT_DETAIL = "reportPrePaymentDetail"; |
| | | public static final String REPORT_COLLECT_FEES = "reportCollectFees"; |
| | | public static final String REPORT_PAY_FEE_MANAGE = "reportPayFeeManage"; |
| | | public static final String REPORT_QUESTION_ANSWER_DETAIL = "reportQuestionAnswerDetail"; |
| | | public static final String REPORT_PRE_PAYMENT_FEE = "reportPrePaymentFee"; |
| | |
| | | public ResponseEntity<Object> exportExcelData(IPageData pd) throws Exception { |
| | | |
| | | ComponentValidateResult result = this.validateStoreStaffCommunityRelationship(pd, restTemplate); |
| | | Map pdHeaders = pd.getHeaders(); |
| | | if (!StringUtil.isEmpty(result.getStoreId())) { |
| | | pdHeaders.remove("store-id"); |
| | | pdHeaders.put("store-id", result.getStoreId()); |
| | | } |
| | | if (!StringUtil.isEmpty(result.getLoginUserId())) { |
| | | pdHeaders.remove("user-id"); |
| | | pdHeaders.remove("user_id"); |
| | | pdHeaders.put("user-id", result.getUserId()); |
| | | pdHeaders.put("user_id", result.getUserId()); |
| | | pdHeaders.put("login-user-id", result.getLoginUserId()); |
| | | } |
| | | |
| | | Assert.hasKeyAndValue(JSONObject.parseObject(pd.getReqData()), "communityId", "请求中未包含小区"); |
| | | Assert.hasKeyAndValue(JSONObject.parseObject(pd.getReqData()), "pagePath", "请求中未包含页面"); |
| | | |
| | | Workbook workbook = null; //工作簿 |
| | | SXSSFWorkbook workbook = null; //工作簿 |
| | | String userId = ""; |
| | | //工作表 |
| | | workbook = new XSSFWorkbook(); |
| | | workbook = new SXSSFWorkbook(); |
| | | workbook.setCompressTempFiles(false); |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | String pagePath = reqJson.getString("pagePath"); |
| | | |
| | |
| | | break; |
| | | case REPORT_REPAIR_DETAIL: |
| | | reportRepairDetail(pd, result, workbook); |
| | | break; |
| | | case REPORT_PREPAYMENT_DETAIL: |
| | | reportPrepaymentDetail(pd, result, workbook); |
| | | break; |
| | | case REPORT_COLLECT_FEES: |
| | | reportCollectFees(pd, result, workbook); |
| | | break; |
| | | case REPORT_PAY_FEE_MANAGE: |
| | | reportPayFeeManage(pd, result, workbook); |
| | |
| | | } |
| | | } |
| | | |
| | | private void reportPrepaymentDetail(IPageData pd, ComponentValidateResult result, Workbook workbook) { |
| | | Sheet sheet = workbook.createSheet("账单明细表"); |
| | | Row row = sheet.createRow(0); |
| | | row.createCell(0).setCellValue("报表ID"); |
| | | row.createCell(1).setCellValue("付费对象"); |
| | | row.createCell(2).setCellValue("业主"); |
| | | row.createCell(3).setCellValue("费用项"); |
| | | row.createCell(4).setCellValue("费用类型"); |
| | | row.createCell(5).setCellValue("费用状态"); |
| | | row.createCell(6).setCellValue("支付方式"); |
| | | row.createCell(7).setCellValue("费用开始时间"); |
| | | row.createCell(8).setCellValue("费用结束时间"); |
| | | row.createCell(9).setCellValue("缴费时间"); |
| | | row.createCell(10).setCellValue("应缴金额(元)"); |
| | | row.createCell(11).setCellValue("应收金额(元)"); |
| | | row.createCell(12).setCellValue("实收金额(元)"); |
| | | row.createCell(13).setCellValue("欠费金额(元)"); |
| | | row.createCell(14).setCellValue("优惠金额(元)"); |
| | | row.createCell(15).setCellValue("减免金额(元)"); |
| | | row.createCell(16).setCellValue("赠送金额(元)"); |
| | | row.createCell(17).setCellValue("滞纳金(元)"); |
| | | row.createCell(18).setCellValue("空置房打折(元)"); |
| | | row.createCell(19).setCellValue("空置房减免(元)"); |
| | | row.createCell(20).setCellValue("面积(平方米)"); |
| | | |
| | | //查询预付期缴费明细 |
| | | JSONArray prepayments = this.getReportPrepaymentDetail(pd, result); |
| | | if (prepayments == null || prepayments.size() == 0) { |
| | | return; |
| | | } |
| | | JSONObject dataObj = null; |
| | | for (int roomIndex = 0; roomIndex < prepayments.size(); roomIndex++) { |
| | | row = sheet.createRow(roomIndex + 1); |
| | | dataObj = prepayments.getJSONObject(roomIndex); |
| | | row.createCell(0).setCellValue(dataObj.getString("prepaymentId")); |
| | | row.createCell(1).setCellValue(dataObj.getString("objName")); |
| | | row.createCell(2).setCellValue(dataObj.getString("ownerName")); |
| | | row.createCell(3).setCellValue(dataObj.getString("feeName")); |
| | | row.createCell(4).setCellValue(dataObj.getString("feeTypeCdName")); |
| | | row.createCell(5).setCellValue(dataObj.getString("prepaymentStateName")); |
| | | if (!StringUtil.isEmpty(dataObj.getString("primeRate"))) { |
| | | row.createCell(6).setCellValue(dataObj.getString("primeRate")); |
| | | } else { |
| | | row.createCell(6).setCellValue("--"); |
| | | } |
| | | row.createCell(7).setCellValue(dataObj.getString("feeBeginTime")); |
| | | row.createCell(8).setCellValue(dataObj.getString("feeFinishTime")); |
| | | if (!StringUtil.isEmpty(dataObj.getString("payTime"))) { |
| | | row.createCell(9).setCellValue(dataObj.getString("payTime")); |
| | | } else { |
| | | row.createCell(9).setCellValue("--"); |
| | | } |
| | | row.createCell(10).setCellValue(dataObj.getString("payableAmount")); |
| | | row.createCell(11).setCellValue(dataObj.getString("prepaymentReceivableAmount")); |
| | | row.createCell(12).setCellValue(dataObj.getString("prepaymentReceivedAmount")); |
| | | row.createCell(13).setCellValue(dataObj.getString("oweAmount")); |
| | | row.createCell(14).setCellValue(dataObj.getString("preferentialAmount")); |
| | | row.createCell(15).setCellValue(dataObj.getString("deductionAmount")); |
| | | row.createCell(16).setCellValue(dataObj.getString("giftAmount")); |
| | | row.createCell(17).setCellValue(dataObj.getString("lateFee")); |
| | | row.createCell(18).setCellValue(dataObj.getString("vacantHousingDiscount")); |
| | | row.createCell(19).setCellValue(dataObj.getString("vacantHousingReduction")); |
| | | row.createCell(20).setCellValue(dataObj.getString("builtUpArea")); |
| | | } |
| | | } |
| | | |
| | | private void reportCollectFees(IPageData pd, ComponentValidateResult result, Workbook workbook){ |
| | | Sheet sheet = workbook.createSheet("收费状况表"); |
| | | Row row = sheet.createRow(0); |
| | | row.createCell(0).setCellValue("费用项"); |
| | | row.createCell(1).setCellValue("费用类型"); |
| | | row.createCell(2).setCellValue("应缴金额(元)"); |
| | | row.createCell(3).setCellValue("应收金额(元)"); |
| | | row.createCell(4).setCellValue("实收金额(元)"); |
| | | row.createCell(5).setCellValue("欠费金额(元)"); |
| | | row.createCell(6).setCellValue("优惠金额(元)"); |
| | | row.createCell(7).setCellValue("减免金额(元)"); |
| | | row.createCell(8).setCellValue("赠送金额(元)"); |
| | | row.createCell(9).setCellValue("滞纳金(元)"); |
| | | row.createCell(10).setCellValue("空置房打折(元)"); |
| | | row.createCell(11).setCellValue("空置房减免(元)"); |
| | | //查询预付期缴费明细 |
| | | JSONArray prepayments = this.getReportCollectFees(pd, result); |
| | | if (prepayments == null || prepayments.size() == 0) { |
| | | return; |
| | | } |
| | | JSONObject dataObj = null; |
| | | for (int roomIndex = 0; roomIndex < prepayments.size(); roomIndex++) { |
| | | row = sheet.createRow(roomIndex + 1); |
| | | dataObj = prepayments.getJSONObject(roomIndex); |
| | | row.createCell(0).setCellValue(dataObj.getString("feeName")); |
| | | row.createCell(1).setCellValue(dataObj.getString("feeTypeCdName")); |
| | | row.createCell(2).setCellValue(dataObj.getString("allPayableAmount")); |
| | | row.createCell(3).setCellValue(dataObj.getString("allReceivableAmount")); |
| | | row.createCell(4).setCellValue(dataObj.getString("allReceivedAmount")); |
| | | row.createCell(5).setCellValue(dataObj.getString("allOweAmount")); |
| | | row.createCell(6).setCellValue(dataObj.getString("allPreferentialAmount")); |
| | | row.createCell(7).setCellValue(dataObj.getString("allDeductionAmount")); |
| | | row.createCell(8).setCellValue(dataObj.getString("allGiftAmount")); |
| | | row.createCell(9).setCellValue(dataObj.getString("allLateFee")); |
| | | row.createCell(10).setCellValue(dataObj.getString("allVacantHousingDiscount")); |
| | | row.createCell(11).setCellValue(dataObj.getString("allVacantHousingReduction")); |
| | | } |
| | | } |
| | | |
| | | private void reportPayFeeManage(IPageData pd, ComponentValidateResult result, Workbook workbook) { |
| | | Sheet sheet = workbook.createSheet("缴费清单"); |
| | | Row row = sheet.createRow(0); |
| | |
| | | row.createCell(11).setCellValue("申请数量"); |
| | | row.createCell(12).setCellValue("采购/出库数量"); |
| | | row.createCell(13).setCellValue("采购价格"); |
| | | row.createCell(14).setCellValue("采购总价"); |
| | | row.createCell(14).setCellValue("总价"); |
| | | row.createCell(15).setCellValue("申请备注"); |
| | | row.createCell(16).setCellValue("状态"); |
| | | row.createCell(17).setCellValue("创建时间"); |
| | |
| | | row.createCell(11).setCellValue(dataObj.getString("quantity") + dataObj.getString("unitCodeName")); |
| | | row.createCell(12).setCellValue(dataObj.getString("purchaseQuantity") + dataObj.getString("unitCodeName")); |
| | | row.createCell(13).setCellValue(dataObj.getString("price")); |
| | | if (!StringUtil.isEmpty(dataObj.getString("resOrderType")) && dataObj.getString("resOrderType").equals("10000") && |
| | | !StringUtil.isEmpty(dataObj.getString("purchaseQuantity")) && !StringUtil.isEmpty(dataObj.getString("price"))) { //状态是入库 |
| | | //!StringUtil.isEmpty(dataObj.getString("resOrderType")) && dataObj.getString("resOrderType").equals("10000") && |
| | | if (!StringUtil.isEmpty(dataObj.getString("purchaseQuantity")) && !StringUtil.isEmpty(dataObj.getString("price"))) { //状态是入库 |
| | | //获取采购数量 |
| | | double purchaseQuantity = Double.parseDouble(dataObj.getString("purchaseQuantity")); |
| | | //获取采购单价 |
| | |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | reqJson.put("page", 1); |
| | | reqJson.put("row", 10000); |
| | | reqJson.put("hasOweFee","Y"); |
| | | reqJson.put("hasOweFee", "Y"); |
| | | apiUrl = "/reportOweFee/queryReportAllOweFee" + mapToUrlParam(reqJson); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | |
| | | return null; |
| | | } |
| | | return savedRepairInfoResults.getJSONArray("data"); |
| | | } |
| | | |
| | | private JSONArray getReportPrepaymentDetail(IPageData pd, ComponentValidateResult result) { |
| | | String apiUrl = ""; |
| | | ResponseEntity<String> responseEntity = null; |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | reqJson.put("page", 1); |
| | | reqJson.put("row", 10000); |
| | | apiUrl = "/reportFeeMonthStatisticsPrepayment/queryPayFeePrepaymentDetail" + mapToUrlParam(reqJson); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |
| | | } |
| | | JSONObject savedPrepaymentInfoResults = JSONObject.parseObject(responseEntity.getBody(), Feature.OrderedField); |
| | | //获取限制条数的值 |
| | | int number = Integer.parseInt(MappingCache.getValue(DOMAIN_COMMON, EXPORT_NUMBER)); |
| | | if (savedPrepaymentInfoResults.getJSONArray("data").size() > number) { |
| | | throw new IllegalArgumentException("导出数据超过限制条数" + number + "条,无法继续导出操作!"); |
| | | } |
| | | if (!savedPrepaymentInfoResults.containsKey("data")) { |
| | | return null; |
| | | } |
| | | return savedPrepaymentInfoResults.getJSONArray("data"); |
| | | } |
| | | |
| | | private JSONArray getReportCollectFees(IPageData pd, ComponentValidateResult result) { |
| | | String apiUrl = ""; |
| | | ResponseEntity<String> responseEntity = null; |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | reqJson.put("page", 1); |
| | | reqJson.put("row", 10000); |
| | | apiUrl = "/reportFeeMonthStatisticsPrepayment/queryReportCollectFees" + mapToUrlParam(reqJson); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |
| | | } |
| | | JSONObject savedCollectFeeInfoResults = JSONObject.parseObject(responseEntity.getBody(), Feature.OrderedField); |
| | | //获取限制条数的值 |
| | | int number = Integer.parseInt(MappingCache.getValue(DOMAIN_COMMON, EXPORT_NUMBER)); |
| | | if (savedCollectFeeInfoResults.getJSONArray("data").size() > number) { |
| | | throw new IllegalArgumentException("导出数据超过限制条数" + number + "条,无法继续导出操作!"); |
| | | } |
| | | if (!savedCollectFeeInfoResults.containsKey("data")) { |
| | | return null; |
| | | } |
| | | return savedCollectFeeInfoResults.getJSONArray("data"); |
| | | } |
| | | |
| | | private JSONArray getReportPayFeeManage(IPageData pd, ComponentValidateResult result) { |
| | |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | reqJson.put("page", 1); |
| | | reqJson.put("row", 10000); |
| | | apiUrl = "/reportFeeMonthStatistics/queryPrePayment" + mapToUrlParam(reqJson); |
| | | apiUrl = "/reportFeeMonthStatistics.queryPrePayment" + mapToUrlParam(reqJson); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |
| | |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | reqJson.put("page", 1); |
| | | reqJson.put("row", 10000); |
| | | apiUrl = "/reportFeeMonthStatistics/queryDeadlineFee" + mapToUrlParam(reqJson); |
| | | apiUrl = "/reportFeeMonthStatistics.queryDeadlineFee" + mapToUrlParam(reqJson); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |
| | |
| | | String[] split = receivedAmount.split("-"); |
| | | receivedAmount = split[1]; |
| | | } |
| | | if(!StringUtil.isEmpty(str) || !StringUtil.isEmpty(discount)) { |
| | | if (!StringUtil.isEmpty(str) || !StringUtil.isEmpty(discount)) { |
| | | row.createCell(7).setCellValue(receivedAmount + "(" + str + discount + ")"); |
| | | } else { |
| | | row.createCell(7).setCellValue(receivedAmount); |
| | |
| | | JSONObject reqJson = JSONObject.parseObject(pd.getReqData()); |
| | | reqJson.put("page", 1); |
| | | reqJson.put("row", 10000); |
| | | apiUrl = "/reportFeeMonthStatistics/queryReportFeeSummary" + mapToUrlParam(reqJson); |
| | | apiUrl = "/reportFeeMonthStatistics.queryReportFeeSummary" + mapToUrlParam(reqJson); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |