Browse Source

优化报表进度问题

wuxw 2 years ago
parent
commit
f4f6ae0c03

+ 15 - 1
java110-utils/src/main/java/com/java110/utils/util/MoneyUtil.java

@@ -24,7 +24,12 @@ public class MoneyUtil {
     public static double computePriceScale(double price,String scale,int decimalPlace){
 
         //todo 解决 群里反馈 进度丢失问题
-        //todo 发现了个BUG   MoneyUtil.computePriceScale      计算金额四舍五入时,精度丢失问题,    new BigDecimal(String )  就OK了,  double  会出问题。     例如444.195   四舍五入变成了 44.19
+        //todo 发现了个BUG
+        // MoneyUtil.computePriceScale
+        // 计算金额四舍五入时,精度丢失问题,
+        // new BigDecimal(String )
+        // 就OK了,  double  会出问题。
+        // 例如444.195   四舍五入变成了 44.19
         BigDecimal feeTotalPrice = new BigDecimal(price+"");
 
         if(DOWN.equals(scale)) {
@@ -38,5 +43,14 @@ public class MoneyUtil {
         return feeTotalPrice.doubleValue();
     }
 
+    /**
+     * 四舍五入
+     * @param price
+     * @return
+     */
+    public static double computePriceScale(double price){
+        return computePriceScale(price,HALF_UP,2);
+    }
+
 
 }

+ 2 - 0
service-job/src/main/java/com/java110/job/cmd/iot/GetOpenApiCmd.java

@@ -53,6 +53,8 @@ public class GetOpenApiCmd extends Cmd {
         Assert.listOnlyOne(userDtos, "用户未登录");
 
         reqJson.put("propertyUserId", userDtos.get(0).getUserId());
+        reqJson.put("propertyUserTel", userDtos.get(0).getTel());
+
     }
 
     @Override

+ 2 - 0
service-job/src/main/java/com/java110/job/cmd/iot/PostOpenApiCmd.java

@@ -53,6 +53,8 @@ public class PostOpenApiCmd extends Cmd {
         Assert.listOnlyOne(userDtos, "用户未登录");
 
         reqJson.put("propertyUserTel", userDtos.get(0).getTel());
+        reqJson.put("propertyUserId", userDtos.get(0).getUserId());
+
     }
 
     @Override

+ 13 - 12
service-report/src/main/java/com/java110/report/cmd/dataReport/QueryFeeDataReportCmd.java

@@ -11,6 +11,7 @@ import com.java110.report.statistics.IFeeStatistics;
 import com.java110.report.statistics.IOrderStatistics;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.MoneyUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -59,69 +60,69 @@ public class QueryFeeDataReportCmd extends Cmd {
         double receivedFee = feeStatisticsImpl.getReceivedFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","实收金额");
-        data.put("value", receivedFee);
+        data.put("value", MoneyUtil.computePriceScale(receivedFee));
         datas.add(data);
 
         // todo 查询 欠费金额
         double oweFee = feeStatisticsImpl.getOweFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","欠费金额");
-        data.put("value", oweFee);
+        data.put("value", MoneyUtil.computePriceScale(oweFee));
         datas.add(data);
 
         // todo 查询 优惠金额
         double discountFee = feeStatisticsImpl.getDiscountFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","优惠金额");
-        data.put("value", discountFee);
+        data.put("value", MoneyUtil.computePriceScale(discountFee));
         datas.add(data);
 
         // todo 查询 滞纳金
         double lateFee = feeStatisticsImpl.getLateFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","滞纳金");
-        data.put("value", lateFee);
+        data.put("value", MoneyUtil.computePriceScale(lateFee));
         datas.add(data);
 
         // todo 查询 账户预存
         double prestoreAccount = feeStatisticsImpl.getPrestoreAccount(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","账户预存");
-        data.put("value", prestoreAccount);
+        data.put("value", MoneyUtil.computePriceScale(prestoreAccount));
         datas.add(data);
 
         // todo 查询 账户扣款
         double withholdAccount = feeStatisticsImpl.getWithholdAccount(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","账户扣款");
-        data.put("value", withholdAccount);
+        data.put("value", MoneyUtil.computePriceScale(withholdAccount));
         datas.add(data);
 
         // todo 查询 临时车收入
         double tempCarFee = feeStatisticsImpl.getTempCarFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","临时车收入");
-        data.put("value", tempCarFee);
+        data.put("value", MoneyUtil.computePriceScale(tempCarFee));
         datas.add(data);
 
         // todo 查询 押金退款
         double refundDeposit = feeStatisticsImpl.geRefundDeposit(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","押金退款");
-        data.put("value", refundDeposit);
+        data.put("value", MoneyUtil.computePriceScale(refundDeposit));
         datas.add(data);
 
         // todo 查询 退款订单数
         double refundOrderCount = feeStatisticsImpl.geRefundOrderCount(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","退款订单数");
-        data.put("value", refundOrderCount);
+        data.put("value", MoneyUtil.computePriceScale(refundOrderCount));
         datas.add(data);
         // todo 查询 退款金额
         double refundFee = feeStatisticsImpl.geRefundFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","退款金额");
-        data.put("value", refundFee);
+        data.put("value", MoneyUtil.computePriceScale(refundFee));
         datas.add(data);
 
 
@@ -130,14 +131,14 @@ public class QueryFeeDataReportCmd extends Cmd {
         double chargeFee = feeStatisticsImpl.getChargeFee(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","充电金额");
-        data.put("value", chargeFee);
+        data.put("value", MoneyUtil.computePriceScale(chargeFee));
         datas.add(data);
 
         // todo 查询 月卡金额
         double chargeMonthOrderMoney = orderStatisticsImpl.getChargeMonthOrderCount(queryStatisticsDto);
         data = new JSONObject();
         data.put("name","月卡实收");
-        data.put("value", chargeMonthOrderMoney);
+        data.put("value", MoneyUtil.computePriceScale(chargeMonthOrderMoney));
         datas.add(data);
 
 

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

@@ -14,6 +14,7 @@ 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.MoneyUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -151,7 +152,6 @@ public class QueryReceivedDetailStatisticsCmd extends Cmd {
                     continue;
                 }
                 for (DictDto tDict : dictDtos) {
-                    //feeTypeCd = info.get("feeTypeCd").toString();
                     feeTypeCd = tDict.getStatusCd();
                     if (!info.containsKey(feeTypeCd)) {
                         continue;
@@ -160,7 +160,7 @@ public class QueryReceivedDetailStatisticsCmd extends Cmd {
                     data.put("receivedFee" + feeTypeCd, info.get(feeTypeCd));
                 }
             }
-            data.put("receivedFee", receivedFee.doubleValue());
+            data.put("receivedFee", MoneyUtil.computePriceScale(receivedFee.doubleValue()));
         }
 
         return datas;

+ 9 - 6
service-report/src/main/java/com/java110/report/cmd/dataReport/QueryReceivedStatisticsCmd.java

@@ -9,6 +9,8 @@ import com.java110.dto.report.QueryStatisticsDto;
 import com.java110.report.statistics.IFeeStatistics;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.MoneyUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,7 +66,7 @@ public class QueryReceivedStatisticsCmd extends Cmd {
     }
 
     private List<Map> computeFloorReceivedFee(List<Map> datas) {
-        if (datas == null || datas.size() < 1) {
+        if (ListUtil.isNull(datas)) {
             return new ArrayList<>();
         }
 
@@ -75,22 +77,23 @@ public class QueryReceivedStatisticsCmd extends Cmd {
             }
         }
 
-        if (tmpDatas == null || tmpDatas.size() < 1) {
+        if (ListUtil.isNull(tmpDatas)) {
             return new ArrayList<>();
         }
 
         BigDecimal receivedFee = null;
+        double receivedFeeD = 0;
         for (Map tmpData : tmpDatas) {
             receivedFee = new BigDecimal(0.00);
             for (Map data : datas) {
                 if (!data.get("floorId").toString().equals(tmpData.get("floorId"))) {
                     continue;
                 }
-
-                receivedFee = receivedFee.add(new BigDecimal(data.get("receivedFee").toString()));
-                tmpData.put("receivedFee" + data.get("feeTypeCd").toString(), data.get("receivedFee"));
+                receivedFeeD = Double.parseDouble(data.get("receivedFee").toString());
+                receivedFee = receivedFee.add(new BigDecimal(receivedFeeD + ""));
+                tmpData.put("receivedFee" + data.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(receivedFeeD));
             }
-            tmpData.put("receivedFee", receivedFee.doubleValue());
+            tmpData.put("receivedFee", MoneyUtil.computePriceScale(receivedFee.doubleValue()));
         }
 
         return tmpDatas;

+ 12 - 6
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFeeDetailCarCmd.java

@@ -13,6 +13,7 @@ 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.MoneyUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -118,6 +119,8 @@ public class QueryReportFeeDetailCarCmd extends Cmd {
 
         BigDecimal oweFee = null;
         BigDecimal receivedFee = null;
+        double oweFeeD = 0;
+        double receivedFeeD = 0;
         for (int dataIndex = 0; dataIndex < datas.size(); dataIndex++) {
             oweFee = new BigDecimal(0.00);
             receivedFee = new BigDecimal(0.00);
@@ -127,13 +130,16 @@ public class QueryReportFeeDetailCarCmd extends Cmd {
                     continue;
                 }
 
-                oweFee = oweFee.add(new BigDecimal(info.get("oweFee").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"));
+                oweFeeD = Double.parseDouble(info.get("oweFee").toString());
+                receivedFeeD = Double.parseDouble(info.get("receivedFee").toString());
+
+                oweFee = oweFee.add(new BigDecimal(oweFeeD + ""));
+                receivedFee = receivedFee.add(new BigDecimal(receivedFeeD + ""));
+                data.put("oweFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(oweFeeD));
+                data.put("receivedFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(receivedFeeD));
             }
-            data.put("oweFee", oweFee.doubleValue());
-            data.put("receivedFee", receivedFee.doubleValue());
+            data.put("oweFee", MoneyUtil.computePriceScale(oweFee.doubleValue()));
+            data.put("receivedFee", MoneyUtil.computePriceScale(receivedFee.doubleValue()));
         }
 
         return datas;

+ 12 - 6
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFeeDetailContractCmd.java

@@ -12,6 +12,7 @@ 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.MoneyUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -117,6 +118,8 @@ public class QueryReportFeeDetailContractCmd extends Cmd {
 
         BigDecimal oweFee = null;
         BigDecimal receivedFee = null;
+        double oweFeeD = 0;
+        double receivedFeeD = 0;
         for (int dataIndex = 0; dataIndex < datas.size(); dataIndex++) {
             data = datas.getJSONObject(dataIndex);
             oweFee = new BigDecimal(0.00);
@@ -126,13 +129,16 @@ public class QueryReportFeeDetailContractCmd extends Cmd {
                     continue;
                 }
 
-                oweFee = oweFee.add(new BigDecimal(info.get("oweFee").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"));
+                oweFeeD = Double.parseDouble(info.get("oweFee").toString());
+                receivedFeeD = Double.parseDouble(info.get("receivedFee").toString());
+
+                oweFee = oweFee.add(new BigDecimal(oweFeeD + ""));
+                receivedFee = receivedFee.add(new BigDecimal(receivedFeeD + ""));
+                data.put("oweFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(oweFeeD));
+                data.put("receivedFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(receivedFeeD));
             }
-            data.put("oweFee", oweFee.doubleValue());
-            data.put("receivedFee", receivedFee.doubleValue());
+            data.put("oweFee", MoneyUtil.computePriceScale(oweFee.doubleValue()));
+            data.put("receivedFee", MoneyUtil.computePriceScale(receivedFee.doubleValue()));
         }
 
         return datas;

+ 13 - 6
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFeeDetailOwnerCmd.java

@@ -12,6 +12,7 @@ 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.MoneyUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -107,6 +108,8 @@ public class QueryReportFeeDetailOwnerCmd extends Cmd {
 
         BigDecimal oweFee = null;
         BigDecimal receivedFee = null;
+        double oweFeeD = 0;
+        double receivedFeeD = 0;
         for (int dataIndex = 0; dataIndex < datas.size(); dataIndex++) {
             data = datas.getJSONObject(dataIndex);
             oweFee = new BigDecimal(0.00);
@@ -116,14 +119,18 @@ public class QueryReportFeeDetailOwnerCmd extends Cmd {
                     continue;
                 }
 
-                oweFee = oweFee.add(new BigDecimal(info.get("oweFee").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"));
+                oweFeeD = Double.parseDouble(info.get("oweFee").toString());
+                receivedFeeD = Double.parseDouble(info.get("receivedFee").toString());
+
+                oweFee = oweFee.add(new BigDecimal(oweFeeD + ""));
+                receivedFee = receivedFee.add(new BigDecimal(receivedFeeD + ""));
+                data.put("oweFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(oweFeeD));
+                data.put("receivedFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(receivedFeeD));
                 data.put("objName", info.get("objName"));
+
             }
-            data.put("oweFee", oweFee.doubleValue());
-            data.put("receivedFee", receivedFee.doubleValue());
+            data.put("oweFee", MoneyUtil.computePriceScale(oweFee.doubleValue()));
+            data.put("receivedFee", MoneyUtil.computePriceScale(receivedFee.doubleValue()));
             // todo 处理 收费对象重复问题
             delRepeatObjName(data);
         }

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

@@ -12,6 +12,8 @@ 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.ListUtil;
+import com.java110.utils.util.MoneyUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -70,7 +72,7 @@ public class QueryReportFeeDetailRoomCmd extends Cmd {
         }
 
         // todo 计算 房屋欠费实收数据
-        JSONArray datas = computeRoomOweReceivedFee(rooms,queryStatisticsDto);
+        JSONArray datas = computeRoomOweReceivedFee(rooms, queryStatisticsDto);
 
         ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) queryStatisticsDto.getRow()), count, datas);
 
@@ -85,8 +87,8 @@ public class QueryReportFeeDetailRoomCmd extends Cmd {
      * @param rooms
      * @return
      */
-    private JSONArray computeRoomOweReceivedFee(List<RoomDto> rooms,QueryStatisticsDto queryStatisticsDto) {
-        if (rooms == null || rooms.size() < 1) {
+    private JSONArray computeRoomOweReceivedFee(List<RoomDto> rooms, QueryStatisticsDto queryStatisticsDto) {
+        if (ListUtil.isNull(rooms)) {
             return new JSONArray();
         }
 
@@ -97,39 +99,44 @@ public class QueryReportFeeDetailRoomCmd extends Cmd {
         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());
+            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);
         }
 
         queryStatisticsDto.setObjIds(objIds.toArray(new String[objIds.size()]));
         List<Map> infos = feeStatisticsImpl.getObjFeeSummary(queryStatisticsDto);
 
-        if(infos == null || infos.size() < 1){
+        if (infos == null || infos.size() < 1) {
             return datas;
         }
 
         BigDecimal oweFee = null;
         BigDecimal receivedFee = null;
-        for(int dataIndex = 0; dataIndex < datas.size();dataIndex ++){
+        double oweFeeD = 0;
+        double receivedFeeD = 0;
+        for (int dataIndex = 0; dataIndex < datas.size(); dataIndex++) {
             oweFee = new BigDecimal(0.00);
             receivedFee = new BigDecimal(0.00);
             data = datas.getJSONObject(dataIndex);
-            for(Map info : infos){
-                if(!data.get("roomId").toString().equals(info.get("objId"))){
+            for (Map info : infos) {
+                if (!data.get("roomId").toString().equals(info.get("objId"))) {
                     continue;
                 }
 
-                oweFee = oweFee.add(new BigDecimal(info.get("oweFee").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"));
+                oweFeeD = Double.parseDouble(info.get("oweFee").toString());
+                receivedFeeD = Double.parseDouble(info.get("receivedFee").toString());
+
+                oweFee = oweFee.add(new BigDecimal(oweFeeD + ""));
+                receivedFee = receivedFee.add(new BigDecimal(receivedFeeD + ""));
+                data.put("oweFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(oweFeeD));
+                data.put("receivedFee" + info.get("feeTypeCd").toString(), MoneyUtil.computePriceScale(receivedFeeD));
             }
-            data.put("oweFee",oweFee.doubleValue());
-            data.put("receivedFee",receivedFee.doubleValue());
+            data.put("oweFee", MoneyUtil.computePriceScale(oweFee.doubleValue()));
+            data.put("receivedFee", MoneyUtil.computePriceScale(receivedFee.doubleValue()));
         }
 
         return datas;

+ 7 - 6
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFeeSummaryCmd.java

@@ -11,6 +11,7 @@ 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.MoneyUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -101,15 +102,15 @@ public class QueryReportFeeSummaryCmd extends Cmd {
         int oweRoomCount = feeStatisticsImpl.getOweRoomCount(queryStatisticsDto);
 
         JSONObject data = new JSONObject();
-        data.put("hisOweFee", hisOweFee);
-        data.put("curOweFee", curOweFee);
-        data.put("hisReceivedFee", hisReceivedFee);
-        data.put("preReceivedFee", preReceivedFee);
-        data.put("receivedFee", receivedFee);
+        data.put("hisOweFee", MoneyUtil.computePriceScale(hisOweFee));
+        data.put("curOweFee", MoneyUtil.computePriceScale(curOweFee));
+        data.put("hisReceivedFee", MoneyUtil.computePriceScale(hisReceivedFee));
+        data.put("preReceivedFee", MoneyUtil.computePriceScale(preReceivedFee));
+        data.put("receivedFee", MoneyUtil.computePriceScale(receivedFee));
         data.put("roomCount", roomCount);
         data.put("feeRoomCount", feeRoomCount);
         data.put("oweRoomCount", oweRoomCount);
-        data.put("curReceivableFee", curReceivableFee);
+        data.put("curReceivableFee", MoneyUtil.computePriceScale(curReceivableFee));
 
         JSONArray datas = new JSONArray();
         datas.add(data);