修改场站监控、版本号管理

This commit is contained in:
yuyang 2022-09-27 16:00:23 +08:00
parent 94ae833b82
commit 97445c7f50
11 changed files with 98 additions and 132 deletions

View File

@ -71,7 +71,7 @@ public class XhpcEquipmenMonitorController extends BaseController {
* @return * @return
*/ */
@GetMapping(value = "/getChargingStationMonitor") @GetMapping(value = "/getChargingStationMonitor")
public AjaxResult getChargingStationMonitor(String chargingStationId) { public AjaxResult getChargingStationMonitor(Long chargingStationId) {
return xhpcEquipmenMonitorService.getChargingStationMonitor(chargingStationId); return xhpcEquipmenMonitorService.getChargingStationMonitor(chargingStationId);
} }

View File

@ -20,4 +20,6 @@ public interface XhpcEquipmenMonitorMapper {
int insertquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor); int insertquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor);
int updaEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor); int updaEquipmenMonitor(XhpcEquipmenMonitor xhpcEquipmenMonitor);
List<XhpcEquipmenMonitor> getChargingStationId(@Param("chargingStationId")Long chargingStationId);
} }

View File

@ -26,4 +26,6 @@ public interface XhpcPileEditionMapper {
int insertXhpcPileEdition(XhpcPileEdition xhpcPileEdition); int insertXhpcPileEdition(XhpcPileEdition xhpcPileEdition);
int updatePileEdition(XhpcPileEdition xhpcPileEdition); int updatePileEdition(XhpcPileEdition xhpcPileEdition);
XhpcPileEdition getXhpcPileEditionById(@Param("pileEditionId")Long pileEditionId);
} }

View File

@ -2,8 +2,6 @@ package com.xhpc.charging.station.service;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcEquipmenMonitor; 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 javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
@ -24,7 +22,7 @@ public interface IXhpcEquipmenMonitorService {
AjaxResult remove(Long equipmenMonitorId); AjaxResult remove(Long equipmenMonitorId);
AjaxResult getChargingStationMonitor(String chargingStationId); AjaxResult getChargingStationMonitor(Long chargingStationId);
AjaxResult getChargingStationEquipmenToken(); AjaxResult getChargingStationEquipmenToken();
} }

View File

@ -102,15 +102,28 @@ public class XhpcEquipmenMonitorServiceImpl implements IXhpcEquipmenMonitorServi
} }
@Override @Override
public AjaxResult getChargingStationMonitor(String chargingStationId) { public AjaxResult getChargingStationMonitor(Long chargingStationId) {
List<Map<String, Object>> list =new ArrayList<>();
Map<String, Object> map = new HashMap<>(); //获取设备列表
map.put("chargingStationId",1); List<Map<String, Object>> listMap =new ArrayList<>();
map.put("equipmentNumber","C41675932"); List<XhpcEquipmenMonitor> list = xhpcEquipmenMonitorMapper.getChargingStationId(chargingStationId);
map.put("equipmentName","公司内部监控"); //获取token
map.put("url","ezopen://open.ys7.com/C41675932/1.hd.live"); String equipmenToken = getEquipmenToken();
list.add(map); for (int i = 0; i <list.size() ; i++) {
return AjaxResult.success(list); XhpcEquipmenMonitor xhpcEquipmenMonitor = list.get(i);
Map<String, Object> map = new HashMap<>();
String equipmenNumber = xhpcEquipmenMonitor.getEquipmenNumber();
String equipmenName = xhpcEquipmenMonitor.getEquipmenName();
map.put("chargingStationId",xhpcEquipmenMonitor.getChargingStationId());
map.put("equipmentNumber",equipmenNumber);
map.put("equipmentName",equipmenName);
String equipmenUrl = getEquipmenUrl(equipmenToken, equipmenNumber, "1");
if(equipmenUrl !=null && !"".equals(equipmenUrl)){
map.put("url",equipmenUrl);
listMap.add(map);
}
}
return AjaxResult.success(listMap);
} }
@Override @Override
@ -118,68 +131,50 @@ public class XhpcEquipmenMonitorServiceImpl implements IXhpcEquipmenMonitorServi
try{ try{
//获取token //获取token
String equipmenToken = redisService.getCacheObject("equipmen:token"); String equipmenToken = getEquipmenToken();
Map<String, Object> map = new HashMap<>(); return AjaxResult.success(equipmenToken);
if(equipmenToken ==null || "".equals(equipmenToken)){
String resp = HttpClientUtil.sendPost("https://open.ys7.com/api/lapp/token/get?appKey=e87d64ac7c424d7bb37830055a21b57a&appSecret=85d3ea44e86f940ac8274b43f6703803", null);
JSONObject jsonObject = JSON.parseObject(resp);
JSONObject data = jsonObject.getJSONObject("data");
String accessToken = data.getString("accessToken");
map.put("accessToken",accessToken);
redisService.setCacheObject("equipmen:token",accessToken,259200L, TimeUnit.SECONDS);
}else{
map.put("accessToken",equipmenToken);
}
return AjaxResult.success(map);
}catch (Exception e){ }catch (Exception e){
return AjaxResult.error("获取监控token失败请联系管理员"); return AjaxResult.error("获取监控token失败请联系管理员");
} }
} }
public static void main(String[] args) { public String getEquipmenToken(){
//// String st="14:30:00"; String equipmenToken = redisService.getCacheObject("equipmen:token");
//// String end="15:30:00"; Map<String, Object> map = new HashMap<>();
//// if(equipmenToken ==null || "".equals(equipmenToken)){
//// long sttime = DateUtil.parse(st, "HH:mm:ss").getTime(); String resp = HttpClientUtil.sendPost("https://open.ys7.com/api/lapp/token/get?appKey=e87d64ac7c424d7bb37830055a21b57a&appSecret=85d3ea44e86f940ac8274b43f6703803", null);
//// long endtime = DateUtil.parse(end, "HH:mm:ss").getTime(); JSONObject jsonObject = JSON.parseObject(resp);
//// JSONObject data = jsonObject.getJSONObject("data");
//// System.out.println((endtime-sttime)/1800000); String accessToken = data.getString("accessToken");
// try{ map.put("accessToken",accessToken);
// redisService.setCacheObject("equipmen:token",accessToken,259200L, TimeUnit.SECONDS);
// //获取token return accessToken;
//// HashMap<String, String> headers = new HashMap<>(3); }else{
//// String requestUrl = "https://open.ys7.com/api/lapp/token/get"; return equipmenToken;
//// String jsonStr = "{\n" + }
//// " \"appKey\":\"e87d64ac7c424d7bb37830055a21b57a\",\n" +
//// " \"appSecret\":\"85d3ea44e86f940ac8274b43f6703803\"\n" +
//// "}";
//// headers.put("content-type", "application/json");
//// // 发送post请求
//// String resultData = HttpUtils.sendPostWithJson(requestUrl, jsonStr,headers);
//// // 并接收返回结果
//// System.out.println(resultData);
// Map<String, String> rm = new HashMap<>();
// // rm.put("appKey", "e87d64ac7c424d7bb37830055a21b57a");
// // rm.put("appSecret", "85d3ea44e86f940ac8274b43f6703803");
//
//
// String resp = HttpClientUtil.sendPost("https://open.ys7.com/api/lapp/token/get?appKey=e87d64ac7c424d7bb37830055a21b57a&appSecret=85d3ea44e86f940ac8274b43f6703803", null);
//
// 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");
// System.out.println("accessToken:"+accessToken);
// String expireTime = data.getString("expireTime");
//
//
// }catch (Exception e){
//
// e.printStackTrace();
// }
} }
public static String getEquipmenUrl(String accessToken,String deviceSerial,String channelNo){
String url = "https://open.ys7.com/api/lapp/v2/live/address/get?accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&channelNo=" + channelNo;
String resp = HttpClientUtil.sendPost(url, null);
JSONObject jsonObject = JSON.parseObject(resp);
if("200".equals(jsonObject.getString("code"))){
JSONObject data = jsonObject.getJSONObject("data");
return data.getString("url");
}else{
return null;
}
}
public static void main(String[] args) {
String accessToken = "at.bxecfid28j8vu7baai2o82jydfj74jlw-1hrdvblpz2-1a7773w-vr8r9vdl6";
String deviceSerial ="C41675932";
String channelNo ="1";
String equipmenUrl = getEquipmenUrl(accessToken, deviceSerial, channelNo);
System.out.println("equipmenUrl:"+equipmenUrl);
}
} }

View File

@ -94,11 +94,20 @@ public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPil
@Override @Override
public AjaxResult status(Long pileEditionId,Integer status) { public AjaxResult status(Long pileEditionId,Integer status) {
XhpcPileEdition xhpcPileEdition = new XhpcPileEdition();
XhpcPileEdition xhpcPileEdition = xhpcPileEditionMapper.getXhpcPileEditionById(pileEditionId);
if(xhpcPileEdition==null){
return AjaxResult.error(500, "数据错误,请刷新页面在操作");
}
String[] split = xhpcPileEdition.getChargingPileIds().split(",");
if(split ==null || split.length==0){
return AjaxResult.error(500, "请选择桩");
}
List list = Arrays.asList(split);
xhpcPileEdition.setPileEditionId(pileEditionId); xhpcPileEdition.setPileEditionId(pileEditionId);
xhpcPileEdition.setStatus(status); xhpcPileEdition.setStatus(status);
if(status==0){ if(status==0){
int xhpcPileEditions = xhpcPileEditionMapper.updatePileEdition(xhpcPileEdition); int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(),list,1);
if(xhpcPileEditions >0){ if(xhpcPileEditions >0){
return AjaxResult.error(500, "有重复桩"); return AjaxResult.error(500, "有重复桩");
} }

View File

@ -158,4 +158,14 @@
</trim> </trim>
where equipmen_monitor_id = #{equipmenMonitorId} where equipmen_monitor_id = #{equipmenMonitorId}
</update> </update>
<select id="getChargingStationId" resultMap="BaseResultMap">
select *
from xhpc_equipmen_monitor
where status=0 and del_flag=0
<if test="chargingStationId !=null">
and charging_station_id=#{chargingStationId}
</if>
</select>
</mapper> </mapper>

View File

@ -52,6 +52,7 @@
<if test="tenantId !=null and tenantId !=''"> <if test="tenantId !=null and tenantId !=''">
and xpe.tenant_id=#{tenantId} and xpe.tenant_id=#{tenantId}
</if> </if>
order by xpe.create_time desc
</select> </select>
<select id="getXhpcPileEditions" resultType="int"> <select id="getXhpcPileEditions" resultType="int">
@ -59,11 +60,11 @@
count(xpe.pile_edition_id) number count(xpe.pile_edition_id) number
from xhpc_pile_edition xpe from xhpc_pile_edition xpe
where xpe.del_flag=0 and xpe.status =0 where xpe.del_flag=0 and xpe.status =0
<if test="type ==1"> <if test="type ==1 and pileEditionId !=null">
and xpe.pile_edition_id != #{pileEditionId} and xpe.pile_edition_id != #{pileEditionId}
</if> </if>
<foreach collection="chargingPileIds" separator="" item="pileId" close="" open=""> <foreach collection="chargingPileIds" separator="or" item="pileId" close=")" open="and(">
and find_in_set(#{pileId},xpe.charging_pile_ids) find_in_set(#{pileId},xpe.charging_pile_ids)
</foreach> </foreach>
</select> </select>
@ -166,4 +167,8 @@
</trim> </trim>
where pile_edition_id = #{pileEditionId} where pile_edition_id = #{pileEditionId}
</update> </update>
<select id="getXhpcPileEditionById" resultMap="BaseResultMap">
select * from xhpc_pile_edition where pile_edition_id = #{pileEditionId}
</select>
</mapper> </mapper>

View File

@ -1447,7 +1447,7 @@
COUNT(xh.history_order_id) totalOrder, COUNT(xh.history_order_id) totalOrder,
xcs.`name` name, xcs.`name` name,
IFNULL(ut.empty,0) emptyorder, IFNULL(ut.empty,0) emptyorder,
concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),'%') emptyOrderRate format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2) emptyOrderRate
FROM xhpc_charging_station xcs FROM xhpc_charging_station xcs
LEFT JOIN xhpc_history_order xh on xcs.charging_station_id =xh.charging_station_id LEFT JOIN xhpc_history_order xh on xcs.charging_station_id =xh.charging_station_id
LEFT join (SELECT COUNT(xh.history_order_id) empty,xh.charging_station_id LEFT join (SELECT COUNT(xh.history_order_id) empty,xh.charging_station_id
@ -1496,7 +1496,7 @@
xt.`name` name, xt.`name` name,
IFNULL(ut.empty,0) emptyorder, IFNULL(ut.empty,0) emptyorder,
xh.terminal_id, xh.terminal_id,
concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),'%') emptyOrderRate format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2) emptyOrderRate
FROM `xhpc_history_order` as xh FROM `xhpc_history_order` as xh
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id =xh.charging_station_id LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id =xh.charging_station_id
LEFT JOIN xhpc_terminal xt on xt.terminal_id =xh.terminal_id LEFT JOIN xhpc_terminal xt on xt.terminal_id =xh.terminal_id

View File

@ -219,38 +219,8 @@
(select sum(amount) from xhpc_recharge_order where create_time &gt;= #{time2} and tenant_id =#{tenantId} and del_flag = 0 and status=1) two, (select sum(amount) from xhpc_recharge_order where create_time &gt;= #{time2} and tenant_id =#{tenantId} and del_flag = 0 and status=1) two,
(select sum(amount) from xhpc_recharge_order where create_time &gt;= #{time3} and tenant_id =#{tenantId} and del_flag = 0 and status=1) three, (select sum(amount) from xhpc_recharge_order where create_time &gt;= #{time3} and tenant_id =#{tenantId} and del_flag = 0 and status=1) three,
(select sum(amount) from xhpc_recharge_order where create_time &gt;= #{time4} and tenant_id =#{tenantId} and del_flag = 0 and status=1) four (select sum(amount) from xhpc_recharge_order where create_time &gt;= #{time4} and tenant_id =#{tenantId} and del_flag = 0 and status=1) four
from xhpc_recharge_order xro from xhpc_recharge_order xro
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'recharge_order_status' and sdd.dict_value = xro.`status`
where xro.del_flag = 0 where xro.del_flag = 0
<if test="phone != null and phone != ''">
and xau.phone like concat('%', #{phone}, '%')
</if>
<if test="tenantId != null and tenantId != ''">
and xro.tenant_id =#{tenantId}
</if>
<if test="rechargeOrderNumber != null and rechargeOrderNumber != ''">
and xro.recharge_order_number like concat('%', #{rechargeOrderNumber}, '%')
</if>
<if test="status != null and status != ''">
and xro.status like concat('%', #{status}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''"><!-- 开始时间检索 -->
AND xro.create_time &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''"><!-- 结束时间检索 -->
AND xro.create_time &lt;= #{createTimeEnd}
</if>
<if test="type != null and type != ''">
AND xro.type = #{type}
</if>
<if test="source != null">
AND xro.source = #{source}
</if>
<if test="userId != null">
and xro.user_id=#{userId}
</if>
ORDER BY xro.create_time DESC ORDER BY xro.create_time DESC
</select> </select>

View File

@ -246,38 +246,13 @@
<select id="sumMoney" resultType="map"> <select id="sumMoney" resultType="map">
select select
sum(xro.amount) amount, sum(xro.amount) amount,
(select sum(amount) from xhpc_refund_order where create_time &gt;= #{time1} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) one, (select sum(amount) from xhpc_refund_order where create_time &gt;= #{time1} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) one,
(select sum(amount) from xhpc_refund_order where create_time &gt;= #{time2} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) two, (select sum(amount) from xhpc_refund_order where create_time &gt;= #{time2} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) two,
(select sum(amount) from xhpc_refund_order where create_time &gt;= #{time3} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) three, (select sum(amount) from xhpc_refund_order where create_time &gt;= #{time3} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) three,
(select sum(amount) from xhpc_refund_order where create_time &gt;= #{time4} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) four (select sum(amount) from xhpc_refund_order where create_time &gt;= #{time4} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) four
from xhpc_refund_order xro from xhpc_refund_order xro
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value =
xro.examine_status
where xro.del_flag = 0 and xro.examine_status=1 and xro.status =1 where xro.del_flag = 0 and xro.examine_status=1 and xro.status =1
<if test="phone != null and phone != ''">
and xau.phone like concat('%', #{phone}, '%')
</if>
<if test="tenantId != null and tenantId != ''">
and xro.tenant_id=#{tenantId}
</if>
<if test="refundOrderNumber != null and refundOrderNumber != ''">
and xro.refund_order_number like concat('%', #{refundOrderNumber}, '%')
</if>
<if test="status != null and status != ''">
and xro.status like concat('%', #{status}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''"><!-- 开始时间检索 -->
AND xro.create_time &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''"><!-- 结束时间检索 -->
AND xro.create_time &lt;= #{createTimeEnd}
</if>
<if test="type != null and type != ''">
and xro.type = #{type}
</if>
ORDER BY xro.create_time DESC ORDER BY xro.create_time DESC
</select> </select>