package com.ruoyi.buss.controller;
|
|
import com.ruoyi.buss.domain.DmHarbor2;
|
import com.ruoyi.buss.domain.DsMatDispatch2;
|
import com.ruoyi.buss.service.IDmHarbor2Service;
|
import com.ruoyi.buss.service.IDsMatDispatch2Service;
|
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.domain.model.LoginUser;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.utils.StringUtils;
|
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.Date;
|
import java.util.List;
|
|
@Tag(name = "跨港区调度接口")
|
@RestController
|
@RequestMapping("/buss/matdispatch")
|
public class DsMatDispatch2Controller extends BaseController {
|
|
private static String STATUS_1 = "1"; // 未提交
|
private static String STATUS_2 = "2"; // 审批中
|
private static String STATUS_3 = "3"; // 审批通过
|
private static String STATUS_4 = "4"; // 驳回
|
|
|
@Autowired
|
private IDmHarbor2Service iDmHarbor2Service;
|
|
@Autowired
|
private IDsMatDispatch2Service iDsMatDispatch2Service;
|
|
@Operation(summary = "获取任务列表")
|
@PostMapping("/list/all")
|
@ResponseBody
|
public AjaxResult list() {
|
List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchForApply();
|
if(null != list){
|
return success(list);
|
}
|
return error("获取任务列表失败,请重试");
|
}
|
|
@Operation(summary = "根据条件获取任务列表")
|
@PostMapping("/list/param")
|
@ResponseBody
|
public AjaxResult list(DsMatDispatch2 dsMatDispatch2) {
|
List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchList(dsMatDispatch2);
|
if(null != list){
|
return success(list);
|
}
|
return error("获取任务列表失败,请重试");
|
}
|
|
@Operation(summary = "获取自己权限内的任务列表")
|
@PostMapping("/list/self")
|
@ResponseBody
|
public AjaxResult list3(@RequestParam(value = "status", required = false) String status) {
|
List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchByDeptId(getDeptId(), status);
|
if(null != list){
|
return success(list);
|
}
|
return error("获取任务列表失败,请重试");
|
}
|
|
@Operation(summary = "获取任务列表")
|
@PostMapping("/list")
|
@ResponseBody
|
public AjaxResult list2(@RequestParam(value = "status", required = false) String status) {
|
LoginUser loginUser = getLoginUser();
|
DsMatDispatch2 dsMatDispatch2 = new DsMatDispatch2();
|
dsMatDispatch2.setResHarborId(loginUser.getDeptId().toString());
|
if(StringUtils.isNotBlank(status)){
|
dsMatDispatch2.setStatus(status);
|
}
|
List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchList(dsMatDispatch2);
|
if(null != list){
|
return success(list);
|
}
|
return error("获取任务列表失败,请重试");
|
}
|
|
@Operation(summary = "获取自己新建的任务列表")
|
@PostMapping("/list2")
|
@ResponseBody
|
public AjaxResult list2() {
|
LoginUser loginUser = getLoginUser();
|
DsMatDispatch2 dsMatDispatch2 = new DsMatDispatch2();
|
dsMatDispatch2.setResHarborId(loginUser.getDeptId().toString());
|
dsMatDispatch2.setResHarborName(loginUser.getUsername());
|
List<DsMatDispatch2> list = iDsMatDispatch2Service.selectDsMatDispatchList(new DsMatDispatch2());
|
if(null != list){
|
return success(list);
|
}
|
return error("获取任务列表失败,请重试");
|
}
|
|
@Operation(summary = "任务提交审批")
|
@PostMapping("/apply/{id}")
|
@ResponseBody
|
public AjaxResult toApply(@PathVariable("id") Long id) {
|
DsMatDispatch2 matDispatch2 = iDsMatDispatch2Service.selectDsMatDispatchById(id);
|
if(null != matDispatch2){
|
if(matDispatch2.getStatus().equals(STATUS_1)){
|
matDispatch2.setStatus(STATUS_2);
|
matDispatch2.setUpdateBy(getUsername());
|
matDispatch2.setUpdateTime(new Date());
|
int rst = iDsMatDispatch2Service.updateDsMatDispatch(matDispatch2);
|
if(rst > 0){
|
return success("提交审批成功");
|
}
|
else {
|
return error("提交审批失败");
|
}
|
}
|
else {
|
return error("当前任务不可提交审批");
|
}
|
}
|
else{
|
return error("获取任务失败,请重试");
|
}
|
}
|
|
@Operation(summary = "任务审批")
|
@PostMapping("/prove")
|
@ResponseBody
|
public AjaxResult prove(@RequestBody DsMatDispatch2 dsMatDispatch2) {
|
if(null != dsMatDispatch2 && null != dsMatDispatch2.getId()){
|
DsMatDispatch2 matDispatch2 = iDsMatDispatch2Service.selectDsMatDispatchById(dsMatDispatch2.getId());
|
DmHarbor2 harborRes = null;
|
List<DmHarbor2> harbor2List = iDmHarbor2Service.selectDmHarborList(new DmHarbor2());
|
for(DmHarbor2 harbor2 : harbor2List){
|
if(StringUtils.isNotBlank(dsMatDispatch2.getDesHarborId()) && harbor2.getPKID().toString().equals(dsMatDispatch2.getDesHarborId())){
|
harborRes = harbor2;
|
}
|
}
|
if(null != matDispatch2){
|
if(matDispatch2.getStatus().equals(STATUS_2)){
|
if(dsMatDispatch2.getApplyResult().equals("1")){
|
matDispatch2.setStatus(STATUS_3);
|
}
|
else{
|
matDispatch2.setStatus(STATUS_4);
|
}
|
|
matDispatch2.setApplyResult(dsMatDispatch2.getApplyResult());
|
matDispatch2.setApplyTime(new Date());
|
matDispatch2.setApplyContent(dsMatDispatch2.getApplyContent());
|
matDispatch2.setApplyBy(getUsername());
|
matDispatch2.setUpdateBy(getUsername());
|
matDispatch2.setUpdateTime(new Date());
|
if(null != harborRes){
|
matDispatch2.setResHarborId(harborRes.getDeptId().toString());
|
matDispatch2.setResHarborName(harborRes.getDeptName());
|
}
|
int rst = iDsMatDispatch2Service.updateDsMatDispatch(matDispatch2);
|
if(rst > 0){
|
return success("审批成功");
|
}
|
else {
|
return error("审批失败");
|
}
|
}
|
else {
|
return error("当前任务不可审批");
|
}
|
}
|
else{
|
return error("获取任务失败,请重试");
|
}
|
}
|
return error("参数失败,需要");
|
}
|
|
/**
|
* 新增保存泊位信息
|
*/
|
@Operation(summary="新增跨港区调度信息")
|
@Log(title = "跨港区调度信息", businessType = BusinessType.INSERT)
|
@PostMapping("/add")
|
@ResponseBody
|
public AjaxResult addSave(@RequestBody DsMatDispatch2 dsMatDispatch2) {
|
if(null == dsMatDispatch2){
|
return error("参数不能为空");
|
}
|
if(StringUtils.isBlank(dsMatDispatch2.getContent())){
|
return error("调度内容不能为空");
|
}
|
LoginUser loginUser = getLoginUser();
|
dsMatDispatch2.setResHarborId(loginUser.getDeptId().toString());
|
dsMatDispatch2.setResHarborName(loginUser.getUsername());
|
dsMatDispatch2.setCreateTime(new Date());
|
dsMatDispatch2.setCreateBy(getUsername());
|
dsMatDispatch2.setStatus(STATUS_1);
|
return toAjax(iDsMatDispatch2Service.insertDsMatDispatch(dsMatDispatch2));
|
}
|
|
/**
|
* 修改保存泊位信息
|
*/
|
@Operation(summary="修改保存跨港区调度信息")
|
@Log(title = "跨港区调度信息", businessType = BusinessType.UPDATE)
|
@PostMapping("/edit")
|
@ResponseBody
|
public AjaxResult editSave(DsMatDispatch2 dsMatDispatch2)
|
{
|
return toAjax(iDsMatDispatch2Service.updateDsMatDispatch(dsMatDispatch2));
|
}
|
|
/**
|
* 删除泊位信息
|
*/
|
@Operation(summary="删除跨港区调度信息")
|
@Log(title = "泊位信息", businessType = BusinessType.DELETE)
|
@PostMapping( "/remove/{id}")
|
@ResponseBody
|
public AjaxResult remove(@PathVariable("id") Long id)
|
{
|
return toAjax(iDsMatDispatch2Service.deleteDsMatDispatchById(id));
|
}
|
|
}
|