增加监控设备列表

This commit is contained in:
yuyang 2022-09-12 17:05:09 +08:00
parent 9d425130e3
commit 720ff83ee5
10 changed files with 522 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -219,4 +220,27 @@ public class XhpcChargingStationController extends BaseController {
return xhpcChargingStationService.updateXhpcRateTime(request, xhpcChargingStationDto);
}
/**
* 场站监控列表
*
* @param chargingStationId
* @return
*/
@GetMapping(value = "/getChargingStationMonitor")
public AjaxResult getChargingStationMonitor(String chargingStationId) {
return xhpcChargingStationService.getChargingStationMonitor(chargingStationId);
}
/**
* 场站监控Token
*
* @return
*/
@GetMapping(value = "/getChargingStationEquipmenToken")
public AjaxResult getChargingStationEquipmenToken() {
Map<String, Object> map = new HashMap<>();
map.put("accessToken","at.35peeqba81hltpja2c32fw8e9fhxwjes-7p2r9zyvtp-1016urx-bkfywfr2z");
return AjaxResult.success(map);
}
}

View File

@ -0,0 +1,70 @@
package com.xhpc.charging.station.controller;
import com.xhpc.charging.station.service.IXhpcEquipmenMonitorService;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.domain.XhpcChargingPile;
import com.xhpc.common.domain.XhpcEquipmenMonitor;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/9/12 10:57
*/
@RestController
@RequestMapping("/equipmenMonitor")
public class XhpcEquipmenMonitorController extends BaseController {
@Resource
private IXhpcEquipmenMonitorService xhpcEquipmenMonitorService;
/**
* 列表
* @return
*/
@GetMapping("/list")
public TableDataInfo list(HttpServletRequest request, String equipmenName, String equipmenNumber, Long chargingStationId) {
startPage();
List<Map<String, Object>> list = xhpcEquipmenMonitorService.list(request,equipmenName,equipmenNumber,chargingStationId);
return getDataTable(list);
}
/**
* 详情
*
* @return
*/
@GetMapping(value = "/getequipmenMonitorById")
public AjaxResult getequipmenMonitorById(@RequestParam(value = "equipmenMonitorId") Long equipmenMonitorId) {
return xhpcEquipmenMonitorService.getequipmenMonitorById(equipmenMonitorId);
}
/**
* 新增
*
* @return
*/
@PostMapping(value = "/addEquipmenMonitor")
public AjaxResult addEquipmenMonitor(@RequestBody XhpcEquipmenMonitor xhpcEquipmenMonitor) {
return xhpcEquipmenMonitorService.addEquipmenMonitor(xhpcEquipmenMonitor);
}
@DeleteMapping("/{equipmenMonitorId}")
public AjaxResult remove(@PathVariable Long equipmenMonitorId) {
return xhpcEquipmenMonitorService.remove(equipmenMonitorId);
}
}

View File

@ -0,0 +1,23 @@
package com.xhpc.charging.station.mapper;
import com.xhpc.common.domain.XhpcEquipmenMonitor;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/9/12 11:07
*/
public interface XhpcEquipmenMonitorMapper {
List<Map<String, Object>> list(@Param("number") Integer number, @Param("logOperatorId")Long logOperatorId, @Param("tenantId")String tenantId,@Param("chargingStationId")Long chargingStationId,@Param("equipmenName")String equipmenName,@Param("equipmenNumber")String equipmenNumber);
Map<String, Object> getequipmenMonitorById(@Param("equipmenMonitorId")Long equipmenMonitorId);
int insertquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor);
int updaEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor);
}

View File

@ -252,4 +252,6 @@ public interface IXhpcChargingStationService {
int insertXhpcRateTime(XhpcRateTime xhpcRateTime);
Map<String,Object> activityDiscountTime(Long userId, Date startTime, Integer source, Long chargingStationId, String tenantId);
AjaxResult getChargingStationMonitor(String chargingStationId);
}

View File

@ -0,0 +1,28 @@
package com.xhpc.charging.station.service;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcEquipmenMonitor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/9/12 10:55
*/
public interface IXhpcEquipmenMonitorService {
List<Map<String, Object>> list(HttpServletRequest request, String equipmenName, String equipmenNumber, Long chargingStationId);
AjaxResult getequipmenMonitorById(Long equipmenMonitorId);
AjaxResult addEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor);
AjaxResult remove(Long equipmenMonitorId);
}

View File

@ -2,6 +2,8 @@ package com.xhpc.charging.station.service;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xhpc.charging.station.dto.XhpcActivityDiscountDto;
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
import com.xhpc.charging.station.mapper.XhpcChargingStationPushStatusMapper;
@ -21,6 +23,7 @@ import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.LogUserUtils;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.common.util.Utilitys;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import org.slf4j.Logger;
@ -34,9 +37,11 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 电站Service业务层处理
*
@ -1542,6 +1547,55 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return map;
}
@Override
public AjaxResult getChargingStationMonitor(String chargingStationId) {
List<Map<String, Object>> list =new ArrayList<>();
// try{
// String[] split = chargingStationId.split(",");
// //获取token
// String equipmenToken = redisService.getCacheObject("equipmen:token");
// Map<String, String> rm = new HashMap<>();
// rm.put("appKey", "e87d64ac7c424d7bb37830055a21b57a");
// rm.put("appSecret", "85d3ea44e86f940ac8274b43f6703803");
//
// if(equipmenToken ==null || "".equals(equipmenToken)){
// String resp = Utilitys.doPost("https://open.ys7.com/api/lapp/token/get", null, null, rm);
// JSONObject jsonObject = JSON.parseObject(resp);
// System.out.println("==========jsonObject============");
// System.out.println("==========jsonObject============"+jsonObject.toString());
// System.out.println("==========jsonObject============");
// JSONObject data = jsonObject.getJSONObject("data");
// String accessToken = data.getString("accessToken");
// //String expireTime = data.getString("expireTime");
// redisService.setCacheObject("equipmen:token",accessToken,259200L, TimeUnit.SECONDS);
// }
// if(chargingStationId ==null || chargingStationId.length()==0 || "".equals(chargingStationId)){
// //所有场站
// }else{
// for (int i = 0; i <split.length ; i++) {
//
// }
// }
//
// }catch (Exception e){
//
// return AjaxResult.error("场站id错误");
// }
Map<String, Object> map = new HashMap<>();
map.put("chargingStationId",1);
map.put("equipmentNumber","C41675932");
map.put("equipmentName","公司内部监控");
map.put("url","ezopen://open.ys7.com/C41675932/1.hd.live");
list.add(map);
return AjaxResult.success(list);
}
public static void main(String[] args) {
String st="14:30:00";

View File

@ -0,0 +1,93 @@
package com.xhpc.charging.station.service;
import com.xhpc.charging.station.mapper.XhpcEquipmenMonitorMapper;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcEquipmenMonitor;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/9/12 10:56
*/
@Service
public class XhpcEquipmenMonitorServiceImpl implements IXhpcEquipmenMonitorService{
@Resource
private TokenService tokenService;
@Resource
private XhpcEquipmenMonitorMapper xhpcEquipmenMonitorMapper;
@Override
public List<Map<String, Object>> list(HttpServletRequest request, String equipmenName, String equipmenNumber, Long chargingStationId) {
LoginUser loginUser = tokenService.getLoginUser();
String tenantId = loginUser.getTenantId();
Long logUserId = SecurityUtils.getUserId();
SysUser sysUser = loginUser.getSysUser();
List<Map<String, Object>> map =new ArrayList<>();
if(tenantId !=null && !"".equals(tenantId)){
if(UserTypeUtil.SYS_USER_TYPE_FOUR.equals(sysUser.getUserType())){
//运维管理人员
}else{
if(sysUser.getUserId() !=UserTypeUtil.USER_ID){
Long logOperatorId = sysUser.getOperatorId();
if ("01".equals(sysUser.getUserType())) {
//运营商看自己的场站
map = xhpcEquipmenMonitorMapper.list(1,logOperatorId,tenantId,chargingStationId,equipmenName,equipmenNumber);
}else{
//查询赋值的场站
map = xhpcEquipmenMonitorMapper.list(2,logUserId,tenantId,chargingStationId,equipmenName,equipmenNumber);
}
}else{
//全部桩
map = xhpcEquipmenMonitorMapper.list(0,null,tenantId,chargingStationId,equipmenName,equipmenNumber);
}
}
}
return map;
}
@Override
public AjaxResult getequipmenMonitorById(Long equipmenMonitorId) {
return AjaxResult.success(xhpcEquipmenMonitorMapper.getequipmenMonitorById(equipmenMonitorId));
}
@Override
public AjaxResult addEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor) {
LoginUser loginUser = tokenService.getLoginUser();
String tenantId = loginUser.getTenantId();
if(xhpcEquipmenMonitor.getEquipmenMonitorId() ==null){
xhpcEquipmenMonitor.setTenantId(tenantId);
xhpcEquipmenMonitorMapper.insertquipmenMonitor(xhpcEquipmenMonitor);
}else{
xhpcEquipmenMonitorMapper.updaEquipmenMonitor(xhpcEquipmenMonitor);
}
return AjaxResult.success();
}
@Override
public AjaxResult remove(Long equipmenMonitorId) {
XhpcEquipmenMonitor xhpcEquipmenMonitor = new XhpcEquipmenMonitor();
xhpcEquipmenMonitor.setEquipmenMonitorId(equipmenMonitorId);
xhpcEquipmenMonitor.setDelFlag(2);
int i = xhpcEquipmenMonitorMapper.updaEquipmenMonitor(xhpcEquipmenMonitor);
if (i > 0) {
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--suppress SqlDialectInspection -->
<mapper namespace="com.xhpc.charging.station.mapper.XhpcEquipmenMonitorMapper">
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcEquipmenMonitor">
<result property="equipmenMonitorId" column="equipmen_monitor_id"/>
<result property="equipmenName" column="equipmen_name"/>
<result property="equipmenNumber" column="equipmen_number"/>
<result property="status" column="status"/>
<result property="delFlag" column="del_flag"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="remark" column="remark"/>
<result property="tenantId" column="tenant_id"/>
<result property="chargingStationId" column="charging_station_id"/>
</resultMap>
<select id="list" resultType="java.util.Map">
select
xem.equipmen_monitor_id as equipmenMonitorId,
xem.equipmen_name as equipmenName,
xem.equipmen_number as equipmenNumber,
st.name as chargingStationName,
xem.create_time as createTime
from xhpc_equipmen_monitor as xem
left join xhpc_charging_station as st on st.charging_station_id =xem.charging_station_id
where xem.del_flag =0
<if test="equipmenName !=null and equipmenName !=''">
and xem.equipmen_name like CONCAT('%',#{equipmenName},'%')
</if>
<if test="equipmenNumber !=null and equipmenNumber !=''">
and xem.equipmen_number like CONCAT('%',#{equipmenNumber},'%')
</if>
<if test="chargingStationId !=null and chargingStationId!=''">
and xem.charging_station_id=#{chargingStationId}
</if>
<if test="number !=0 and number ==1">
and xem.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test="number !=0 and number ==2">
and xem.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
<if test="tenantId !=null and tenantId !=''">
and xem.tenant_id=#{tenantId}
</if>
order by xem.create_time desc
</select>
<select id="getequipmenMonitorById" resultType="map">
select
equipmen_monitor_id as equipmenMonitorId,
equipmen_name as equipmenName,
equipmen_number as equipmenNumber,
charging_station_id as chargingStationId,
create_time as createTime
from xhpc_equipmen_monitor where equipmen_monitor_id =#{equipmenMonitorId}
</select>
<insert id="insertquipmenMonitor" parameterType="com.xhpc.common.domain.XhpcEquipmenMonitor" useGeneratedKeys="true"
keyProperty="equipmenMonitorId">
insert into xhpc_equipmen_monitor
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != equipmenName and equipmenName!='' ">
equipmen_name,
</if>
<if test="null != equipmenNumber and equipmenNumber!='' ">
equipmen_number,
</if>
<if test="null != chargingStationId ">
charging_station_id,
</if>
<if test="null != status ">
status,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != tenantId ">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != equipmenName and equipmenName!='' ">
#{equipmenName},
</if>
<if test="null != equipmenNumber and equipmenNumber ">
#{equipmenNumber},
</if>
<if test="null != chargingStationId ">
#{chargingStationId},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != tenantId ">
#{tenantId},
</if>
</trim>
</insert>
<update id="updaEquipmenMonitor" parameterType="Integer">
update xhpc_equipmen_monitor
<trim prefix="SET" suffixOverrides=",">
<if test="equipmenName != null">equipmen_name = #{equipmenName},</if>
<if test="equipmenNumber != null">equipmen_number = #{equipmenNumber},</if>
<if test="chargingStationId != null">charging_station_id = #{chargingStationId},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where equipmen_monitor_id = #{equipmenMonitorId}
</update>
</mapper>

View File

@ -0,0 +1,29 @@
package com.xhpc.common.domain;
import com.xhpc.common.core.web.domain.BaseEntity;
import lombok.Data;
/**
* @author yuyang
* @date 2022/9/12 10:51
*/
@Data
public class XhpcEquipmenMonitor extends BaseEntity {
private Long equipmenMonitorId;
private Long chargingStationId;
private String equipmenName;
private String equipmenNumber;
/** 状态0正常 1停用 */
private Integer status;
/** 删除标志0代表存在 2代表删除 */
private Integer delFlag;
private String tenantId;
}

View File

@ -0,0 +1,41 @@
package com.xhpc.common.util;
import co.intella.crypto.AesCryptoUtil;
import co.intella.crypto.KeyReader;
import co.intella.net.Constant;
import co.intella.net.HttpRequestUtil;
import javax.crypto.SecretKey;
import java.io.InputStream;
import java.security.PublicKey;
import java.util.Map;
public class Utilitys {
public static String doRequest(String url, InputStream rsaPubKeyStream, Map<String, String> requestMap) {
try {
PublicKey rsaPubKey = KeyReader.loadPublicKeyFromDER(rsaPubKeyStream);
SecretKey aesKey = AesCryptoUtil.generateSecreteKey();
return doPost(url, rsaPubKey, aesKey, requestMap);
} catch (Exception e) {
e.printStackTrace();
return String.format("{\"Header\": {\"StatusCode\": \"9000\",\"StatusDesc\": \"%s\"}}", e.getMessage());
}
}
public static String doPost(String url, PublicKey rsaPubKey, SecretKey aesKey, Map<String, String> requestMap) {
try {
String _response = HttpRequestUtil.httpsPost(url, requestMap, rsaPubKey, aesKey);
return AesCryptoUtil.decryptResponse(aesKey, Constant.IV, _response);
} catch (Exception e) {
e.printStackTrace();
return String.format("{\"Header\": {\"StatusCode\": \"9000\",\"StatusDesc\": \"%s\"}}", e.getMessage());
}
}
}