首页今日充电枪实时状态、今天订单量、今日订电量、今日营收统计
This commit is contained in:
parent
51da3f9416
commit
ae4fee772d
@ -960,7 +960,7 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
|
||||
if(xhpc.getSource()==1){
|
||||
if(xhpc.getSource()!=null && xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
xhpcSt.setOperatorId(xhpc.getOperatorId());
|
||||
|
||||
@ -364,11 +364,17 @@ public class XhpcStatisticsController extends BaseController {
|
||||
* 今日订单量、今日订电量、今日营收、今日充电枪状态
|
||||
*/
|
||||
@GetMapping("/getToday")
|
||||
public void getToday(@RequestParam("operatorId") Long operatorId, @RequestParam("chargingStationId")Long chargingStationId,@RequestParam("chargingPileId")Long chargingPileId)
|
||||
public AjaxResult getToday(Long operatorId,Long chargingStationId,Long chargingPileId)
|
||||
{
|
||||
xhpcStatisticsService.getToday(operatorId,chargingStationId,chargingPileId);
|
||||
return AjaxResult.success(xhpcStatisticsService.getToday(operatorId,chargingStationId,chargingPileId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 今日电枪实时状态
|
||||
*/
|
||||
@GetMapping("/getTodayTerminal")
|
||||
public AjaxResult getTodayTerminal(Long operatorId,Long chargingStationId,Long chargingPileId)
|
||||
{
|
||||
return AjaxResult.success(xhpcStatisticsService.getTodayTerminal(operatorId,chargingStationId,chargingPileId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,14 +183,20 @@ public interface XhpcStatisticsServiceMapper {
|
||||
|
||||
|
||||
//今日订单量
|
||||
Map<String, Object> getTodayStatusNUmber(@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId,@Param("operatorId")Long operatorId, @Param("chargingStationId")Long chargingStationId, @Param("chargingPileId")Long chargingPileId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay);
|
||||
List<Map<String,Object>> getTodayStatusNUmber(@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId,@Param("operatorId")Long operatorId, @Param("chargingStationId")Long chargingStationId, @Param("chargingPileId")Long chargingPileId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay);
|
||||
|
||||
int getTodayNUmber(@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId,@Param("operatorId")Long operatorId, @Param("chargingStationId")Long chargingStationId, @Param("chargingPileId")Long chargingPileId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay);
|
||||
//今日订单量
|
||||
int getTodayDegreeNUmber(@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId,@Param("operatorId")Long operatorId, @Param("chargingStationId")Long chargingStationId, @Param("chargingPileId")Long chargingPileId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay);
|
||||
//今日营收
|
||||
double getTodayAmount(@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId,@Param("operatorId")Long operatorId, @Param("chargingStationId")Long chargingStationId, @Param("chargingPileId")Long chargingPileId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay);
|
||||
|
||||
|
||||
/**
|
||||
* 根据电站获取终端的编号
|
||||
* @param chargingStationId
|
||||
* @return
|
||||
*/
|
||||
List<String> getTerminal(@Param("status") Integer status,@Param("logOperatorId")Long logOperatorId,@Param("operatorId")Long operatorId,@Param("chargingStationId")Long chargingStationId,@Param("chargingPileId")Long chargingPileId,@Param("tenantId")String tenantId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -279,4 +279,9 @@ public interface IXhpcStatisticsService {
|
||||
* 今日订单量、今日订电量、今日营收、今日充电枪状态
|
||||
*/
|
||||
Map<String, Object> getToday(Long operatorId,Long chargingStationId,Long chargingPileId);
|
||||
|
||||
/**
|
||||
* 今日电枪实时状态
|
||||
*/
|
||||
Map<String, Object> getTodayTerminal(Long operatorId,Long chargingStationId,Long chargingPileId);
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.xhpc.common.core.utils.SecurityUtils;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.service.BaseService;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.common.util.UserTypeUtil;
|
||||
import com.xhpc.order.domain.XhpcStatisticsStation;
|
||||
@ -28,6 +29,7 @@ import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -44,6 +46,8 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
|
||||
private IXhpcHistoryOrderService xhpcHistoryOrderService;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getTimeIntervalPage(HttpServletRequest request,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) {
|
||||
@ -1002,7 +1006,7 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
|
||||
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(1, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
map.put("todayDegree",todayDegreeNUmber);
|
||||
//今日营收
|
||||
extracted(operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, logOperatorId);
|
||||
extracted(1,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, logOperatorId);
|
||||
}else{
|
||||
//查询赋值的场站
|
||||
//--------
|
||||
@ -1012,7 +1016,7 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
|
||||
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(2, logUserId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
map.put("todayDegree",todayDegreeNUmber);
|
||||
//今日营收
|
||||
extracted(operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, logUserId);
|
||||
extracted(2,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, logUserId);
|
||||
}
|
||||
}else{
|
||||
//今日订单量
|
||||
@ -1021,28 +1025,106 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
|
||||
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(0, null, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
map.put("todayDegree",todayDegreeNUmber);
|
||||
//今日营收
|
||||
extracted(operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, null);
|
||||
extracted(0,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, null);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private void extracted(Long operatorId, Long chargingStationId, Long chargingPileId, String tenantId, String beginOfDay, String endOfDay, Map<String, Object> map, Long logOperatorId) {
|
||||
double t1 = xhpcStatisticsServiceMapper.getTodayAmount(1, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
double t2 = xhpcStatisticsServiceMapper.getTodayAmount(1, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, DateUtil.formatDateTime(DateUtil.offsetDay(DateUtil.parse(beginOfDay), -1)), DateUtil.formatDateTime(DateUtil.offsetDay(DateUtil.parse(endOfDay), -1)));
|
||||
/**
|
||||
* 今日电枪实时状态
|
||||
*
|
||||
* @param operatorId
|
||||
* @param chargingStationId
|
||||
* @param chargingPileId
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getTodayTerminal(Long operatorId, Long chargingStationId, Long chargingPileId) {
|
||||
|
||||
LoginUser loginUser = tokenService.getLoginUser();
|
||||
String tenantId = loginUser.getTenantId();
|
||||
Long logUserId = SecurityUtils.getUserId();
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
|
||||
Map<String ,Object> map =new HashMap<>();
|
||||
if(tenantId !=null && !"".equals(tenantId)){
|
||||
if(sysUser.getUserId() !=UserTypeUtil.USER_ID){
|
||||
Long logOperatorId = sysUser.getOperatorId();
|
||||
if ("01".equals(sysUser.getUserType())) {
|
||||
//运营商看自己的场站
|
||||
extracted(1,logOperatorId,operatorId, chargingStationId, chargingPileId, tenantId, map);
|
||||
}else{
|
||||
//查询赋值的场站
|
||||
extracted(2,logUserId,operatorId, chargingStationId, chargingPileId, tenantId, map);
|
||||
}
|
||||
}else{
|
||||
//全部桩
|
||||
extracted(0,null,operatorId, chargingStationId, chargingPileId, tenantId, map);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private void extracted(Integer status,Long logOperatorId,Long operatorId, Long chargingStationId, Long chargingPileId, String tenantId, Map<String, Object> map) {
|
||||
List<String> terminal = xhpcStatisticsServiceMapper.getTerminal(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId);
|
||||
|
||||
int offLine =0;//离线
|
||||
int fault =0;//故障
|
||||
int freeTime =0;//空闲
|
||||
int charge =0;//充电
|
||||
int unknown =0;//未知
|
||||
if(terminal !=null && terminal.size()>0){
|
||||
for (String st:terminal) {
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("gun:" + st);
|
||||
if(!cacheMap.isEmpty()){
|
||||
if (cacheMap.containsKey("status") &&
|
||||
"离线".equals(cacheMap.get("status").toString())){
|
||||
offLine++;
|
||||
}else if(cacheMap.containsKey("status") &&
|
||||
"故障".equals(cacheMap.get("status").toString())){
|
||||
fault++;
|
||||
}else if(cacheMap.containsKey("status") &&
|
||||
"空闲".equals(cacheMap.get("status").toString())){
|
||||
freeTime++;
|
||||
}else{
|
||||
charge++;
|
||||
}
|
||||
}else{
|
||||
unknown++;
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("offLine",offLine);
|
||||
map.put("fault",fault);
|
||||
map.put("freeTime",freeTime);
|
||||
map.put("charge",charge);
|
||||
map.put("unknown",unknown);
|
||||
}
|
||||
|
||||
private void extracted(Integer status,Long operatorId, Long chargingStationId, Long chargingPileId, String tenantId, String beginOfDay, String endOfDay, Map<String, Object> map, Long logOperatorId) {
|
||||
double t1 = xhpcStatisticsServiceMapper.getTodayAmount(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
double t2 = xhpcStatisticsServiceMapper.getTodayAmount(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, DateUtil.formatDateTime(DateUtil.offsetDay(DateUtil.parse(beginOfDay), -1)), DateUtil.formatDateTime(DateUtil.offsetDay(DateUtil.parse(endOfDay), -1)));
|
||||
BigDecimal divide1 = new BigDecimal(t1 - t2).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
||||
BigDecimal divide2 = new BigDecimal(t2 - t1).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
||||
Map<String, Object> map1 =new HashMap<>();
|
||||
map1.put("todayAmount",t1);
|
||||
map1.put("yesterdayAmount",t2);
|
||||
map1.put("weekNumber",t1-t2>0?(t1-t2)/t1:(t2-t1)/t1);
|
||||
map1.put("weekNumber",t1-t2>0?divide1:divide2);
|
||||
map1.put("type",t1-t2>0?true:false);
|
||||
map.put("todayAmount", map1);
|
||||
}
|
||||
|
||||
private void extracted(Integer status, Long operatorId, Long chargingStationId, Long chargingPileId, String tenantId, String beginOfDay, String endOfDay, String lastBeginOfDay, String lastEndOfDay, String weekBeginOfDay, String weekEndOfDay, Map<String, Object> map, Long logOperatorId) {
|
||||
Map<String, Object> todayStatusNUmber = xhpcStatisticsServiceMapper.getTodayStatusNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
List<Map<String,Object>> list = xhpcStatisticsServiceMapper.getTodayStatusNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
|
||||
int t1 = xhpcStatisticsServiceMapper.getTodayNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, lastBeginOfDay, lastEndOfDay);
|
||||
int t2 = xhpcStatisticsServiceMapper.getTodayNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, weekBeginOfDay, weekEndOfDay);
|
||||
todayStatusNUmber.put("weekNumber",t1-t2>0?(t1-t2)/t1:(t2-t1)/t1);
|
||||
map.put("todayOrder",todayStatusNUmber);
|
||||
Map<String,Object> todayStatusNUmber = new HashMap<>();
|
||||
BigDecimal divide1 = new BigDecimal(t1 - t2).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
||||
BigDecimal divide2 = new BigDecimal(t2 - t1).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
||||
todayStatusNUmber.put("weekNumber",t1-t2>0?divide1:divide2);
|
||||
todayStatusNUmber.put("type",t1-t2>0?true:false);
|
||||
map.put("todayOrder",list);
|
||||
map.put("todayOrderWeek",todayStatusNUmber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -927,8 +927,14 @@
|
||||
|
||||
<select id="getTodayStatusNUmber" resultType="map">
|
||||
SELECT
|
||||
COUNT(status) number,
|
||||
status,
|
||||
COUNT(status) value,
|
||||
case when status=-1 then "无效订单"
|
||||
when status=0 then "充电中订单"
|
||||
when status=1 then "自动结算订单"
|
||||
when status=2 then "异常订单"
|
||||
when status=3 then "平台结算订单"
|
||||
else "其他订单"
|
||||
end name
|
||||
FROM
|
||||
xhpc_charge_order
|
||||
WHERE
|
||||
@ -956,7 +962,7 @@
|
||||
|
||||
<select id="getTodayNUmber" resultType="int">
|
||||
SELECT
|
||||
COUNT(charge_order_id) number,
|
||||
COUNT(charge_order_id) number
|
||||
FROM
|
||||
xhpc_charge_order
|
||||
WHERE
|
||||
@ -983,12 +989,12 @@
|
||||
|
||||
<select id="getTodayDegreeNUmber" resultType="int">
|
||||
SELECT
|
||||
COUNT(charging_degree) number,
|
||||
sum(total_power) number
|
||||
FROM
|
||||
xhpc_charge_order
|
||||
xhpc_history_order
|
||||
WHERE
|
||||
create_time >=#{beginOfDay} and create_time <= #{endOfDay}
|
||||
<if test="operatorId !=null">
|
||||
end_time >=#{beginOfDay} and end_time <= #{endOfDay}
|
||||
<if test="operatorId !=null and operatorId !=''">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
|
||||
</if>
|
||||
<if test="tenantId !=null and tenantId !=''">
|
||||
@ -1010,12 +1016,12 @@
|
||||
|
||||
<select id="getTodayAmount" resultType="double">
|
||||
SELECT
|
||||
COUNT(amount_charged) number,
|
||||
IFNULL(sum(total_price),0) number
|
||||
FROM
|
||||
xhpc_charge_order
|
||||
xhpc_history_order
|
||||
WHERE
|
||||
create_time >=#{beginOfDay} and create_time <= #{endOfDay}
|
||||
<if test="operatorId !=null">
|
||||
end_time >=#{beginOfDay} and end_time <= #{endOfDay}
|
||||
<if test="operatorId !=null and ''!=operatorId">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
|
||||
</if>
|
||||
<if test="tenantId !=null and tenantId !=''">
|
||||
@ -1035,5 +1041,27 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getTerminal" resultType="String">
|
||||
select serial_number as serialNumber
|
||||
from xhpc_terminal
|
||||
where del_flag = 0
|
||||
<if test="operatorId !=null and ''!=operatorId">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
|
||||
</if>
|
||||
<if test="tenantId !=null and tenantId !=''">
|
||||
and tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="chargingStationId !=null">
|
||||
and charging_station_id=#{chargingStationId}
|
||||
</if>
|
||||
<if test="chargingPileId !=null">
|
||||
and charging_pile_id=#{chargingPileId}
|
||||
</if>
|
||||
<if test="status==1">
|
||||
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
|
||||
</if>
|
||||
<if test="status==2">
|
||||
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user