zhou zhou
1 天以前 1dcfa3702505f0c431757312b5304531029f90f6
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WaveController.java
@@ -9,6 +9,7 @@
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.common.domain.PageResult;
import com.vincent.rsf.server.common.utils.ExcelUtil;
import com.vincent.rsf.server.common.utils.OptimisticLockUtils;
import com.vincent.rsf.server.common.annotation.OperationLog;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.KeyValVo;
@@ -25,6 +26,7 @@
import com.vincent.rsf.server.manager.service.WaveService;
import com.vincent.rsf.server.manager.service.impl.TaskItemLogServiceImpl;
import com.vincent.rsf.server.manager.service.impl.WaveItemServiceImpl;
import com.vincent.rsf.server.manager.utils.buildPageRowsUtils;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@@ -32,7 +34,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
@RestController
@@ -54,25 +56,26 @@
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<Wave, BaseParam> pageParam = new PageParam<>(baseParam, Wave.class);
        return R.ok().add(waveService.page(pageParam, pageParam.buildWrapper(true)));
        PageParam<Wave, BaseParam> page = waveService.page(pageParam, pageParam.buildWrapper(true));
        return R.ok().add(buildPageRowsUtils.rowsMap(page));
    }
    @PreAuthorize("hasAuthority('manager:wave:list')")
    @PostMapping("/wave/list")
    public R list(@RequestBody Map<String, Object> map) {
        return R.ok().add(waveService.list());
        return R.ok().add(buildPageRowsUtils.rowsMap(waveService.list()));
    }
    @PreAuthorize("hasAuthority('manager:wave:list')")
    @PostMapping({"/wave/many/{ids}", "/waves/many/{ids}"})
    public R many(@PathVariable Long[] ids) {
        return R.ok().add(waveService.listByIds(Arrays.asList(ids)));
        return R.ok().add(buildPageRowsUtils.rowsMap(waveService.listByIds(Arrays.asList(ids))));
    }
    @PreAuthorize("hasAuthority('manager:wave:list')")
    @GetMapping("/wave/{id}")
    public R get(@PathVariable("id") Long id) {
        return R.ok().add(waveService.getById(id));
        return R.ok().add(buildPageRowsUtils.rowsMap(waveService.getById(id)));
    }
    @PreAuthorize("hasAuthority('manager:wave:save')")
@@ -84,19 +87,20 @@
        if (!waveService.save(wave)) {
            return R.error("Save Fail");
        }
        return R.ok("Save Success").add(wave);
        return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(wave));
    }
    @PreAuthorize("hasAuthority('manager:wave:update')")
    @OperationLog("Update 波次单据")
    @PostMapping("/wave/update")
    public R update(@RequestBody Wave wave) {
        OptimisticLockUtils.requireVersion("波次", wave.getVersion());
        wave.setUpdateBy(getLoginUserId());
        wave.setUpdateTime(new Date());
        if (!waveService.updateById(wave)) {
            return R.error("Update Fail");
        }
        return R.ok("Update Success").add(wave);
        return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(wave));
    }
    @PreAuthorize("hasAuthority('manager:wave:remove')")
@@ -125,13 +129,13 @@
        waveService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
                item -> vos.add(new KeyValVo(item.getId(), item.getId()))
        );
        return R.ok().add(vos);
        return R.ok().add(buildPageRowsUtils.rowsMap(vos));
    }
    @PreAuthorize("hasAuthority('manager:wave:list')")
    @PostMapping("/wave/export")
    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
        ExcelUtil.build(ExcelUtil.create(waveService.list(), Wave.class), response);
        ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(waveService.list()), Wave.class), response);
    }
    @PreAuthorize("hasAuthority('manager:wave:update')")
@@ -165,16 +169,21 @@
        List<WaveItem> waveItems = waveService.mergeWavePreview(waveId);
        PageResult<WaveItem> pageResult = new PageResult<>();
        pageResult.setRecords(waveItems).setTotal(Long.parseLong(waveItems.size() + ""));
        return R.ok().add(pageResult);
        return R.ok().add(buildPageRowsUtils.rowsMap(pageResult));
    }
    @PreAuthorize("hasAuthority('manager:waveItem:update')")
    @ApiOperation("暂停下发任务")
    @PostMapping("/wave/pause/pub/{id}")
    public R pausePublicTask(@PathVariable Long id) {
        waveService.update(new LambdaUpdateWrapper<Wave>()
                .eq(Wave::getId, id)
                .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_PAUSE.val));
        Wave wave = waveService.getById(id);
        if (Objects.isNull(wave)) {
            throw new CoolException("波次数据不存在!!");
        }
        wave.setExceStatus(WaveExceStatus.WAVE_EXCE_STATUS_PAUSE.val);
        if (!waveService.updateById(wave)) {
            throw new CoolException("波次状态修改失败!!");
        }
        return R.ok();
    }
@@ -182,9 +191,14 @@
    @ApiOperation("继续下发任务")
    @PostMapping("/wave/continue/pub/{id}")
    public R continuePublicTask(@PathVariable Long id) {
        waveService.update(new LambdaUpdateWrapper<Wave>()
                .eq(Wave::getId, id)
                .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val));
        Wave wave = waveService.getById(id);
        if (Objects.isNull(wave)) {
            throw new CoolException("波次数据不存在!!");
        }
        wave.setExceStatus(WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val);
        if (!waveService.updateById(wave)) {
            throw new CoolException("波次状态修改失败!!");
        }
        return R.ok();
    }
@@ -196,6 +210,15 @@
        if (Objects.isNull(id)) {
            return R.error("参数不能为空!!");
        }
        Wave wave = waveService.getById(id);
        if (Objects.isNull(wave)) {
            throw new CoolException("波次数据不存在!!");
        }
        wave.setExceStatus(WaveExceStatus.WAVE_EXCE_STATUS_PAUSE.val);
        if (!waveService.updateById(wave)) {
            throw new CoolException("波次状态修改失败!!");
        }
        return waveService.stopPubTask(id);
    }