| | |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderService; |
| | | import com.vincent.rsf.server.manager.service.OutStockItemService; |
| | | import com.vincent.rsf.server.manager.service.OutStockService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | public class OutStockController extends BaseController { |
| | | |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | private OutStockService outStockService; |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | private OutStockItemService outStockItemService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:list')") |
| | | @PostMapping("/outStock/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AsnOrder, BaseParam> pageParam = new PageParam<>(baseParam, AsnOrder.class); |
| | | return R.ok().add(asnOrderService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(outStockService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:list')") |
| | | @PostMapping("/outStock/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(asnOrderService.list(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getType, OrderType.ORDER_OUT.type))); |
| | | return R.ok().add(outStockService.list(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getType, OrderType.ORDER_OUT.type))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:list')") |
| | | @PostMapping({"/outStock/many/{ids}", "/asnOrders/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(asnOrderService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(outStockService.listByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:list')") |
| | | @PreAuthorize("hasAuthority('manager:outStock:list')") |
| | | @OperationLog("表单查询") |
| | | @GetMapping("/outStock/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(asnOrderService.getById(id)); |
| | | return R.ok().add(outStockService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:save')") |
| | |
| | | public R save(@RequestBody AsnOrder asnOrder) { |
| | | asnOrder.setCreateBy(getLoginUserId()) |
| | | .setUpdateBy(getLoginUserId()); |
| | | if (!Objects.isNull(asnOrder.getCode())) { |
| | | String code = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, asnOrder); |
| | | asnOrder.setCode(code); |
| | | if (Objects.isNull(asnOrder.getCode())) { |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, asnOrder); |
| | | if (Objects.isNull(ruleCode) || StringUtils.isBlank(ruleCode)) { |
| | | return R.error("编码规则错误:编码「SYS_OUT_STOCK_CODE」是未设置成功!!"); |
| | | } |
| | | asnOrder.setCode(ruleCode); |
| | | } |
| | | if (!asnOrderService.save(asnOrder)) { |
| | | if (!outStockService.save(asnOrder)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(asnOrder); |
| | |
| | | asnOrder.setType(OrderType.ORDER_OUT.type) |
| | | .setUpdateBy(getLoginUserId()) |
| | | .setUpdateTime(new Date()); |
| | | if (!asnOrderService.updateById(asnOrder)) { |
| | | if (Objects.isNull(asnOrder.getCode())) { |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, asnOrder); |
| | | asnOrder.setCode(ruleCode); |
| | | } |
| | | if (!outStockService.updateById(asnOrder)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(asnOrder); |
| | |
| | | @OperationLog("Delete 出库单据") |
| | | @PostMapping("/outStock/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!asnOrderService.removeByIds(Arrays.asList(ids))) { |
| | | if (!outStockService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(AsnOrder::getCode, condition); |
| | | } |
| | | asnOrderService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | outStockService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getCode())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:update')") |
| | | @ApiOperation("取消出库单据") |
| | | @GetMapping("/outStock/cancel/{id}") |
| | | public R cancel(@PathVariable String id) { |
| | | if (Objects.isNull(id)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return outStockService.cancelOutOrder(id); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:outStock:list')") |
| | | @PostMapping("/outStock/export") |
| | |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | List<Long> ids = JSONArray.parseArray(JSONObject.toJSONString(map.get("ids")), Long.class); |
| | | if (!ids.isEmpty()) { |
| | | orders = asnOrderService.list(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, ids)); |
| | | orders = outStockService.list(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, ids)); |
| | | } else { |
| | | orders = asnOrderService.list(new LambdaQueryWrapper<>()); |
| | | orders = outStockService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | } else { |
| | | orders = asnOrderService.list(); |
| | | orders = outStockService.list(); |
| | | } |
| | | List<AsnOrderTemplate> orderTemplates = new ArrayList<>(); |
| | | for (AsnOrder order : orders) { |
| | | List<AsnOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, order.getId())); |
| | | List<AsnOrderItem> orderItems = outStockItemService.list(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, order.getId())); |
| | | for (AsnOrderItem item : orderItems) { |
| | | if (Objects.isNull(item)) { |
| | | continue; |