Kaynağa Gözat

报表导出

java110 5 yıl önce
ebeveyn
işleme
f805ffca7e

+ 52 - 0
java110-db/src/main/resources/mapper/report/ReportFeeYearCollectionServiceDaoImplMapper.xml

@@ -14,6 +14,58 @@
         )
     </insert>
 
+    <select id="getReportFeeYearCollectionInfos" parameterType="Map" resultType="Map">
+        select t.owner_link,t.owner_link ownerLink,t.status_cd,t.status_cd statusCd,t.obj_name,t.obj_name
+        objName,t.owner_id,t.owner_id ownerId,t.fee_id,t.fee_id feeId,t.built_up_area,t.built_up_area
+        builtUpArea,t.owner_name,t.owner_name ownerName,t.config_id,t.config_id configId,t.obj_id,t.obj_id
+        objId,t.fee_name,t.fee_name feeName,t.community_id,t.community_id communityId,t.collection_id,t.collection_id
+        collectionId,t.obj_type,t.obj_type objType,rd.collection_year collectionYear,rd.receivable_amount receivableAmount,
+        rd.relation_year relationYear
+        from report_fee_year_collection t
+        left join report_fee_year_collection_detail rd on t.collection_id = rd.collection_id and rd.status_cd = '0' and rd.community_id = t.community_id
+        where 1 =1
+        <if test="ownerLink !=null and ownerLink != ''">
+            and t.owner_link= #{ownerLink}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="objName !=null and objName != ''">
+            and t.obj_name= #{objName}
+        </if>
+        <if test="ownerId !=null and ownerId != ''">
+            and t.owner_id= #{ownerId}
+        </if>
+        <if test="feeId !=null and feeId != ''">
+            and t.fee_id= #{feeId}
+        </if>
+        <if test="builtUpArea !=null and builtUpArea != ''">
+            and t.built_up_area= #{builtUpArea}
+        </if>
+        <if test="ownerName !=null and ownerName != ''">
+            and t.owner_name= #{ownerName}
+        </if>
+        <if test="configId !=null and configId != ''">
+            and t.config_id= #{configId}
+        </if>
+        <if test="objId !=null and objId != ''">
+            and t.obj_id= #{objId}
+        </if>
+        <if test="feeName !=null and feeName != ''">
+            and t.fee_name= #{feeName}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="collectionId !=null and collectionId != ''">
+            and t.collection_id= #{collectionId}
+        </if>
+        <if test="objType !=null and objType != ''">
+            and t.obj_type= #{objType}
+        </if>
+        order by rd.collectionYear
+
+    </select>
 
     <!-- 查询费用年收费信息 add by wuxw 2018-07-03 -->
     <select id="getReportFeeYearCollectionInfo" parameterType="Map" resultType="Map">

+ 62 - 0
service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportReportFeeSMOImpl.java

@@ -45,6 +45,7 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
     public static final String REPORT_FEE_DETAIL = "reportFeeDetail";
     public static final String REPORT_OWE_FEE_DETAIL = "reportOweFeeDetail";
     public static final String REPORT_PAY_FEE_DETAIL = "reportPayFeeDetail";
+    public static final String REPORT_YEAR_COLLECTION = "reportYearCollection";
 
     @Autowired
     private RestTemplate restTemplate;
@@ -83,6 +84,10 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
             case REPORT_PAY_FEE_DETAIL:
                 reportPayFeeDetail(pd, result, workbook);
                 break;
+            case REPORT_YEAR_COLLECTION:
+                reportYearCollection(pd, result, workbook);
+                break;
+
         }
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         MultiValueMap headers = new HttpHeaders();
@@ -150,6 +155,45 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
         }
     }
 
+    private void reportYearCollection(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("应收金额");
+
+        //查询楼栋信息
+        JSONArray rooms = this.getReportYearCollection(pd, result);
+        if (rooms == null) {
+            return;
+        }
+        JSONArray reportFeeYearCollectionDetailDtos = rooms.getJSONObject(0).getJSONArray("reportFeeYearCollectionDetailDtos");
+
+        for (int detailIndex = 0; detailIndex < reportFeeYearCollectionDetailDtos.size(); detailIndex++) {
+            row.createCell(6 + detailIndex).setCellValue(reportFeeYearCollectionDetailDtos.getJSONObject(detailIndex).getString("collectionYear") + "年");
+        }
+
+        JSONObject dataObj = null;
+        for (int roomIndex = 0; roomIndex < rooms.size(); roomIndex++) {
+            row = sheet.createRow(roomIndex + 1);
+            dataObj = rooms.getJSONObject(roomIndex);
+            row.createCell(0).setCellValue(dataObj.getString("ownerName"));
+            row.createCell(1).setCellValue(dataObj.getString("objName"));
+            row.createCell(2).setCellValue(dataObj.getString("ownerLink"));
+            row.createCell(3).setCellValue(dataObj.getString("builtUpArea"));
+            row.createCell(4).setCellValue(dataObj.getString("feeName"));
+            row.createCell(5).setCellValue(dataObj.getString("receivableAmount"));
+
+            reportFeeYearCollectionDetailDtos = rooms.getJSONObject(roomIndex).getJSONArray("reportFeeYearCollectionDetailDtos");
+            for (int detailIndex = 0; detailIndex < reportFeeYearCollectionDetailDtos.size(); detailIndex++) {
+                row.createCell(6 + detailIndex).setCellValue(reportFeeYearCollectionDetailDtos.getJSONObject(detailIndex).getString("receivedAmount"));
+            }
+        }
+    }
+
     private JSONArray getReportPayFeeDetail(IPageData pd, ComponentValidateResult result) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
@@ -168,6 +212,24 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
         return savedRoomInfoResults.getJSONArray("data");
     }
 
+    private JSONArray getReportYearCollection(IPageData pd, ComponentValidateResult result) {
+        String apiUrl = "";
+        ResponseEntity<String> responseEntity = null;
+        JSONObject reqJson = JSONObject.parseObject(pd.getReqData());
+        reqJson.put("page", 1);
+        reqJson.put("row", 10001);
+        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/reportFeeYearCollection/queryReportFeeYear" + mapToUrlParam(reqJson);
+        responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息
+            return null;
+        }
+        JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody(), Feature.OrderedField);
+        if (!savedRoomInfoResults.containsKey("data")) {
+            return null;
+        }
+        return savedRoomInfoResults.getJSONArray("data");
+    }
+
     private void reportOweFeeDetail(IPageData pd, ComponentValidateResult result, Workbook workbook) {
         Sheet sheet = workbook.createSheet("欠费明细表");
         Row row = sheet.createRow(0);

+ 2 - 0
service-report/src/main/java/com/java110/report/api/ReportFeeYearCollectionApi.java

@@ -131,6 +131,8 @@ public class ReportFeeYearCollectionApi {
         return getReportFeeYearCollectionBMOImpl.get(reportFeeYearCollectionDto);
     }
 
+
+
     /**
      * 微信保存消息模板
      *

+ 1 - 0
service-report/src/main/java/com/java110/report/dao/IReportFeeYearCollectionServiceDao.java

@@ -39,6 +39,7 @@ public interface IReportFeeYearCollectionServiceDao {
      * @throws DAOException DAO异常
      */
     List<Map> getReportFeeYearCollectionInfo(Map info) throws DAOException;
+    List<Map> getReportFeeYearCollectionInfos(Map info) throws DAOException;
 
 
 

+ 14 - 0
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeYearCollectionServiceDaoImpl.java

@@ -59,6 +59,20 @@ public class ReportFeeYearCollectionServiceDaoImpl extends BaseServiceDao implem
 
         return businessReportFeeYearCollectionInfos;
     }
+    /**
+     * 查询费用年收费信息(instance)
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getReportFeeYearCollectionInfos(Map info) throws DAOException {
+        logger.debug("查询费用年收费信息 入参 info : {}",info);
+
+        List<Map> businessReportFeeYearCollectionInfos = sqlSessionTemplate.selectList("reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfos",info);
+
+        return businessReportFeeYearCollectionInfos;
+    }
 
 
     /**

+ 55 - 1
service-report/src/main/java/com/java110/report/smo/impl/ReportFeeYearCollectionInnerServiceSMOImpl.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName FloorInnerServiceSMOImpl
@@ -63,17 +64,70 @@ public class ReportFeeYearCollectionInnerServiceSMOImpl extends BaseServiceSMO i
         //校验是否传了 分页信息
 
         int page = reportFeeYearCollectionDto.getPage();
+        List<ReportFeeYearCollectionDto> reportFeeYearCollections = null;
+
+        //不分页直接查全量数据
+        if (reportFeeYearCollectionDto.getRow() > 10000) {
+            List<Map> reportFeeYearCollectionMaps =
+                    reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfos(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto));
+
+            reportFeeYearCollections = doCreateReportFeeYearCollections(reportFeeYearCollectionMaps);
+            return reportFeeYearCollections;
+        }
 
         if (page != PageDto.DEFAULT_PAGE) {
             reportFeeYearCollectionDto.setPage((page - 1) * reportFeeYearCollectionDto.getRow());
         }
 
-        List<ReportFeeYearCollectionDto> reportFeeYearCollections = BeanConvertUtil.covertBeanList(reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto)), ReportFeeYearCollectionDto.class);
+        reportFeeYearCollections = BeanConvertUtil.covertBeanList(reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto)), ReportFeeYearCollectionDto.class);
 
         freshDetails(reportFeeYearCollections);
         return reportFeeYearCollections;
     }
 
+    /**
+     * 创建对象
+     *
+     * @param reportFeeYearCollectionMaps
+     * @return
+     */
+    private List<ReportFeeYearCollectionDto> doCreateReportFeeYearCollections(List<Map> reportFeeYearCollectionMaps) {
+        List<ReportFeeYearCollectionDto> reportFeeYearCollectionDtos = new ArrayList<>();
+        ReportFeeYearCollectionDto reportFeeYearCollectionDto = null;
+
+        for (Map reportFeeYearCollectionMap : reportFeeYearCollectionMaps) {
+            if (!hasReportFeeYearCollectionDto(reportFeeYearCollectionMap, reportFeeYearCollectionDtos)) {
+                reportFeeYearCollectionDto = BeanConvertUtil.covertBean(reportFeeYearCollectionMap, ReportFeeYearCollectionDto.class);
+                reportFeeYearCollectionDtos.add(reportFeeYearCollectionDto);
+            }
+        }
+        List<ReportFeeYearCollectionDetailDto> reportFeeYearCollectionDetailDtos = null;
+        ReportFeeYearCollectionDetailDto reportFeeYearCollectionDetailDto = null;
+        for (ReportFeeYearCollectionDto tmpReportFeeYearCollectionDto : reportFeeYearCollectionDtos) {
+            reportFeeYearCollectionDetailDtos = new ArrayList<>();
+            for (Map reportFeeYearCollectionMap : reportFeeYearCollectionMaps) {
+                if (tmpReportFeeYearCollectionDto.getCollectionId().equals(reportFeeYearCollectionMap.get("collectionId"))) {
+                    reportFeeYearCollectionDetailDto = BeanConvertUtil.covertBean(reportFeeYearCollectionMap, ReportFeeYearCollectionDetailDto.class);
+                    reportFeeYearCollectionDetailDtos.add(reportFeeYearCollectionDetailDto);
+                }
+            }
+            tmpReportFeeYearCollectionDto.setReportFeeYearCollectionDetailDtos(reportFeeYearCollectionDetailDtos);
+        }
+
+        return reportFeeYearCollectionDtos;
+    }
+
+    private boolean hasReportFeeYearCollectionDto(Map reportFeeYearCollectionMap, List<ReportFeeYearCollectionDto> reportFeeYearCollectionDtos) {
+
+        for (ReportFeeYearCollectionDto reportFeeYearCollectionDto : reportFeeYearCollectionDtos) {
+            if (reportFeeYearCollectionDto.getCollectionId().equals(reportFeeYearCollectionMap.get("collectionId"))) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private void freshDetails(List<ReportFeeYearCollectionDto> reportFeeYearCollections) {
         if (reportFeeYearCollections == null || reportFeeYearCollections.size() < 1 || reportFeeYearCollections.size() > 20) {
             return;