Просмотр исходного кода

报表运营开发完成欠费明细表

wuxw 1 год назад
Родитель
Сommit
da9c3956e7

+ 2 - 2
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml

@@ -1492,7 +1492,7 @@
 
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <select id="queryOweFeeDetail" parameterType="Map" resultType="Map">
-        select t.obj_name objName,t.fee_name feeName,t.owner_name ownerName,t.link ownerTel,br.built_up_area builtUpArea,
+        select t.obj_name objName,t.fee_name feeName,t.owner_name ownerName,t.link ownerTel,br.built_up_area builtUpArea,t.community_id communityId,
         MIN(t.cur_month_time) startTime,MAX(t.cur_month_time) endTime,max(t.deadline_time) deadlineTime,SUM(t.receivable_amount) oweAmount
         from pay_fee_detail_month t
         left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
@@ -1537,7 +1537,7 @@
         <if test="feeTypeCd != null and feeTypeCd != ''">
             and t.fee_type_cd = #{feeTypeCd}
         </if>
-        group by t.obj_name ,t.fee_name ,t.owner_name ,t.link ,br.built_up_area
+        group by t.obj_name ,t.fee_name ,t.owner_name ,t.link ,br.built_up_area,t.community_id
         order by t.obj_name
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}

+ 1 - 10
service-report/src/main/java/com/java110/report/cmd/admin/GetCommunityFeeSummaryCmd.java

@@ -33,20 +33,11 @@ public class GetCommunityFeeSummaryCmd extends Cmd {
 
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
-        Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
 
         Assert.hasKeyAndValue(reqJson, "startDate", "未包含开始日期");
         Assert.hasKeyAndValue(reqJson, "endDate", "未包含结束日期");
 
-        String storeId = CmdContextUtils.getStoreId(context);
-
-        StoreDto storeDto = new StoreDto();
-        storeDto.setStoreId(storeId);
-        storeDto.setStoreTypeCd(StoreDto.STORE_TYPE_ADMIN);
-        int count = storeInnerServiceSMOImpl.getStoreCount(storeDto);
-        if (count < 1) {
-            throw new CmdException("非法操作,请用系统管理员账户操作");
-        }
+        super.validateAdmin(context);
     }
 
     @Override

+ 92 - 0
service-report/src/main/java/com/java110/report/cmd/fee/QueryAdminOweFeeDetailCmd.java

@@ -5,12 +5,37 @@ 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.core.log.LoggerFactory;
+import com.java110.dto.community.CommunityDto;
+import com.java110.dto.reportFee.ReportFeeMonthStatisticsDto;
+import com.java110.intf.community.ICommunityV1InnerServiceSMO;
+import com.java110.intf.report.IReportFeeMonthStatisticsInnerServiceSMO;
+import com.java110.report.bmo.reportFeeMonthStatistics.impl.GetReportFeeMonthStatisticsBMOImpl;
 import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ListUtil;
+import com.java110.vo.ResultVo;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
 
 @Java110Cmd(serviceCode = "fee.queryAdminOweFeeDetail")
 public class QueryAdminOweFeeDetailCmd extends Cmd {
+
+    private static final Logger logger = LoggerFactory.getLogger(GetReportFeeMonthStatisticsBMOImpl.class);
+
+    @Autowired
+    private IReportFeeMonthStatisticsInnerServiceSMO reportFeeMonthStatisticsInnerServiceSMOImpl;
+
+    @Autowired
+    private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
         super.validateAdmin(context);
@@ -19,6 +44,73 @@ public class QueryAdminOweFeeDetailCmd extends Cmd {
 
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = BeanConvertUtil.covertBean(reqJson, ReportFeeMonthStatisticsDto.class);
+        int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetailCount(reportFeeMonthStatisticsDto);
+        List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
+        if (count > 0) {
+            reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetail(reportFeeMonthStatisticsDto);
+            ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetailMajor(reportFeeMonthStatisticsDto);
+            if (!ListUtil.isNull(reportFeeMonthStatisticsDtos)) {
+                for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsDtos) {
+//                    reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
+//                    reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
+                    reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getOweAmount());
+                }
+            }
+            freshReportOweDay(reportFeeMonthStatisticsDtos);
+        } else {
+            reportFeeMonthStatisticsDtos = new ArrayList<>();
+        }
+
+        refreshCommunityName(reportFeeMonthStatisticsDtos);
+
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportFeeMonthStatisticsDtos);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
+
+    }
+
+    private void freshReportOweDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
+        int day = 0;
+        for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+            try {
+                day = DateUtil.daysBetween(DateUtil.getDateFromStringB(reportFeeMonthStatisticsDto.getEndTime()),
+                        DateUtil.getDateFromStringB(reportFeeMonthStatisticsDto.getStartTime()));
+                reportFeeMonthStatisticsDto.setOweDay(day);
+            } catch (Exception e) {
+                logger.error("计算欠费天数失败", e);
+            }
+        }
+    }
+
+    private void refreshCommunityName(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
+        if(ListUtil.isNull(reportFeeMonthStatisticsDtos)){
+            return;
+        }
+
+        List<String> communityIds = new ArrayList<>();
+        for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+            communityIds.add(reportFeeMonthStatisticsDto.getCommunityId());
+        }
 
+        if(ListUtil.isNull(communityIds)){
+            return ;
+        }
+        CommunityDto communityDto = new CommunityDto();
+        communityDto.setCommunityIds(communityIds.toArray(new String[communityIds.size()]));
+        List<CommunityDto> communityDtos = communityV1InnerServiceSMOImpl.queryCommunitys(communityDto);
+        if(ListUtil.isNull(communityDtos)){
+            return;
+        }
+        for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+            for (CommunityDto tCommunityDto : communityDtos) {
+                if (!reportFeeMonthStatisticsDto.getCommunityId().equals(tCommunityDto.getCommunityId())) {
+                    continue;
+                }
+                reportFeeMonthStatisticsDto.setCommunityName(tCommunityDto.getName());
+            }
+        }
     }
 }