|
@@ -269,17 +269,22 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
|
|
|
//当天总消耗
|
|
|
JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate,nowDate,nowHour,userSet);
|
|
|
- resultMap.put("todayCost",jsonObjectNow.getString("totalCost"));
|
|
|
+ resultMap.put("todayCost",Check.isNull(jsonObjectNow.getString("totalCost")) ? "0" : jsonObjectNow.getString("totalCost"));
|
|
|
//昨天同时段总消耗
|
|
|
JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time,time,nowHour,userSet);
|
|
|
|
|
|
//今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
|
|
|
- Double d = (Double.valueOf(jsonObjectNow.getString("totalCost")) - Double.valueOf(jsonObjectYesterday.getString("totalCost"))) / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
|
|
|
+ Double d = new Double("0");
|
|
|
+ if (!Check.isNull( jsonObjectNow.getString("totalCost")) && !Check.isNull(jsonObjectYesterday.getString("totalCost"))){
|
|
|
+ d = (Double.valueOf(jsonObjectNow.getString("totalCost"))
|
|
|
+ - Double.valueOf(jsonObjectYesterday.getString("totalCost")))
|
|
|
+ / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
|
|
|
+ }
|
|
|
resultMap.put("todayCompare",decimalFormat.format(d));
|
|
|
|
|
|
//所选时段消耗
|
|
|
JSONObject timeNowCost = materialStareMapper.getKuaiShouTotalCostDaily(stratDate,endDate,userSet);
|
|
|
- resultMap.put("timeCost",timeNowCost.getString("totalCost"));
|
|
|
+ resultMap.put("timeCost",Check.isNull(timeNowCost.getString("totalCost")) ? "0" : timeNowCost.getString("totalCost"));
|
|
|
//上阶段时间
|
|
|
Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
|
|
|
long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
@@ -288,7 +293,11 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//上阶段消耗
|
|
|
JSONObject timeLastCost = materialStareMapper.getKuaiShouTotalCostDaily(lastTimeStart,lastTimeEnd,userSet);
|
|
|
//环比 = (当前总消耗 - 上阶段总消耗 ) / 上阶段总消耗
|
|
|
- Double timeCompare = (Double.valueOf(timeNowCost.getString("totalCost")) - Double.valueOf(timeLastCost.getString("totalCost"))) / Double.valueOf(timeLastCost.getString("totalCost"));
|
|
|
+ Double timeCompare = new Double("0");
|
|
|
+ if (!Check.isNull(timeNowCost.getString("totalCost")) && !Check.isNull(timeLastCost.getString("totalCost"))){
|
|
|
+ timeCompare = (Double.valueOf(timeNowCost.getString("totalCost")) - Double.valueOf(timeLastCost.getString("totalCost"))) / Double.valueOf(timeLastCost.getString("totalCost"));
|
|
|
+ }
|
|
|
+
|
|
|
resultMap.put("timeCompare",decimalFormat.format(timeCompare));
|
|
|
|
|
|
//当前月份的框返 和 激励
|
|
@@ -296,13 +305,19 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long monthFirstDay = Long.valueOf(DateUtils.getFirstDayByMonth());
|
|
|
//框返 激励
|
|
|
JSONObject nowMonthCost = materialStareMapper.getKuaiShouAccountCharged(monthFirstDay,nowDate,userSet);
|
|
|
- resultMap.put("directCharged",nowMonthCost.getString("directCharged"));//框返
|
|
|
- resultMap.put("contractCharged",nowMonthCost.getString("contractCharged"));//激励
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ resultMap.put("directCharged",Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("directCharged"));//框返
|
|
|
+ resultMap.put("contractCharged",Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("contractCharged"));//激励
|
|
|
|
|
|
//当前月消耗
|
|
|
JSONObject monthCost = materialStareMapper.getKuaiShouAccountCostMonth(userId, monthFirstDay,nowDate);
|
|
|
resultMap.put("monthCost",Check.isNull(monthCost) ? "0" : monthCost.getString("cost"));
|
|
|
- resultMap.put("userName",Check.isNull(monthCost) ? "-" : monthCost.getString("userName"));
|
|
|
+
|
|
|
+ //用户
|
|
|
+ JSONObject userName = materialStareMapper.getKuaiShouUserByUserId(userId);
|
|
|
+ resultMap.put("userName",Check.isNull(userName) ? "-" : userName.getString("userName"));
|
|
|
|
|
|
|
|
|
//公司 组内排名
|