|
|
@@ -1,6 +1,9 @@
|
|
|
package com.ruoyi.project.ps.inspection.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
@@ -19,7 +22,7 @@ import java.util.Map;
|
|
|
* @date 2025-01-XX
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/ps/dev")
|
|
|
+@RequestMapping("/ps/app")
|
|
|
public class TPsInspectionAppController extends BaseController {
|
|
|
|
|
|
// 注入各个Controller
|
|
|
@@ -68,12 +71,66 @@ public class TPsInspectionAppController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
public AjaxResult list(InspectionQueryRequest request) {
|
|
|
- if (request.getType() == null || request.getType().isEmpty()) {
|
|
|
+ if (StringUtils.isEmpty(request.getType())) {
|
|
|
return AjaxResult.error("巡检记录类型不能为空");
|
|
|
}
|
|
|
|
|
|
+ if (StringUtils.isEmpty(request.getData())) {
|
|
|
+ request.setData("{}");
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
- TableDataInfo dataTable = queryByType(request.getType(), JSON.toJSONString(request));
|
|
|
+ // 解析分页参数
|
|
|
+ Integer pageNum = null;
|
|
|
+ Integer pageSize = null;
|
|
|
+
|
|
|
+ // 先从 data JSON 中尝试获取分页参数
|
|
|
+ try {
|
|
|
+ JSONObject dataJson = JSON.parseObject(request.getData());
|
|
|
+ if (dataJson != null) {
|
|
|
+ Object pageNumObj = dataJson.get("pageNum");
|
|
|
+ Object pageSizeObj = dataJson.get("pageSize");
|
|
|
+ if (pageNumObj != null) {
|
|
|
+ pageNum = Integer.valueOf(pageNumObj.toString());
|
|
|
+ }
|
|
|
+ if (pageSizeObj != null) {
|
|
|
+ pageSize = Integer.valueOf(pageSizeObj.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("解析 data JSON 中的分页参数失败", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果 data 中没有分页参数,尝试从请求参数中获取
|
|
|
+ if (pageNum == null || pageSize == null) {
|
|
|
+ try {
|
|
|
+ com.ruoyi.common.utils.ServletUtils.getRequest();
|
|
|
+ if (pageNum == null) {
|
|
|
+ Integer paramPageNum = com.ruoyi.common.utils.ServletUtils.getParameterToInt("pageNum");
|
|
|
+ if (paramPageNum != null) {
|
|
|
+ pageNum = paramPageNum;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pageSize == null) {
|
|
|
+ Integer paramPageSize = com.ruoyi.common.utils.ServletUtils.getParameterToInt("pageSize");
|
|
|
+ if (paramPageSize != null) {
|
|
|
+ pageSize = paramPageSize;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("从请求参数中获取分页参数失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置分页(必须在调用 queryByType 之前设置,因为 PageHelper 使用 ThreadLocal)
|
|
|
+ if (pageNum != null && pageSize != null) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ } else {
|
|
|
+ // 如果没有分页参数,使用默认分页或调用 startPage() 从请求参数中获取
|
|
|
+ startPage();
|
|
|
+ }
|
|
|
+
|
|
|
+ TableDataInfo dataTable = queryByType(request.getType(), request.getData());
|
|
|
return AjaxResult.success(dataTable);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("查询巡检记录失败", e);
|
|
|
@@ -81,6 +138,31 @@ public class TPsInspectionAppController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取巡检记录详细信息(App接口)
|
|
|
+ * 根据设备编号/位号和计划ID获取检查记录信息
|
|
|
+ *
|
|
|
+ * @param request 查询请求参数(包含type、devNo/boxNo/equipId等和planId)
|
|
|
+ * @return 查询结果
|
|
|
+ */
|
|
|
+ @GetMapping("/info")
|
|
|
+ public AjaxResult getInfo(InspectionQueryRequest request) {
|
|
|
+ if (StringUtils.isEmpty(request.getType())) {
|
|
|
+ return AjaxResult.error("巡检记录类型不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(request.getData())) {
|
|
|
+ request.setData("{}");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ return getInfoByType(request.getType(), request.getData());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("获取巡检记录失败", e);
|
|
|
+ return AjaxResult.error("获取失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改巡检记录(App接口)
|
|
|
*
|
|
|
@@ -186,6 +268,90 @@ public class TPsInspectionAppController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据类型获取数据,调用对应Controller的getInfo方法
|
|
|
+ */
|
|
|
+ private AjaxResult getInfoByType(String type, String dataJson) {
|
|
|
+ type = type.toLowerCase();
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case "alarm":
|
|
|
+ TPsInspectionAlarm alarm = (TPsInspectionAlarm) setFilterFields(dataJson, TPsInspectionAlarm.class);
|
|
|
+ return alarmController.getInfoByDevNo(alarm);
|
|
|
+
|
|
|
+ case "extinguisher":
|
|
|
+ TPsInspectionExtinguisher extinguisher = (TPsInspectionExtinguisher) setFilterFields(dataJson, TPsInspectionExtinguisher.class);
|
|
|
+ return extinguisherController.getInfoByFireextinguisherno(extinguisher);
|
|
|
+
|
|
|
+ case "hydrant":
|
|
|
+ TPsInspectionHydrant hydrant = (TPsInspectionHydrant) setFilterFields(dataJson, TPsInspectionHydrant.class);
|
|
|
+ return hydrantController.getInfoByEquipid(hydrant);
|
|
|
+
|
|
|
+ case "firedoor":
|
|
|
+ TPsInspectionFiredoor firedoor = (TPsInspectionFiredoor) setFilterFields(dataJson, TPsInspectionFiredoor.class);
|
|
|
+ return firedoorController.getInfoByDoorno(firedoor);
|
|
|
+
|
|
|
+ case "lift":
|
|
|
+ TPsInspectionLift lift = (TPsInspectionLift) setFilterFields(dataJson, TPsInspectionLift.class);
|
|
|
+ return liftController.getInfoByDevno(lift);
|
|
|
+
|
|
|
+ case "cabinet":
|
|
|
+ TPsInspectionCabinet cabinet = (TPsInspectionCabinet) setFilterFields(dataJson, TPsInspectionCabinet.class);
|
|
|
+ return cabinetController.getInfoByBoxNo(cabinet);
|
|
|
+
|
|
|
+ case "callsystem":
|
|
|
+ TPsInspectionCallsystem callsystem = (TPsInspectionCallsystem) setFilterFields(dataJson, TPsInspectionCallsystem.class);
|
|
|
+ return callsystemController.getInfoByDevno(callsystem);
|
|
|
+
|
|
|
+ case "fgs":
|
|
|
+ TPsInspectionFgs fgs = (TPsInspectionFgs) setFilterFields(dataJson, TPsInspectionFgs.class);
|
|
|
+ return fgsController.getInfoByFgsno(fgs);
|
|
|
+
|
|
|
+ case "curtain":
|
|
|
+ TPsInspectionCurtain curtain = (TPsInspectionCurtain) setFilterFields(dataJson, TPsInspectionCurtain.class);
|
|
|
+ return curtainController.getInfoByCurtainname(curtain);
|
|
|
+
|
|
|
+ case "steam":
|
|
|
+ TPsInspectionSteam steam = (TPsInspectionSteam) setFilterFields(dataJson, TPsInspectionSteam.class);
|
|
|
+ return steamController.getInfoBySteamname(steam);
|
|
|
+
|
|
|
+ case "monitor":
|
|
|
+ TPsInspectionMonitor monitor = (TPsInspectionMonitor) setFilterFields(dataJson, TPsInspectionMonitor.class);
|
|
|
+ return monitorController.getInfoByDevno(monitor);
|
|
|
+
|
|
|
+ case "coffer":
|
|
|
+ TPsInspectionCoffer coffer = (TPsInspectionCoffer) setFilterFields(dataJson, TPsInspectionCoffer.class);
|
|
|
+ return cofferController.getInfoByCofferno(coffer);
|
|
|
+
|
|
|
+ case "sump":
|
|
|
+ TPsInspectionSump sump = (TPsInspectionSump) setFilterFields(dataJson, TPsInspectionSump.class);
|
|
|
+ return sumpController.getInfoBySumpno(sump);
|
|
|
+
|
|
|
+ case "pit":
|
|
|
+ TPsInspectionPit pit = (TPsInspectionPit) setFilterFields(dataJson, TPsInspectionPit.class);
|
|
|
+ return pitController.getInfoByDevno(pit);
|
|
|
+
|
|
|
+ case "rainvalve":
|
|
|
+ TPsInspectionRainvalve rainvalve = (TPsInspectionRainvalve) setFilterFields(dataJson, TPsInspectionRainvalve.class);
|
|
|
+ return rainvalveController.getInfoByValvename(rainvalve);
|
|
|
+
|
|
|
+ case "ventvalve":
|
|
|
+ TPsInspectionVentvalve ventvalve = (TPsInspectionVentvalve) setFilterFields(dataJson, TPsInspectionVentvalve.class);
|
|
|
+ return ventvalveController.getInfoByVentvalveno(ventvalve);
|
|
|
+
|
|
|
+ case "utilitystation":
|
|
|
+ TPsInspectionUtilitystation utilitystation = (TPsInspectionUtilitystation) setFilterFields(dataJson, TPsInspectionUtilitystation.class);
|
|
|
+ return utilitystationController.getInfoByUtilitystationname(utilitystation);
|
|
|
+
|
|
|
+ case "eyewash":
|
|
|
+ TPsInspectionEyewash eyewash = (TPsInspectionEyewash) setFilterFields(dataJson, TPsInspectionEyewash.class);
|
|
|
+ return eyewashController.getInfoByDevno(eyewash);
|
|
|
+
|
|
|
+ default:
|
|
|
+ throw new IllegalArgumentException("不支持的巡检记录类型:" + type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据类型更新数据,调用对应Controller的edit方法
|
|
|
*/
|