From 720ff83ee560a7cf1873eb6cfe786370428c357a Mon Sep 17 00:00:00 2001 From: yuyang Date: Mon, 12 Sep 2022 17:05:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=91=E6=8E=A7=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XhpcChargingStationController.java | 24 +++ .../XhpcEquipmenMonitorController.java | 70 ++++++++ .../mapper/XhpcEquipmenMonitorMapper.java | 23 +++ .../service/IXhpcChargingStationService.java | 2 + .../service/IXhpcEquipmenMonitorService.java | 28 ++++ .../XhpcChargingStationServiceImpl.java | 54 ++++++ .../XhpcEquipmenMonitorServiceImpl.java | 93 +++++++++++ .../mapper/XhpcEquipmenMonitorMapper.xml | 158 ++++++++++++++++++ .../common/domain/XhpcEquipmenMonitor.java | 29 ++++ .../java/com/xhpc/common/util/Utilitys.java | 41 +++++ 10 files changed, 522 insertions(+) create mode 100644 xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcEquipmenMonitorController.java create mode 100644 xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcEquipmenMonitorMapper.java create mode 100644 xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcEquipmenMonitorService.java create mode 100644 xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcEquipmenMonitorServiceImpl.java create mode 100644 xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcEquipmenMonitorMapper.xml create mode 100644 xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcEquipmenMonitor.java create mode 100644 xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/Utilitys.java diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java index 72109d74..b418f4bd 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java @@ -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 map = new HashMap<>(); + map.put("accessToken","at.35peeqba81hltpja2c32fw8e9fhxwjes-7p2r9zyvtp-1016urx-bkfywfr2z"); + return AjaxResult.success(map); + } } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcEquipmenMonitorController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcEquipmenMonitorController.java new file mode 100644 index 00000000..eb9020f8 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcEquipmenMonitorController.java @@ -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> 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); + } + +} diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcEquipmenMonitorMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcEquipmenMonitorMapper.java new file mode 100644 index 00000000..8f111698 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcEquipmenMonitorMapper.java @@ -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> 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 getequipmenMonitorById(@Param("equipmenMonitorId")Long equipmenMonitorId); + + int insertquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor); + + int updaEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor); +} diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java index af3e9904..8d7b36e6 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java @@ -252,4 +252,6 @@ public interface IXhpcChargingStationService { int insertXhpcRateTime(XhpcRateTime xhpcRateTime); Map activityDiscountTime(Long userId, Date startTime, Integer source, Long chargingStationId, String tenantId); + + AjaxResult getChargingStationMonitor(String chargingStationId); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcEquipmenMonitorService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcEquipmenMonitorService.java new file mode 100644 index 00000000..659a6559 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcEquipmenMonitorService.java @@ -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> list(HttpServletRequest request, String equipmenName, String equipmenNumber, Long chargingStationId); + + AjaxResult getequipmenMonitorById(Long equipmenMonitorId); + + + AjaxResult addEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor); + + AjaxResult remove(Long equipmenMonitorId); +} + + diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index e86e57c5..b00bc6e9 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -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> list =new ArrayList<>(); + +// try{ +// String[] split = chargingStationId.split(","); +// //获取token +// String equipmenToken = redisService.getCacheObject("equipmen:token"); +// Map 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 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"; diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcEquipmenMonitorServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcEquipmenMonitorServiceImpl.java new file mode 100644 index 00000000..f5db3e65 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcEquipmenMonitorServiceImpl.java @@ -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> 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 =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(); + } +} diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcEquipmenMonitorMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcEquipmenMonitorMapper.xml new file mode 100644 index 00000000..cf4c6dd6 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcEquipmenMonitorMapper.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into xhpc_equipmen_monitor + + + equipmen_name, + + + equipmen_number, + + + charging_station_id, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + tenant_id, + + + + + #{equipmenName}, + + + #{equipmenNumber}, + + + #{chargingStationId}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{tenantId}, + + + + + + + update xhpc_equipmen_monitor + + equipmen_name = #{equipmenName}, + equipmen_number = #{equipmenNumber}, + charging_station_id = #{chargingStationId}, + status = #{status}, + del_flag = #{delFlag}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + remark = #{remark}, + + where equipmen_monitor_id = #{equipmenMonitorId} + + diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcEquipmenMonitor.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcEquipmenMonitor.java new file mode 100644 index 00000000..6e256b2e --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcEquipmenMonitor.java @@ -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; + +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/Utilitys.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/Utilitys.java new file mode 100644 index 00000000..d4b985f0 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/Utilitys.java @@ -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 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 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()); + } + } + +}