diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java new file mode 100644 index 00000000..7a6f7fee --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java @@ -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 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> mapList =new ArrayList<>(); + + Map 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 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> mapList = new ArrayList<>(); + + Map 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 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> 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); + } + + + + +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcInspection.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcInspection.java new file mode 100644 index 00000000..88298531 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcInspection.java @@ -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; +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java new file mode 100644 index 00000000..8ce85b3a --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java @@ -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> getInspectionList(@Param("stationId") Long stationId,@Param("time") String time); + + List> getInspectionChargingStation(); + + int installInspection(XhpcInspection xhpcInspection); + + Map getInspectionById(@Param("stationId")Long stationId,@Param("id") Long id,@Param("type")Integer type); + + int updateInspection(XhpcInspection xhpcInspection); + + +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java new file mode 100644 index 00000000..899641af --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java @@ -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> getInspectionList( Long stationId, String time); + + void timing(); + + AjaxResult getInspectionById(Long stationId, String id); + + AjaxResult addInspection(HttpServletRequest request, XhpcInspection xhpcInspection); +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java new file mode 100644 index 00000000..bea5d6ac --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java @@ -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> getInspectionList(Long stationId, String time) { + return xhpcInspectionMapper.getInspectionList(stationId, time); + } + + @Override + public void timing() { + + //查询没有删除的场站,进行生成每日巡检任务 + List> mapList = xhpcInspectionMapper.getInspectionChargingStation(); + + for (int i = 0; i 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 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(); + } +} diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml new file mode 100644 index 00000000..353f1c9b --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO xhpc_inspection + + + charging_station_id, + + + user_id, + + + terminal_id, + + + name, + + + type, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + inspection_img, + + + fault_img, + + + fault_description, + + + maintenance_record, + + + data_time, + + + error_name, + + + + + #{chargingStationId}, + + + #{userId}, + + + #{terminalId}, + + + #{name}, + + + #{type}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{inspectionImg}, + + + #{faultImg}, + + + #{faultDescription}, + + + #{maintenanceRecord}, + + + #{dataIime}, + + + #{errorName}, + + + + + + + + + update xhpc_inspection + + status=#{status} + inspection_img=#{inspectionImg} + fault_img=#{faultImg} + fault_description=#{faultDescription} + maintenance_record=#{maintenanceRecord} + user_id=#{userId} + + + where inspection_id=#{inspectionId} + + + + + diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcMotorcadeMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcMotorcadeMapper.xml index e354d64c..b3ff73a1 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcMotorcadeMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcMotorcadeMapper.xml @@ -50,6 +50,7 @@