java110 пре 3 година
родитељ
комит
91f0f8d0bb

+ 139 - 0
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFeeDetailCarCmd.java

@@ -0,0 +1,139 @@
+package com.java110.report.cmd.reportFeeMonthStatistics;
+
+import com.alibaba.fastjson.JSONArray;
+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.contract.ContractDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.report.QueryStatisticsDto;
+import com.java110.report.statistics.IBaseDataStatistics;
+import com.java110.report.statistics.IFeeStatistics;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+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.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 查询车辆费用明细表
+ * 以房屋为维度统计 房屋的各个费用项 欠费和实收
+ */
+
+@Java110Cmd(serviceCode = "reportFeeMonthStatistics.queryReportFeeDetailCar")
+public class QueryReportFeeDetailCarCmd extends Cmd {
+
+    @Autowired
+    private IFeeStatistics feeStatisticsImpl;
+
+    @Autowired
+    private IBaseDataStatistics baseDataStatisticsImpl;
+
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        super.validatePageInfo(reqJson);
+        Assert.hasKeyAndValue(reqJson, "startDate", "未包含开始日期");
+        Assert.hasKeyAndValue(reqJson, "endDate", "未包含结束日期");
+        Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        String storeId = context.getReqHeaders().get("store-id");
+
+        QueryStatisticsDto queryStatisticsDto = new QueryStatisticsDto();
+        queryStatisticsDto.setCommunityId(reqJson.getString("communityId"));
+        queryStatisticsDto.setStartDate(reqJson.getString("startDate"));
+        queryStatisticsDto.setEndDate(reqJson.getString("endDate"));
+        queryStatisticsDto.setConfigId(reqJson.getString("configId"));
+        queryStatisticsDto.setFloorId(reqJson.getString("floorId"));
+        queryStatisticsDto.setObjName(reqJson.getString("objName"));
+        queryStatisticsDto.setFeeTypeCd(reqJson.getString("feeTypeCd"));
+        queryStatisticsDto.setOwnerName(reqJson.getString("ownerName"));
+        queryStatisticsDto.setLink(reqJson.getString("link"));
+        queryStatisticsDto.setPage(reqJson.getInteger("page"));
+        queryStatisticsDto.setRow(reqJson.getInteger("row"));
+        queryStatisticsDto.setStoreId(storeId);
+        long count = baseDataStatisticsImpl.getCarCount(queryStatisticsDto);
+        List<OwnerCarDto> contractDtos = null;
+        if (count > 0) {
+            contractDtos = baseDataStatisticsImpl.getCar(queryStatisticsDto);
+        } else {
+            contractDtos = new ArrayList<>();
+        }
+
+        // todo 计算 房屋欠费实收数据
+        JSONArray datas = computeCarOweReceivedFee(contractDtos, queryStatisticsDto);
+
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) queryStatisticsDto.getRow()), count, datas);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        context.setResponseEntity(responseEntity);
+
+    }
+
+    /**
+     * 计算合同欠费 实收费用
+     *
+     * @param ownerCarDtos
+     * @return
+     */
+    private JSONArray computeCarOweReceivedFee(List<OwnerCarDto> ownerCarDtos, QueryStatisticsDto queryStatisticsDto) {
+        if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
+            return new JSONArray();
+        }
+
+        JSONArray datas = new JSONArray();
+        JSONObject data = null;
+
+        List<String> objIds = new ArrayList<>();
+        for (OwnerCarDto ownerCarDto : ownerCarDtos) {
+            objIds.add(ownerCarDto.getCarId());
+            data = new JSONObject();
+            data.put("carId", ownerCarDto.getCarId());
+            data.put("carNum", ownerCarDto.getCarNum() );
+            data.put("ownerName", ownerCarDto.getOwnerName());
+            data.put("ownerId", ownerCarDto.getOwnerId());
+            data.put("link", ownerCarDto.getLink());
+            datas.add(data);
+        }
+
+        queryStatisticsDto.setObjIds(objIds.toArray(new String[objIds.size()]));
+        List<Map> infos = feeStatisticsImpl.getObjFeeSummary(queryStatisticsDto);
+
+        if (infos == null || infos.size() < 1) {
+            return datas;
+        }
+
+        BigDecimal oweFee = new BigDecimal(0.00);
+        BigDecimal receivedFee = new BigDecimal(0.00);
+        for (int dataIndex = 0; dataIndex < datas.size(); dataIndex++) {
+            data = datas.getJSONObject(dataIndex);
+            for (Map info : infos) {
+                if (!data.get("carId").toString().equals(info.get("objId"))) {
+                    continue;
+                }
+
+                oweFee = oweFee.add(new BigDecimal(info.get("oweFee").toString()));
+                receivedFee = oweFee.add(new BigDecimal(info.get("receivedFee").toString()));
+                data.put("oweFee" + info.get("feeTypeCd").toString(), info.get("oweFee"));
+                data.put("receivedFee" + info.get("feeTypeCd").toString(), info.get("receivedFee"));
+            }
+            data.put("oweFee", oweFee.doubleValue());
+            data.put("receivedFee", receivedFee.doubleValue());
+        }
+
+        return datas;
+    }
+}

+ 15 - 0
service-report/src/main/java/com/java110/report/statistics/IBaseDataStatistics.java

@@ -2,6 +2,7 @@ package com.java110.report.statistics;
 
 import com.java110.dto.RoomDto;
 import com.java110.dto.contract.ContractDto;
+import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.owner.OwnerDto;
 import com.java110.dto.report.QueryStatisticsDto;
 
@@ -56,4 +57,18 @@ public interface IBaseDataStatistics {
     long getContractCount(QueryStatisticsDto queryStatisticsDto);
 
     List<ContractDto> getContract(QueryStatisticsDto queryStatisticsDto);
+
+    /**
+     * 查询车辆数量
+     * @param queryStatisticsDto
+     * @return
+     */
+    long getCarCount(QueryStatisticsDto queryStatisticsDto);
+
+    /**
+     * 查询车辆
+     * @param queryStatisticsDto
+     * @return
+     */
+    List<OwnerCarDto> getCar(QueryStatisticsDto queryStatisticsDto);
 }

+ 35 - 1
service-report/src/main/java/com/java110/report/statistics/impl/BaseDataStatisticsImpl.java

@@ -2,12 +2,14 @@ package com.java110.report.statistics.impl;
 
 import com.java110.dto.RoomDto;
 import com.java110.dto.contract.ContractDto;
+import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.owner.OwnerDto;
 import com.java110.dto.report.QueryStatisticsDto;
 import com.java110.intf.community.IRoomV1InnerServiceSMO;
 import com.java110.intf.report.IBaseDataStatisticsInnerServiceSMO;
 import com.java110.intf.report.IReportFeeStatisticsInnerServiceSMO;
 import com.java110.intf.store.IContractInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
 import com.java110.intf.user.IOwnerV1InnerServiceSMO;
 import com.java110.report.statistics.IBaseDataStatistics;
 import com.java110.utils.util.StringUtil;
@@ -34,6 +36,9 @@ public class BaseDataStatisticsImpl implements IBaseDataStatistics {
     @Autowired
     private IContractInnerServiceSMO contractInnerServiceSMOImpl;
 
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
     /**
      * 查询全部房屋
      *
@@ -44,8 +49,9 @@ public class BaseDataStatisticsImpl implements IBaseDataStatistics {
     public long getRoomCount(QueryStatisticsDto queryStatisticsDto) {
 
         RoomDto roomDto = new RoomDto();
-        roomDto.setCommunityId(queryStatisticsDto.getCommunityId());
         roomDto.setFloorId(queryStatisticsDto.getFloorId());
+        roomDto.setCommunityId(queryStatisticsDto.getCommunityId());
+
         addRoomNumCondition(queryStatisticsDto, roomDto);
         return baseDataStatisticsInnerServiceSMOImpl.getRoomCount(roomDto);
     }
@@ -90,6 +96,7 @@ public class BaseDataStatisticsImpl implements IBaseDataStatistics {
         ownerDto.setOwnerTypeCd(OwnerDto.OWNER_TYPE_CD_OWNER);
         ownerDto.setNameLike(queryStatisticsDto.getOwnerName());
         ownerDto.setLink(queryStatisticsDto.getLink());
+        ownerDto.setCommunityId(queryStatisticsDto.getCommunityId());
         return ownerV1InnerServiceSMOImpl.queryOwnersCount(ownerDto);
     }
 
@@ -98,6 +105,7 @@ public class BaseDataStatisticsImpl implements IBaseDataStatistics {
         OwnerDto ownerDto = new OwnerDto();
         ownerDto.setOwnerTypeCd(OwnerDto.OWNER_TYPE_CD_OWNER);
         ownerDto.setNameLike(queryStatisticsDto.getOwnerName());
+        ownerDto.setCommunityId(queryStatisticsDto.getCommunityId());
         ownerDto.setLink(queryStatisticsDto.getLink());
         ownerDto.setPage(queryStatisticsDto.getPage());
         ownerDto.setRow(queryStatisticsDto.getRow());
@@ -107,6 +115,7 @@ public class BaseDataStatisticsImpl implements IBaseDataStatistics {
     @Override
     public long getContractCount(QueryStatisticsDto queryStatisticsDto) {
         ContractDto contractDto = new ContractDto();
+        contractDto.setContractNameLike(queryStatisticsDto.getObjName());
         contractDto.setStoreId(queryStatisticsDto.getStoreId());
         contractDto.setbLink(queryStatisticsDto.getLink());
         contractDto.setPartyBLike(queryStatisticsDto.getOwnerName());
@@ -118,12 +127,37 @@ public class BaseDataStatisticsImpl implements IBaseDataStatistics {
         ContractDto contractDto = new ContractDto();
         contractDto.setStoreId(queryStatisticsDto.getStoreId());
         contractDto.setbLink(queryStatisticsDto.getLink());
+        contractDto.setContractNameLike(queryStatisticsDto.getObjName());
         contractDto.setPartyBLike(queryStatisticsDto.getOwnerName());
         contractDto.setPage(queryStatisticsDto.getPage());
         contractDto.setRow(queryStatisticsDto.getRow());
         return contractInnerServiceSMOImpl.queryContracts(contractDto);
     }
 
+    @Override
+    public long getCarCount(QueryStatisticsDto queryStatisticsDto) {
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCommunityId(queryStatisticsDto.getCommunityId());
+        ownerCarDto.setCarNumLike(queryStatisticsDto.getObjName());
+        ownerCarDto.setOwnerName(queryStatisticsDto.getOwnerName());
+        ownerCarDto.setLink(queryStatisticsDto.getLink());
+        ownerCarDto.setCarTypeCd(OwnerCarDto.CAR_TYPE_PRIMARY);
+        return ownerCarInnerServiceSMOImpl.queryOwnerCarsCount(ownerCarDto);
+    }
+
+    @Override
+    public List<OwnerCarDto> getCar(QueryStatisticsDto queryStatisticsDto) {
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCommunityId(queryStatisticsDto.getCommunityId());
+        ownerCarDto.setCarNumLike(queryStatisticsDto.getObjName());
+        ownerCarDto.setOwnerName(queryStatisticsDto.getOwnerName());
+        ownerCarDto.setLink(queryStatisticsDto.getLink());
+        ownerCarDto.setPage(queryStatisticsDto.getPage());
+        ownerCarDto.setRow(queryStatisticsDto.getRow());
+        ownerCarDto.setCarTypeCd(OwnerCarDto.CAR_TYPE_PRIMARY);
+        return ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+    }
+
 
     /**
      * roomNum 拆分 查询房屋信息