| | |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.manager.controller.params.AsnOrderAndItemsParams; |
| | | import com.vincent.rsf.server.manager.controller.params.OrderOutTaskParam; |
| | | import com.vincent.rsf.server.manager.entity.WkOrder; |
| | | import com.vincent.rsf.server.manager.entity.excel.CheckOrderTemplate; |
| | | import com.vincent.rsf.server.manager.enums.CheckExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.service.CheckOrderService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api("盘点") |
| | | @RestController |
| | |
| | | @OperationLog("Delete 字典数据集") |
| | | @PostMapping("/check/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!checkOrderService.removeByIds(Arrays.asList(ids))) { |
| | | if (Objects.isNull(ids)) { |
| | | throw new RuntimeException("盘点单ID不能为空!!"); |
| | | } |
| | | List<WkOrder> wkOrders = checkOrderService.list(new LambdaQueryWrapper<WkOrder>().in(WkOrder::getId, Arrays.asList(ids))); |
| | | if (wkOrders.isEmpty()) { |
| | | return R.ok(); |
| | | } |
| | | List<WkOrder> orders = wkOrders.stream().filter(order -> order.getExceStatus().equals(CheckExceStatus.CHECK_ORDER_STATUS_UN_EXCE.val)).collect(Collectors.toList()); |
| | | if (orders.isEmpty()) { |
| | | return R.ok(); |
| | | } |
| | | List<Long> orderIds = orders.stream().map(WkOrder::getId).collect(Collectors.toList()); |
| | | if (!checkOrderService.removeByIds(orderIds)) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:update')") |
| | | @ApiOperation("取消盘点单据") |
| | | @GetMapping("/check/cancel/{id}") |
| | | public R cancel(@PathVariable Long id) { |
| | | if (Objects.isNull(id)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return checkOrderService.cancelCheckOrder(id); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | |
| | | } |
| | | |
| | | @PostMapping("/check/items/save") |
| | | @ApiOperation("保存主单及明细") |
| | | @ApiOperation("保存盘点单及明细") |
| | | @PreAuthorize("hasAuthority('manager:check:save')") |
| | | public R saveOutStock(@RequestBody AsnOrderAndItemsParams params) throws Exception { |
| | | if (Objects.isNull(params)) { |
| | |
| | | return checkOrderService.saveCheckOrder(params, getLoginUserId()); |
| | | } |
| | | |
| | | @ApiOperation("盘点单信息修改") |
| | | @PostMapping("/check/items/update") |
| | | @PreAuthorize("hasAuthority('manager:check:update')") |
| | | public R orderAndrItemUpdate(@RequestBody AsnOrderAndItemsParams params) throws Exception { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return checkOrderService.updateOrderItem(params, getLoginUserId()); |
| | | } |
| | | |
| | | @PostMapping("/check/order/items") |
| | | @ApiOperation("盘点出库预览") |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | public R getOrderOutTaskItem(@RequestBody OrderOutTaskParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | return checkOrderService.genCheckPreview(param); |
| | | } |
| | | |
| | | /** |
| | | * 获取出库站点 |
| | | * @return |
| | | */ |
| | | @GetMapping("/check/tasks/sites") |
| | | @ApiOperation("获取盘点出库口") |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | public R getSiteNos() { |
| | | return checkOrderService.getSiteNos(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("获取在库物料列表") |
| | | @PostMapping("/check/locs/{matnrs}") |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | public R getAllLocByMatnr(@PathVariable String[] matnrs) { |
| | | if (Objects.isNull(matnrs)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return checkOrderService.getAllLocByMatnr(Arrays.asList(matnrs)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 下载模板 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/18 08:17 |
| | | */ |
| | | @PostMapping("/check/template/download") |
| | | @ApiOperation("下载盘点单模板") |
| | | @PreAuthorize("hasAuthority('manager:check:update')") |
| | | public void downloadTemplate(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | CheckOrderTemplate template = ExcelUtil.mockData(CheckOrderTemplate.class); |
| | | List<CheckOrderTemplate> list = Arrays.asList(template); |
| | | ExcelUtil.build(ExcelUtil.create(list, CheckOrderTemplate.class, true), response); |
| | | } |
| | | |
| | | /** |
| | | * 盘点单导入 |
| | |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | return checkOrderService.excelImport(file, hashMap, getLoginUserId()); |
| | | } |
| | | |
| | | |
| | | } |