package com.ruoyi.web.controller.manage; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.buss.common.RfidUtil; import com.ruoyi.buss.domain.vo.RfIdVo; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.manage.domain.*; import com.ruoyi.manage.service.DpBerthService; import com.ruoyi.manage.service.DpShipTypeService; import com.ruoyi.manage.service.DpShipsService; import com.ruoyi.manage.service.DsTaskListService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; /** *

* 任务分配详情表 前端控制器 *

* * @author sunjiawei * @since 2025-03-24 */ @RestController @RequestMapping("/dp/dsTaskList") @Tag(name = "大屏--任务分配详情") public class DsTaskListController { @Autowired private DsTaskListService dsTaskListService; @Autowired private DpShipsService dpShipsService; @Autowired private DpShipTypeService dpShipTypeService; @Autowired private DpBerthService dpBerthService; @Autowired private RuoYiConfig ruoYiConfig; @GetMapping("/list") @Operation(summary = "任务分配详情列表") public AjaxResult getList(){ return AjaxResult.success(dsTaskListService.list()); } @GetMapping("/pageList") @Operation(summary = "任务分配详情分页列表") public TableDataInfo getPageList(DsTaskList dsTaskList) { return dsTaskListService.getPageList(dsTaskList); } @GetMapping("/pageListDaily") @Operation(summary = "日常任务分配详情分页列表") public TableDataInfo pageListDaily(DsTaskList dsTaskList) { return dsTaskListService.getPageListDaily(dsTaskList); } @GetMapping(value = "/{id}") @Operation(summary = "获取任务分配详情详细信息") public AjaxResult getInfo(@PathVariable("id") Integer pkid) { return AjaxResult.success(dsTaskListService.getById(pkid)); } @Operation(summary = "群组新增") @PostMapping public AjaxResult add(@RequestBody DsTaskList dsTaskList) { return AjaxResult.success(dsTaskListService.save(dsTaskList)); } @Operation(summary = "日常新增") @PostMapping(value = "/dailyAdd") public AjaxResult dailyAdd(@RequestBody DsTaskList dsTaskList, @RequestParam(value = "lon") Double lon, @RequestParam(value = "lat") Double lat, @RequestParam(value = "alt") Double alt, @RequestParam(value = "heading") Double heading) { String shipType = dsTaskList.getShipType(); LambdaQueryWrapper shipTypeWrapper = new LambdaQueryWrapper<>(); shipTypeWrapper.eq(DpShipType::getShipDesign,shipType); DpShipType dpShipType = dpShipTypeService.getOne(shipTypeWrapper); Integer shipTypeId = dpShipType.getId(); Integer whId = dsTaskList.getHarborId().intValue(); Integer beId = dsTaskList.getBerthId().intValue(); String shipId = dsTaskList.getShipNo(); DpShips dpShip = new DpShips(); dpShip.setShipTypeId(shipTypeId); dpShip.setWhId(whId); dpShip.setBeId(beId); dpShip.setShipId(shipId); dpShip.setShipName(shipId); dpShip.setLon(lon); dpShip.setLat(lat); dpShip.setAlt(alt); dpShip.setHeading(heading); DmBerth dmBerth =dpBerthService.getById(beId); String path = dmBerth.getPath(); boolean taskListRes = dsTaskListService.save(dsTaskList); if(taskListRes){ List list = new ArrayList<>(); RfIdVo rfIdVo = new RfIdVo(); rfIdVo.setId((999+Integer.parseInt(shipId))); rfIdVo.setName(String.valueOf(999+Integer.parseInt(shipId))); rfIdVo.setPath(path); list.add(rfIdVo); RfidUtil.sendJsonPost(ruoYiConfig.getBussRfidUrl(),list.toString()); } boolean shipRes = dpShipsService.save(dpShip); if(taskListRes && shipRes){ return AjaxResult.success(); }else { return AjaxResult.error(); } } @Operation(summary = "修改") @PutMapping public AjaxResult edit(@RequestBody DsTaskList dsTaskList) { return AjaxResult.success(dsTaskListService.updateById(dsTaskList)); } @Operation(summary = "删除") @DeleteMapping("/{pkid}") public AjaxResult remove(@PathVariable Integer pkid) { return AjaxResult.success(dsTaskListService.removeById(pkid)); } @Operation(summary = "日常任务删除") @DeleteMapping("/deleteDaily/{pkid}") public AjaxResult deleteDaily(@PathVariable Integer pkid) { DsTaskList dsTaskList = dsTaskListService.getById(pkid); LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(DpShips::getShipId,dsTaskList.getShipNo()); boolean shipRes = dpShipsService.remove(lambdaQueryWrapper); boolean taskRes = dsTaskListService.removeById(pkid); if(shipRes && taskRes){ return AjaxResult.success(); }else { return AjaxResult.error(); } } @GetMapping(value = "/getByBeId") @Operation(summary = "根据泊位ID获取任务分配详情") public R getByBeId(@RequestParam("beId") Integer beId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); lambdaQueryWrapper.eq(DsTaskList::getBerthId,beId) .eq(DsTaskList::getTaskId,999) .orderByDesc(DsTaskList::getCreateTime) .last("LIMIT 1"); return R.ok(dsTaskListService.getOne(lambdaQueryWrapper)); } }