运维新实现接口
This commit is contained in:
parent
db52a6974c
commit
43ee4bf434
@ -0,0 +1,130 @@
|
||||
package com.xhpc.order.controller;
|
||||
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.order.domain.XhpcInspection;
|
||||
import com.xhpc.order.service.IXhpcInspectionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@EnableScheduling
|
||||
@RestController
|
||||
@RequestMapping("/inspection")
|
||||
@Api(value = "巡检接口", tags = "巡检接口")
|
||||
public class XhpcInspectionController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IXhpcInspectionService xhpcInspectionService;
|
||||
|
||||
|
||||
@GetMapping("/getDataBoard")
|
||||
public AjaxResult getDataBoard(){
|
||||
Map<String,Object> map1 =new HashMap<>();
|
||||
map1.put("stationSum",11);
|
||||
map1.put("abnormalStation",1);
|
||||
map1.put("todayOrder",236);
|
||||
map1.put("emptyOrderRate","23.56");
|
||||
map1.put("completionRate","75%");
|
||||
map1.put("onlineRate","93.5%");
|
||||
return AjaxResult.success(map1);
|
||||
}
|
||||
|
||||
@GetMapping("/getRealTimeWarning")
|
||||
public AjaxResult getRealTimeWarning(){
|
||||
List<Map<String,Object>> mapList =new ArrayList<>();
|
||||
|
||||
Map<String,Object> map1 =new HashMap<>();
|
||||
map1.put("stationName","小华充电团结平安村充电站");
|
||||
map1.put("terminalName","4号桩B枪");
|
||||
map1.put("time","2026-2-5 08:35:45");
|
||||
map1.put("conent","离线时间超过2小时");
|
||||
mapList.add(map1);
|
||||
|
||||
Map<String,Object> map2 =new HashMap<>();
|
||||
map2.put("stationName","小华充电团结平安村充电站");
|
||||
map2.put("terminalName","3号桩B枪");
|
||||
map2.put("time","2026-2-4 08:35:45");
|
||||
map2.put("conent","离线时间超过1小时");
|
||||
mapList.add(map2);
|
||||
|
||||
|
||||
return AjaxResult.success(mapList);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getStationList")
|
||||
public AjaxResult getStationList() {
|
||||
//stationName:场站名称 twoDayOrder:订单量 emptyOrderRate:空订单率
|
||||
// normal:正常 offline:离线 fault:故障 "未知": 3
|
||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
map1.put("stationName", "小华充电团结平安村充电站");
|
||||
map1.put("stationId",1);
|
||||
map1.put("twoDayOrder", "243");
|
||||
map1.put("emptyOrderRate", "34.8%");
|
||||
map1.put("normal", 7);
|
||||
map1.put("offline", 1);
|
||||
map1.put("fault", 2);
|
||||
map1.put("unknown", 3);
|
||||
mapList.add(map1);
|
||||
|
||||
Map<String, Object> map2 = new HashMap<>();
|
||||
map2.put("stationName", "小华充电高堆路充电站");
|
||||
map2.put("stationId",2);
|
||||
map2.put("twoDayOrder", "2430");
|
||||
map2.put("emptyOrderRate", "34.8%");
|
||||
map2.put("normal", 15);
|
||||
map2.put("offline", 1);
|
||||
map2.put("fault", 2);
|
||||
map2.put("unknown", 3);
|
||||
mapList.add(map2);
|
||||
return AjaxResult.success(mapList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getInspectionList")
|
||||
public AjaxResult getInspectionList(@Param("stationId") Long stationId, String time) {
|
||||
//stationName:场站名称 twoDayOrder:订单量 emptyOrderRate:空订单率
|
||||
// normal:正常 offline:离线 fault:故障 "未知": 3
|
||||
|
||||
List<Map<String, Object>> inspectionList = xhpcInspectionService.getInspectionList(stationId, time);
|
||||
return AjaxResult.success(inspectionList);
|
||||
}
|
||||
|
||||
@GetMapping("/timing")
|
||||
@Scheduled(cron = "0 50 23 * * ? ")
|
||||
public void timing(){
|
||||
// 系统自动生成每日巡检项23:50
|
||||
xhpcInspectionService.timing();
|
||||
}
|
||||
|
||||
@GetMapping("/getInspectionById")
|
||||
public AjaxResult getInspectionById(@Param("stationId") Long stationId,@Param("id") String id) {
|
||||
return xhpcInspectionService.getInspectionById(stationId, id);
|
||||
}
|
||||
|
||||
@PostMapping("/addInspection")
|
||||
public AjaxResult addInspection(HttpServletRequest request,XhpcInspection xhpcInspection) {
|
||||
return xhpcInspectionService.addInspection(request,xhpcInspection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.xhpc.order.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class XhpcInspection extends BaseEntity {
|
||||
|
||||
private Long inspectionId;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long chargingStationId;
|
||||
|
||||
private Long terminalId;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String inspectionImg;
|
||||
|
||||
private String faultImg;
|
||||
|
||||
private String faultDescription;
|
||||
|
||||
private String maintenanceRecord;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Integer delFlag;
|
||||
|
||||
private String dataIime;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String errorName;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.xhpc.order.mapper;
|
||||
|
||||
import com.xhpc.order.domain.XhpcInspection;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface XhpcInspectionMapper {
|
||||
|
||||
List<Map<String, Object>> getInspectionList(@Param("stationId") Long stationId,@Param("time") String time);
|
||||
|
||||
List<Map<String, Object>> getInspectionChargingStation();
|
||||
|
||||
int installInspection(XhpcInspection xhpcInspection);
|
||||
|
||||
Map<String, Object> getInspectionById(@Param("stationId")Long stationId,@Param("id") Long id,@Param("type")Integer type);
|
||||
|
||||
int updateInspection(XhpcInspection xhpcInspection);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.xhpc.order.service;
|
||||
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.order.domain.XhpcInspection;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IXhpcInspectionService {
|
||||
|
||||
List<Map<String, Object>> getInspectionList( Long stationId, String time);
|
||||
|
||||
void timing();
|
||||
|
||||
AjaxResult getInspectionById(Long stationId, String id);
|
||||
|
||||
AjaxResult addInspection(HttpServletRequest request, XhpcInspection xhpcInspection);
|
||||
}
|
||||
@ -0,0 +1,119 @@
|
||||
package com.xhpc.order.service.impl;
|
||||
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.order.domain.XhpcInspection;
|
||||
import com.xhpc.order.mapper.XhpcInspectionMapper;
|
||||
import com.xhpc.order.service.IXhpcInspectionService;
|
||||
import com.xhpc.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class XhpcInspectionServiceImpl implements IXhpcInspectionService {
|
||||
|
||||
@Autowired
|
||||
private XhpcInspectionMapper xhpcInspectionMapper;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getInspectionList(Long stationId, String time) {
|
||||
return xhpcInspectionMapper.getInspectionList(stationId, time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timing() {
|
||||
|
||||
//查询没有删除的场站,进行生成每日巡检任务
|
||||
List<Map<String, Object>> mapList = xhpcInspectionMapper.getInspectionChargingStation();
|
||||
|
||||
for (int i = 0; i <mapList.size() ; i++) {
|
||||
Map<String, Object> map = mapList.get(i);
|
||||
Long chargingStationId = Long.getLong(map.get("chargingStationId").toString());
|
||||
if(i==0){
|
||||
XhpcInspection xhpcInspection = new XhpcInspection();
|
||||
xhpcInspection.setName("箱变");
|
||||
xhpcInspection.setChargingStationId(chargingStationId);
|
||||
xhpcInspection.setStatus(0);
|
||||
xhpcInspection.setType(1);
|
||||
xhpcInspectionMapper.installInspection(xhpcInspection);
|
||||
|
||||
XhpcInspection xhpcInspection1 = new XhpcInspection();
|
||||
xhpcInspection1.setName("监控");
|
||||
xhpcInspection.setChargingStationId(chargingStationId);
|
||||
xhpcInspection1.setStatus(0);
|
||||
xhpcInspection1.setType(2);
|
||||
xhpcInspectionMapper.installInspection(xhpcInspection1);
|
||||
|
||||
XhpcInspection xhpcInspection2 = new XhpcInspection();
|
||||
xhpcInspection2.setName("道闸");
|
||||
xhpcInspection.setChargingStationId(chargingStationId);
|
||||
xhpcInspection2.setStatus(0);
|
||||
xhpcInspection2.setType(3);
|
||||
xhpcInspectionMapper.installInspection(xhpcInspection2);
|
||||
|
||||
XhpcInspection xhpcInspection3 = new XhpcInspection();
|
||||
xhpcInspection3.setName("远程连接");
|
||||
xhpcInspection.setChargingStationId(chargingStationId);
|
||||
xhpcInspection3.setStatus(0);
|
||||
xhpcInspection3.setType(4);
|
||||
xhpcInspectionMapper.installInspection(xhpcInspection3);
|
||||
|
||||
}
|
||||
XhpcInspection xhpcInspection = new XhpcInspection();
|
||||
xhpcInspection.setName(map.get("name").toString());
|
||||
xhpcInspection.setChargingStationId(chargingStationId);
|
||||
int status = Integer.getInteger(map.get("status").toString());
|
||||
if(status==0){
|
||||
xhpcInspection.setStatus(0);
|
||||
}else{
|
||||
xhpcInspection.setStatus(3);
|
||||
if(map.get("prompt")!=null){
|
||||
xhpcInspection.setErrorName(map.get("prompt").toString());
|
||||
}
|
||||
}
|
||||
xhpcInspection.setType(0);
|
||||
|
||||
xhpcInspectionMapper.installInspection(xhpcInspection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getInspectionById(Long stationId, String id) {
|
||||
//'0 桩 1箱变 2监控 3道闸 4 远程连接'
|
||||
Map<String, Object> map =new HashMap<>();
|
||||
int type =0;
|
||||
if(id.equals("XB")){
|
||||
type=1;
|
||||
map =xhpcInspectionMapper.getInspectionById(stationId,null,type);
|
||||
}else if(id.equals("DZ")){
|
||||
type=3;
|
||||
map =xhpcInspectionMapper.getInspectionById(stationId,null,type);
|
||||
}else if(id.equals("JK")){
|
||||
type=2;
|
||||
map =xhpcInspectionMapper.getInspectionById(stationId,null,type);
|
||||
}else if(id.equals("YC")){
|
||||
type=2;
|
||||
map =xhpcInspectionMapper.getInspectionById(stationId,null,type);
|
||||
}
|
||||
map =xhpcInspectionMapper.getInspectionById(stationId,Long.getLong(id),type);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult addInspection(HttpServletRequest request, XhpcInspection xhpcInspection) {
|
||||
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
xhpcInspection.setUserId(loginUser.getUserid());
|
||||
xhpcInspectionMapper.updateInspection(xhpcInspection);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,227 @@
|
||||
<?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">
|
||||
<mapper namespace="com.xhpc.order.mapper.XhpcInspectionMapper">
|
||||
<resultMap type="com.xhpc.order.domain.XhpcInspection" id="XhpcInspectionResult">
|
||||
<result column="inspection_id" property="inspectionId"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="charging_station_id" property="chargingStationId"/>
|
||||
<result column="terminal_id" property="terminalId"/>
|
||||
<result column="inspection_img" property="inspectionImg"/>
|
||||
<result column="fault_img" property="faultImg"/>
|
||||
<result column="fault_description" property="faultDescription"/>
|
||||
<result column="maintenance_record" property="maintenanceRecord"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<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="dataIime" column="data_time"/>
|
||||
<result property="errorName" column="error_name"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getInspectionList" resultType="map">
|
||||
select
|
||||
t.inspection_id as inspectionId,
|
||||
CASE
|
||||
WHEN t.type = 1 THEN 'XB'
|
||||
WHEN t.type = 2 THEN 'JK'
|
||||
WHEN t.type = 3 THEN 'DZ'
|
||||
WHEN t.type = 4 THEN 'YC'
|
||||
WHEN t.type = 0 THEN t.inspection_id
|
||||
ELSE NULL
|
||||
END AS id,
|
||||
t.name as name,
|
||||
t.status as status,
|
||||
t.error_name as errorName
|
||||
from xhpc_inspection t
|
||||
where t.charging_station_id=#{stationId} and t.data_time=#{time}
|
||||
order by inspection_id
|
||||
</select>
|
||||
|
||||
<select id="getInspectionChargingStation" resultType="map">
|
||||
select
|
||||
concat(xcp.name,"号桩") name,
|
||||
xcp.status as status,
|
||||
xcs.charging_station_id as chargingStationId,
|
||||
(
|
||||
SELECT xt.prompt
|
||||
FROM xhpc_terminal xt
|
||||
WHERE xt.charging_pile_id = xcp.charging_pile_id
|
||||
AND xt.prompt IS NOT NULL
|
||||
LIMIT 1
|
||||
) AS prompt
|
||||
from xhpc_charging_pile xcp
|
||||
left join xhpc_charging_station as xcs on xcs.charging_station_id = xcp.charging_station_id
|
||||
left join xhpc_terminal xt on xt.charging_pile_id = xcp.charging_pile_id
|
||||
where xcs.del_flag=0 and xcp.del_flag=0
|
||||
order by inspection_id
|
||||
</select>
|
||||
|
||||
<insert id="installInspection">
|
||||
INSERT INTO xhpc_inspection
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="chargingStationId != null">
|
||||
charging_station_id,
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="terminalId != null">
|
||||
terminal_id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
del_flag,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="createBy != null">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="inspectionImg != null">
|
||||
inspection_img,
|
||||
</if>
|
||||
<if test="faultImg != null">
|
||||
fault_img,
|
||||
</if>
|
||||
<if test="faultDescription != null">
|
||||
fault_description,
|
||||
</if>
|
||||
<if test="null != maintenanceRecord">
|
||||
maintenance_record,
|
||||
</if>
|
||||
<if test="dataIime != null">
|
||||
data_time,
|
||||
</if>
|
||||
<if test="errorName != null">
|
||||
error_name,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="chargingStationId != null">
|
||||
#{chargingStationId},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
#{userId},
|
||||
</if>
|
||||
<if test="terminalId != null">
|
||||
#{terminalId},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status},
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
#{delFlag},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="inspectionImg != null">
|
||||
#{inspectionImg},
|
||||
</if>
|
||||
<if test="faultImg != null">
|
||||
#{faultImg},
|
||||
</if>
|
||||
<if test="faultDescription != null">
|
||||
#{faultDescription},
|
||||
</if>
|
||||
<if test="null != maintenanceRecord">
|
||||
#{maintenanceRecord},
|
||||
</if>
|
||||
<if test="dataIime != null">
|
||||
#{dataIime},
|
||||
</if>
|
||||
<if test="errorName != null">
|
||||
#{errorName},
|
||||
</if>
|
||||
</trim>
|
||||
|
||||
</insert>
|
||||
|
||||
<select id="getInspectionById" resultType="map">
|
||||
select
|
||||
t.inspection_id as inspectionId,
|
||||
CASE
|
||||
WHEN t.type = 1 THEN 'XB'
|
||||
WHEN t.type = 2 THEN 'JK'
|
||||
WHEN t.type = 3 THEN 'DZ'
|
||||
WHEN t.type = 4 THEN 'YC'
|
||||
WHEN t.type = 0 THEN t.inspection_id
|
||||
ELSE NULL
|
||||
END AS id,
|
||||
t.name as name,
|
||||
t.status as status,
|
||||
t.inspection_img as inspectionImg,
|
||||
t.fault_img as faultImg,
|
||||
t.fault_description as faultDescription,
|
||||
t.maintenance_record as maintenanceRecord,
|
||||
t.error_name as errorName
|
||||
from xhpc_inspection t
|
||||
where t.charging_station_id=#{stationId} and t.del_flag=0
|
||||
<if test="type==0">
|
||||
and t.inspection_id =#{id}
|
||||
</if>
|
||||
<if test="type!=0">
|
||||
and t.type =#{type}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<update id="updateInspection">
|
||||
update xhpc_inspection
|
||||
<set>
|
||||
<if test="status !=null">status=#{status}</if>
|
||||
<if test="inspectionImg !=null">inspection_img=#{inspectionImg}</if>
|
||||
<if test="faultImg !=null">fault_img=#{faultImg}</if>
|
||||
<if test="faultDescription !=null">fault_description=#{faultDescription}</if>
|
||||
<if test="maintenanceRecord !=null">maintenance_record=#{maintenanceRecord}</if>
|
||||
<if test="userId !=null">user_id=#{userId}</if>
|
||||
</set>
|
||||
|
||||
where inspection_id=#{inspectionId}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -50,6 +50,7 @@
|
||||
<select id="list" resultType="map">
|
||||
select
|
||||
motorcade_id as motorcadeId,
|
||||
ilk as ilk,
|
||||
name as name
|
||||
from xhpc_motorcade
|
||||
where del_flag =0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user