|
@@ -1,56 +1,63 @@
|
|
|
package com.ruoyi.web.controller.qdtl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.enums.BusinessType;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.qdtl.domain.TlArea;
|
|
|
import com.ruoyi.qdtl.domain.TlInspectionDevice;
|
|
|
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
|
|
|
+import com.ruoyi.qdtl.service.ITlAreaService;
|
|
|
import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
-import com.ruoyi.common.annotation.Log;
|
|
|
-import com.ruoyi.common.core.controller.BaseController;
|
|
|
-import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.enums.BusinessType;
|
|
|
-import com.ruoyi.qdtl.domain.TlInspectionLocation;
|
|
|
-import com.ruoyi.qdtl.service.ITlInspectionLocationService;
|
|
|
-import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
-import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 巡检点管理Controller
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
* @date 2022-02-22
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/qdtl/location")
|
|
|
-public class TlInspectionLocationController extends BaseController
|
|
|
-{
|
|
|
+public class TlInspectionLocationController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITlInspectionLocationService tlInspectionLocationService;
|
|
|
@Autowired
|
|
|
private ITlInspectionDeviceService tlInspectionDeviceService;
|
|
|
+ @Autowired
|
|
|
+ private ITlAreaService tlAreaService;
|
|
|
|
|
|
/**
|
|
|
* 查询巡检点管理列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('qdtl:location:list')")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(TlInspectionLocation tlInspectionLocation)
|
|
|
- {
|
|
|
+ public TableDataInfo list(TlInspectionLocation tlInspectionLocation) {
|
|
|
startPage();
|
|
|
List<TlInspectionLocation> list = tlInspectionLocationService.selectTlInspectionLocationList(tlInspectionLocation);
|
|
|
+ // 查询区域数据
|
|
|
+ List<TlArea> areas = tlAreaService.selectTlAreaList(new TlArea());
|
|
|
+ Map<Long, String> areaCollect = areas.stream().collect(Collectors.toMap(TlArea::getId, TlArea::getAreaName));
|
|
|
|
|
|
for (TlInspectionLocation inspectionLocation : list) {
|
|
|
List<TlInspectionDevice> devices = new ArrayList<>();
|
|
@@ -64,6 +71,8 @@ public class TlInspectionLocationController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
inspectionLocation.setDeviceNames(devices);
|
|
|
+ inspectionLocation.setDeviceNamesText(devices.stream().map(TlInspectionDevice::getDeviceName).collect(Collectors.joining(",")));
|
|
|
+ inspectionLocation.setAreaName(areaCollect.getOrDefault(inspectionLocation.getAreaId(), ""));
|
|
|
}
|
|
|
return getDataTable(list);
|
|
|
}
|
|
@@ -74,8 +83,7 @@ public class TlInspectionLocationController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('qdtl:location:export')")
|
|
|
@Log(title = "巡检点管理", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, TlInspectionLocation tlInspectionLocation)
|
|
|
- {
|
|
|
+ public void export(HttpServletResponse response, TlInspectionLocation tlInspectionLocation) {
|
|
|
List<TlInspectionLocation> list = tlInspectionLocationService.selectTlInspectionLocationList(tlInspectionLocation);
|
|
|
ExcelUtil<TlInspectionLocation> util = new ExcelUtil<TlInspectionLocation>(TlInspectionLocation.class);
|
|
|
util.exportExcel(response, list, "巡检点管理数据");
|
|
@@ -86,8 +94,7 @@ public class TlInspectionLocationController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('qdtl:location:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return AjaxResult.success(tlInspectionLocationService.selectTlInspectionLocationById(id));
|
|
|
}
|
|
|
|
|
@@ -97,8 +104,7 @@ public class TlInspectionLocationController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('qdtl:location:add')")
|
|
|
@Log(title = "巡检点管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody TlInspectionLocation tlInspectionLocation)
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody TlInspectionLocation tlInspectionLocation) {
|
|
|
return toAjax(tlInspectionLocationService.insertTlInspectionLocation(tlInspectionLocation));
|
|
|
}
|
|
|
|
|
@@ -108,8 +114,7 @@ public class TlInspectionLocationController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('qdtl:location:edit')")
|
|
|
@Log(title = "巡检点管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody TlInspectionLocation tlInspectionLocation)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody TlInspectionLocation tlInspectionLocation) {
|
|
|
return toAjax(tlInspectionLocationService.updateTlInspectionLocation(tlInspectionLocation));
|
|
|
}
|
|
|
|
|
@@ -118,9 +123,8 @@ public class TlInspectionLocationController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('qdtl:location:remove')")
|
|
|
@Log(title = "巡检点管理", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(tlInspectionLocationService.deleteTlInspectionLocationByIds(ids));
|
|
|
}
|
|
|
}
|