|
@@ -346,21 +346,30 @@ public class SysManagerCompanyServiceImpl extends ServiceImpl<SysManagerCompanyM
|
|
|
JSONObject cost = mapper.queryTtRealTimeCost(companyId, today, lastDay, hour);
|
|
|
Double todayCost = cost.getDouble("todayCost");
|
|
|
Double yesCost = cost.getDouble("yesCost");
|
|
|
- BigDecimal costRatio = BigDecimal.valueOf((todayCost - yesCost) / yesCost).multiply(hundred);
|
|
|
- String costRatioStr = costRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ String costRatioStr = null;
|
|
|
+ if (checkNumberIsNull(yesCost)) {
|
|
|
+ BigDecimal costRatio = BigDecimal.valueOf((todayCost - yesCost) / yesCost).multiply(hundred);
|
|
|
+ costRatioStr = costRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ }
|
|
|
//查询广告组数
|
|
|
JSONObject group = mapper.queryTtRealTimeGroupNum(companyId, today, lastDay);
|
|
|
Long groupNum = group.getLong("todayNum");
|
|
|
Double yesNum = group.getDouble("yesNum");
|
|
|
- BigDecimal unitRatio = BigDecimal.valueOf((groupNum - yesNum) / yesNum).multiply(hundred);
|
|
|
- String unitRatioStr = unitRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ String unitRatioStr = null;
|
|
|
+ if (checkNumberIsNull(yesNum)) {
|
|
|
+ BigDecimal unitRatio = BigDecimal.valueOf((groupNum - yesNum) / yesNum).multiply(hundred);
|
|
|
+ unitRatioStr = unitRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ }
|
|
|
|
|
|
//查询素材数
|
|
|
JSONObject material = mapper.queryTtRealTimeMaterialNum(companyId, userIds, today, lastDay);
|
|
|
Long materialNum = material.getLong("todayCount");
|
|
|
Double yesCount = material.getDouble("yesCount");
|
|
|
- BigDecimal materialRatio = BigDecimal.valueOf((materialNum - yesCount) / yesCount).multiply(hundred);
|
|
|
- String materialRatioStr = materialRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ String materialRatioStr = null;
|
|
|
+ if (checkNumberIsNull(yesCount)) {
|
|
|
+ BigDecimal materialRatio = BigDecimal.valueOf((materialNum - yesCount) / yesCount).multiply(hundred);
|
|
|
+ materialRatioStr = materialRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ }
|
|
|
|
|
|
List<JSONObject> operateList = mapper.queryDepartByParentId(company.getTtOperateId());
|
|
|
if (Check.isNull(list) || list.isEmpty()) {
|
|
@@ -397,21 +406,29 @@ public class SysManagerCompanyServiceImpl extends ServiceImpl<SysManagerCompanyM
|
|
|
JSONObject cost = mapper.queryKsRealTimeCost(companyId, today, lastDay, hour);
|
|
|
Double todayCost = cost.getDouble("todayCost");
|
|
|
Double yesCost = cost.getDouble("yesCost");
|
|
|
- BigDecimal costRatio = BigDecimal.valueOf((todayCost - yesCost) / yesCost).multiply(hundred);
|
|
|
- String costRatioStr = costRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ String costRatioStr = null;
|
|
|
+ if (checkNumberIsNull(yesCost)) {
|
|
|
+ BigDecimal costRatio = BigDecimal.valueOf((todayCost - yesCost) / yesCost).multiply(hundred);
|
|
|
+ costRatioStr = costRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ }
|
|
|
//查询广告组数
|
|
|
JSONObject group = mapper.queryKsRealTimeGroupNum(companyId, today, lastDay);
|
|
|
Long groupNum = group.getLong("todayNum");
|
|
|
Double yesNum = group.getDouble("yesNum");
|
|
|
- BigDecimal unitRatio = BigDecimal.valueOf((groupNum - yesNum) / yesNum).multiply(hundred);
|
|
|
- String unitRatioStr = unitRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
-
|
|
|
+ String unitRatioStr = null;
|
|
|
+ if (checkNumberIsNull(yesNum)) {
|
|
|
+ BigDecimal unitRatio = BigDecimal.valueOf((groupNum - yesNum) / yesNum).multiply(hundred);
|
|
|
+ unitRatioStr = unitRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ }
|
|
|
//查询素材数
|
|
|
JSONObject material = mapper.queryKsRealTimeMaterialNum(companyId, userIds, today, lastDay);
|
|
|
Long materialNum = material.getLong("todayCount");
|
|
|
Double yesCount = material.getDouble("yesCount");
|
|
|
- BigDecimal materialRatio = BigDecimal.valueOf((materialNum - yesCount) / yesCount).multiply(hundred);
|
|
|
- String materialRatioStr = materialRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ String materialRatioStr = null;
|
|
|
+ if (checkNumberIsNull(yesCount)) {
|
|
|
+ BigDecimal materialRatio = BigDecimal.valueOf((materialNum - yesCount) / yesCount).multiply(hundred);
|
|
|
+ materialRatioStr = materialRatio.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ }
|
|
|
|
|
|
List<JSONObject> operateList = mapper.queryDepartByParentId(company.getKsOperateId());
|
|
|
if (Check.isNull(list) || list.isEmpty()) {
|
|
@@ -457,4 +474,19 @@ public class SysManagerCompanyServiceImpl extends ServiceImpl<SysManagerCompanyM
|
|
|
obj.put("totalConsume", totalConsume);
|
|
|
return Result.ok(obj);
|
|
|
}
|
|
|
+
|
|
|
+ private boolean checkNumberIsNull(double number) {
|
|
|
+ if (Check.isNull(number)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ double b = 0.0;
|
|
|
+ BigDecimal number1 = new BigDecimal(number);
|
|
|
+ BigDecimal number2 = new BigDecimal(b);
|
|
|
+ int result = number1.compareTo(number2);
|
|
|
+ if (result == 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|