| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | |
| | | 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; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.entity.TaskItem; |
| | | import com.vincent.rsf.server.manager.entity.TaskItemLog; |
| | | import com.vincent.rsf.server.manager.entity.Wave; |
| | | import com.vincent.rsf.server.manager.entity.WaveItem; |
| | | import com.vincent.rsf.server.manager.enums.WaveExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.WaveItemExceStatus; |
| | | import com.vincent.rsf.server.manager.service.OutStockService; |
| | | import com.vincent.rsf.server.manager.service.TaskItemLogService; |
| | | import com.vincent.rsf.server.manager.service.TaskItemService; |
| | | 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; |
| | |
| | | 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 |
| | |
| | | private WaveService waveService; |
| | | @Autowired |
| | | private TaskItemService taskItemService; |
| | | @Autowired |
| | | private OutStockService outStockService; |
| | | @Autowired |
| | | private TaskItemLogService taskItemLogService; |
| | | @Autowired |
| | | private WaveItemServiceImpl waveItemService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:wave:list')") |
| | | @PostMapping("/wave/page") |
| | | 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')") |
| | |
| | | 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')") |
| | |
| | | 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')") |
| | |
| | | @ApiOperation("选择明细下发任务") |
| | | @PostMapping("/wave/selects/task") |
| | | public R waveToTask(@RequestBody Map<String, Object> map) { |
| | | if (Cools.isEmpty(map) || Cools.isEmpty(map.get("wave"))) { |
| | | if (Cools.isEmpty(map) || Cools.isEmpty(map.get("ids"))) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | return waveService.waveToTask(map, getLoginUserId()); |
| | |
| | | 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) { |
| | | 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(); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waveItem:update')") |
| | | @ApiOperation("继续下发任务") |
| | | @PostMapping("/wave/continue/pub/{id}") |
| | | public R continuePublicTask(@PathVariable Long id) { |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waveItem:update')") |
| | | @ApiOperation("终止下发任务") |
| | | @PostMapping("/wave/stop/pub/{id}") |
| | | public R stopPublicTask(@PathVariable Long id) { |
| | | 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); |
| | | } |
| | | |
| | | } |