| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.constant.Constants; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | 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.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; |
| | | import com.vincent.rsf.server.manager.entity.Companys; |
| | | import com.vincent.rsf.server.manager.entity.LocItem; |
| | | import com.vincent.rsf.server.manager.enums.TaskResouceType; |
| | | import com.vincent.rsf.server.manager.service.CompanysService; |
| | | import com.vincent.rsf.server.manager.service.LocItemService; |
| | | import com.vincent.rsf.server.manager.service.LocService; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import com.vincent.rsf.server.manager.enums.LocStsType; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | 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 LocItemService locItemService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private CompanysService companysService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @PostMapping("/locItem/page") |
| | |
| | | } |
| | | page.setRecords(records); |
| | | |
| | | return R.ok().add(page); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | if (record.getSplrId() != null) { |
| | | Companys companys = companysService.getById(record.getSplrId()); |
| | | if (companys != null) { |
| | | record.setSplrCode(companys.getCode()).setSplrName(companys.getName()); |
| | | } |
| | | } |
| | | } |
| | | page.setRecords(records); |
| | | |
| | | return R.ok().add(page); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | } |
| | | |
| | | /** |
| | | * 生成库存出库任务 |
| | | * @param map |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @ApiOperation("生成库存出库任务") |
| | | @PostMapping("/locItem/generate/task") |
| | | public R generateTask(@RequestBody Map<String, Object> map) { |
| | | if (Objects.isNull(map)) { |
| | | public R generateTask(@RequestBody LocToTaskParams param) { |
| | | if (Objects.isNull(param)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return locItemService.generateTask(map); |
| | | param.setType(Constants.TASK_TYPE_OUT_STOCK); |
| | | |
| | | try { |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_STOCK_TYPE.val, param, getLoginUserId()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @ApiOperation("生成移库任务") |
| | | @PostMapping("/locItem/move/task") |
| | | public R genMoveTask(@RequestBody Map<String, Object> map) { |
| | | public R genMoveTask(@RequestBody LocToTaskParams map) { |
| | | if (Objects.isNull(map)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return locItemService.genMoveTask(map); |
| | | return R.ok("任务生成成功").add(buildPageRowsUtils.rowsMap(locItemService.genMoveTask(map, getLoginUserId()))); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @ApiOperation("生成盘点出库任务") |
| | | @PostMapping("/locItem/check/task") |
| | | public R genStatisticalTask(@RequestBody Map<String, Object> map) { |
| | | public R genStatisticalTask(@RequestBody LocToTaskParams map) { |
| | | if (Objects.isNull(map)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return locItemService.generateTask(map); |
| | | map.setType(Constants.TASK_TYPE_OUT_CHECK); |
| | | |
| | | try { |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val, map, getLoginUserId()); |
| | | } catch (CoolException e) { |
| | | throw e; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return R.ok("任务生成成功"); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @PostMapping("/locItem/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(locItemService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(locItemService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @PostMapping({"/locItem/many/{ids}", "/locItems/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(locItemService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(locItemService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @GetMapping("/locItem/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(locService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(locItemService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:save')") |
| | |
| | | if (!locItemService.save(locItem)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(locItem); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(locItem)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:update')") |
| | |
| | | if (!locItemService.updateById(locItem)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(locItem); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(locItem)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:remove')") |
| | |
| | | if (!locItemService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | |
| | | locItemService.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:locItem:list')") |
| | | @PostMapping("/locItem/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(locItemService.list(), LocItem.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(locItemService.list()), LocItem.class), response); |
| | | } |
| | | |
| | | } |