Kaynağa Gözat

optimize dining

java110 2 yıl önce
ebeveyn
işleme
eff19bd6ed

+ 60 - 32
service-report/src/main/java/com/java110/report/cmd/dataReport/QueryReceivedDetailStatisticsCmd.java

@@ -1,17 +1,22 @@
 package com.java110.report.cmd.dataReport;
 
+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.RoomDto;
 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.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 java.math.BigDecimal;
 import java.text.ParseException;
@@ -28,6 +33,10 @@ public class QueryReceivedDetailStatisticsCmd extends Cmd {
     @Autowired
     private IFeeStatistics feeStatisticsImpl;
 
+    @Autowired
+    private IBaseDataStatistics baseDataStatisticsImpl;
+
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
         Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区");
@@ -50,58 +59,77 @@ public class QueryReceivedDetailStatisticsCmd extends Cmd {
         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"));
+        long count = baseDataStatisticsImpl.getRoomCount(queryStatisticsDto);
+        List<RoomDto> rooms = null;
+        if (count > 0) {
+            rooms = baseDataStatisticsImpl.getRoomInfo(queryStatisticsDto);
+        } else {
+            rooms = new ArrayList<>();
+        }
 
-        List<Map> datas = null;
-        // todo 按楼栋计算实收情况
-        datas = feeStatisticsImpl.getReceivedFeeByFloor(queryStatisticsDto);
+        // todo 计算 房屋欠费实收数据
+        JSONArray datas = computeRoomOweReceivedFee(rooms,queryStatisticsDto);
 
-        datas = computeFloorReceivedFee(datas);
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) queryStatisticsDto.getRow()), count, datas);
 
-        context.setResponseEntity(ResultVo.createResponseEntity(datas));
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        context.setResponseEntity(responseEntity);
     }
 
-    private List<Map> computeFloorReceivedFee(List<Map> datas) {
-        if (datas == null || datas.size() < 1) {
-            return new ArrayList<>();
+    /**
+     * 计算房屋欠费 实收费用
+     *
+     * @param rooms
+     * @return
+     */
+    private JSONArray computeRoomOweReceivedFee(List<RoomDto> rooms,QueryStatisticsDto queryStatisticsDto) {
+        if (rooms == null || rooms.size() < 1) {
+            return new JSONArray();
         }
 
-        List<Map> tmpDatas = new ArrayList<>();
-        for (Map data : datas) {
-            if (!hasInTmp(tmpDatas, data)) {
-                tmpDatas.add(data);
-            }
+        JSONArray datas = new JSONArray();
+        JSONObject data = null;
+
+        List<String> objIds = new ArrayList<>();
+        for (RoomDto roomDto : rooms) {
+            objIds.add(roomDto.getRoomId());
+            data = new JSONObject();
+            data.put("roomId",roomDto.getRoomId());
+            data.put("roomName",roomDto.getFloorNum()+"-"+roomDto.getUnitNum()+"-"+roomDto.getRoomNum());
+            data.put("ownerName",roomDto.getOwnerName());
+            data.put("ownerId",roomDto.getOwnerId());
+            data.put("link",roomDto.getLink());
+            datas.add(data);
         }
 
-        if (tmpDatas == null || tmpDatas.size() < 1) {
-            return new ArrayList<>();
+        queryStatisticsDto.setObjIds(objIds.toArray(new String[objIds.size()]));
+        List<Map> infos = feeStatisticsImpl.getObjFeeSummary(queryStatisticsDto);
+
+        if(infos == null || infos.size() < 1){
+            return datas;
         }
 
         BigDecimal receivedFee = new BigDecimal(0.00);
-        for (Map tmpData : tmpDatas) {
-            for (Map data : datas) {
-                if (!data.get("floorId").toString().equals(tmpData.get("floorId"))) {
+        for(int dataIndex = 0; dataIndex < datas.size();dataIndex ++){
+            data = datas.getJSONObject(dataIndex);
+            for(Map info : infos){
+                if(!data.get("roomId").toString().equals(info.get("objId"))){
                     continue;
                 }
-
-                receivedFee = receivedFee.add(new BigDecimal(data.get("receivedFee").toString()));
-                tmpData.put("receivedFee" + data.get("feeTypeCd").toString(), data.get("receivedFee"));
+                receivedFee = receivedFee.add(new BigDecimal(info.get("receivedFee").toString()));
+                data.put("receivedFee"+info.get("feeTypeCd").toString(),info.get("receivedFee"));
             }
-            tmpData.put("receivedFee", receivedFee.doubleValue());
+            data.put("receivedFee",receivedFee.doubleValue());
         }
 
-        return tmpDatas;
-    }
-
-    private boolean hasInTmp(List<Map> tmpDatas, Map data) {
-        for (Map tmpData : tmpDatas) {
-            if (tmpData.get("floorId").equals(data.get("floorId"))) {
-                return true;
-            }
-        }
-        return false;
+        return datas;
     }
 
 }

+ 1 - 1
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFeeDetailRoomCmd.java

@@ -124,7 +124,7 @@ public class QueryReportFeeDetailRoomCmd extends Cmd {
                 }
 
                 oweFee = oweFee.add(new BigDecimal(info.get("oweFee").toString()));
-                receivedFee = oweFee.add(new BigDecimal(info.get("receivedFee").toString()));
+                receivedFee = receivedFee.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"));
             }