package com.ruoyi.web.controller.manage;
|
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.util.*;
|
|
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.fuzhou.domain.DpEquipment;
|
import com.ruoyi.fuzhou.domain.ReceiveSlmValueFinal;
|
import com.ruoyi.fuzhou.domain.ReceiveWaterValue;
|
import com.ruoyi.fuzhou.domain.vo.DpEquipmentVO;
|
import com.ruoyi.fuzhou.service.EquipmentService;
|
import com.ruoyi.fuzhou.service.ReceiveWaterValueService;
|
import com.ruoyi.manage.domain.DmBerth;
|
import com.ruoyi.manage.service.DpBerthService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.annotation.Resource;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
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.manage.domain.DmHarbor;
|
import com.ruoyi.manage.service.IDmHarborService;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
/**
|
* 港口信息Controller
|
*
|
* @author ruoyi
|
* @date 2025-03-17
|
*/
|
@RestController
|
@RequestMapping("/dp/harbor")
|
@Tag(name = "大屏--港口管理")
|
public class DmHarborController extends BaseController
|
{
|
@Autowired
|
private IDmHarborService dmHarborService;
|
@Autowired
|
private DpBerthService dpBerthService;
|
@Resource
|
private EquipmentService dpEquipmentService;
|
@Resource
|
private ReceiveWaterValueService receiveWaterValueService;
|
|
/**
|
* 查询港口信息列表
|
*/
|
@GetMapping("/list")
|
@Operation(summary = "查询港口信息列表")
|
public TableDataInfo list(DmHarbor dmHarbor)
|
{
|
|
return dmHarborService.getList(dmHarbor);
|
}
|
|
/**
|
* 查询所有港口信息列表
|
*/
|
@GetMapping("/listAll")
|
@Operation(summary = "查询所有港口信息列表")
|
public AjaxResult listAll()
|
{
|
return AjaxResult.success(dmHarborService.list());
|
}
|
|
/**
|
* 查询所有港口信息列表
|
*/
|
@GetMapping("/getListAll")
|
@Operation(summary = "查询所有港口信息")
|
public AjaxResult getListAll()
|
{
|
//获取用户信息根据部门ID查询港口信息
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
Long deptId = loginUser.getDeptId();
|
if(deptId.equals(100L)){
|
return AjaxResult.success(dmHarborService.list());
|
}
|
if(deptId.equals(4001L)){
|
deptId = 101L;
|
}
|
if(deptId.equals(4002L)){
|
deptId = 4000L;
|
}
|
QueryWrapper<DmHarbor> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("DEPT_ID",deptId);
|
return AjaxResult.success(dmHarborService.list(queryWrapper));
|
}
|
|
/**
|
* 查询港口及其泊位详情
|
*/
|
@GetMapping("/getHarborBerth")
|
@Operation(summary = "查询港口及其泊位详情")
|
public AjaxResult getHarborBerth()
|
{
|
//获取用户信息根据部门ID查询港口信息
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
Long deptId = loginUser.getDeptId();
|
List<DmHarbor> reslist = new ArrayList<>();
|
if(deptId.equals(100L)){
|
List<DmHarbor> list = dmHarborService.list();
|
for (DmHarbor dmHarbor : list){
|
LambdaQueryWrapper<DmBerth> berthQueryWrapper = new LambdaQueryWrapper<>();
|
berthQueryWrapper.eq(DmBerth::getHarborId,dmHarbor.getPkId()).notIn(DmBerth::getName,"园区").orderByAsc(DmBerth::getOrderNum);
|
List<DmBerth> dmBerths = dpBerthService.list(berthQueryWrapper);
|
dmHarbor.setDmBerthList(dmBerths);
|
reslist.add(dmHarbor);
|
}
|
return AjaxResult.success(reslist);
|
}else {
|
if(deptId.equals(4001L)){
|
deptId = 101L;
|
}
|
QueryWrapper<DmHarbor> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("DEPT_ID",deptId);
|
List<DmHarbor> list = dmHarborService.list(queryWrapper);
|
for (DmHarbor dmHarbor : list){
|
LambdaQueryWrapper<DmBerth> QueryWrapper = new LambdaQueryWrapper<>();
|
QueryWrapper.eq(DmBerth::getHarborId,dmHarbor.getPkId()).notIn(DmBerth::getName,"园区").orderByAsc(DmBerth::getOrderNum);
|
List<DmBerth> dmBerths = dpBerthService.list(QueryWrapper);
|
dmHarbor.setDmBerthList(dmBerths);
|
reslist.add(dmHarbor);
|
}
|
return AjaxResult.success(reslist);
|
}
|
}
|
|
/**
|
* 查询港口水深数据列表
|
*/
|
@GetMapping("/getWaterDepthList")
|
@Operation(summary = "查询港口水深数据列表")
|
public AjaxResult getWaterDepthList() {
|
//获取用户信息根据部门ID查询港口信息
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
Long deptId = loginUser.getDeptId();
|
List<DpEquipmentVO> resList = new ArrayList<>();
|
if(deptId.equals(100L)){
|
List<DmHarbor> list = dmHarborService.list();
|
return AjaxResult.success(getWaterDepth(list));
|
}else {
|
if(deptId.equals(4001L)){
|
deptId = 101L;
|
}
|
QueryWrapper<DmHarbor> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("DEPT_ID",deptId);
|
List<DmHarbor> list = dmHarborService.list(queryWrapper);
|
return AjaxResult.success(getWaterDepth(list));
|
}
|
}
|
|
/**
|
* 查询港口水深数据列表
|
*/
|
@GetMapping("/getWaterListByIds")
|
@Operation(summary = "通过设备id查询水深数据列表")
|
public AjaxResult getWaterListByIds(String ids) {
|
|
LocalDate today=LocalDate.now();
|
LocalDateTime startOfDay=today.atStartOfDay();
|
LocalDateTime endOfDay=today.plusDays(1).atStartOfDay().minusSeconds(1);
|
|
|
List<ReceiveWaterValue> result=receiveWaterValueService.list(new LambdaQueryWrapper<ReceiveWaterValue>() {{
|
in(ReceiveWaterValue::getDeviceName,ids.split(","))
|
.ge(ReceiveWaterValue::getCreateTime,startOfDay)
|
.le(ReceiveWaterValue::getCreateTime,endOfDay);
|
}});
|
|
List<Map<String,Object>>res=new ArrayList<>();
|
String[] idArray=ids.split(",");
|
for (int i = 0; i < idArray.length; i++){
|
Map<String,Object> map=new HashMap<>();
|
map.put("id",idArray[i]);
|
List<ReceiveWaterValue> ds=new ArrayList<>();
|
for (int k = 0; k < result.size(); k++) {
|
ReceiveWaterValue data=result.get(k);
|
if(data.getDeviceName().equals(idArray[i])){
|
ds.add(data);
|
}
|
}
|
map.put("data",ds);
|
res.add(map);
|
}
|
|
return AjaxResult.success(res);
|
}
|
|
private JSONArray getWaterDepth(List<DmHarbor> list){
|
List<DpEquipmentVO> resList = new ArrayList<>();
|
for (DmHarbor dmHarbor : list){
|
List<DpEquipmentVO> dpEquipmentVOS = dpEquipmentService.getListByWhId(dmHarbor.getPkId().intValue());
|
for (DpEquipmentVO dpEquipmentVO : dpEquipmentVOS){
|
if(dpEquipmentVO.getEquipmentTypeId()==7){
|
ReceiveWaterValue waterValue = receiveWaterValueService.getOne(new LambdaQueryWrapper<ReceiveWaterValue>() {{
|
eq(ReceiveWaterValue::getDeviceName, String.valueOf(dpEquipmentVO.getId()))
|
.orderByDesc(ReceiveWaterValue::getCreateTime).last("LIMIT 1");
|
}});
|
if(waterValue!=null){
|
dpEquipmentVO.setFieldName(waterValue.getWaterDeep());
|
resList.add(dpEquipmentVO);
|
}
|
}
|
}
|
}
|
JSONArray jsonArray = new JSONArray();
|
for (DpEquipmentVO dpEquipmentVO : resList){
|
JSONObject jsonObject = new JSONObject();
|
jsonObject.put("equName",dpEquipmentVO.getEquName());
|
jsonObject.put("waterDeep",dpEquipmentVO.getFieldName());
|
jsonArray.add(jsonObject);
|
}
|
return jsonArray;
|
}
|
|
|
/**
|
* 导出港口信息列表
|
*/
|
// @PreAuthorize("@ss.hasPermi('system:harbor:export')")
|
// @Log(title = "港口信息", businessType = BusinessType.EXPORT)
|
// @PostMapping("/export")
|
// public void export(HttpServletResponse response, DmHarbor2 dmHarbor)
|
// {
|
// List<DmHarbor2> list = dmHarborService.selectDmHarborList(dmHarbor);
|
// ExcelUtil<DmHarbor2> util = new ExcelUtil<DmHarbor2>(DmHarbor2.class);
|
// util.exportExcel(response, list, "港口信息数据");
|
// }
|
|
/**
|
* 获取港口信息详细信息
|
*/
|
@GetMapping("/{pkId}")
|
@Operation(summary = "获取港口信息详细信息")
|
public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
|
{
|
return success(dmHarborService.getById(pkId));
|
}
|
|
/**
|
* 新增港口信息
|
*/
|
@Operation(summary = "新增港口信息")
|
@PostMapping
|
public AjaxResult add(@RequestBody DmHarbor dmHarbor)
|
{
|
return toAjax(dmHarborService.save(dmHarbor));
|
}
|
|
/**
|
* 修改港口信息
|
*/
|
@Operation(summary = "修改港口信息")
|
@PutMapping
|
public AjaxResult edit(@RequestBody DmHarbor dmHarbor)
|
{
|
return toAjax(dmHarborService.updateById(dmHarbor));
|
}
|
|
/**
|
* 删除港口信息
|
*/
|
@Operation(summary = "删除港口信息")
|
@DeleteMapping("/{pkId}")
|
public AjaxResult remove(@PathVariable Long pkId)
|
{
|
return toAjax(dmHarborService.removeById(pkId));
|
}
|
}
|