| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.manager.entity.LocItem; |
| | | import com.vincent.rsf.server.manager.entity.WaitPakinItem; |
| | | import com.vincent.rsf.server.manager.controller.params.WarehouseStockParam; |
| | | import com.vincent.rsf.server.manager.entity.StockItem; |
| | | import com.vincent.rsf.server.manager.entity.ViewStockManage; |
| | | import com.vincent.rsf.server.manager.enums.ViewStockType; |
| | | import com.vincent.rsf.server.manager.service.WarehouseStockService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @PostMapping("/page") |
| | | public R page(@RequestBody Map<String, Object> param) { |
| | | if (Objects.isNull(param)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | BaseParam baseParam = buildParam(param, BaseParam.class); |
| | | PageParam<LocItem, BaseParam> pageParam = new PageParam<>(baseParam, LocItem.class); |
| | | QueryWrapper<LocItem> queryWrapper = pageParam.buildWrapper(true); |
| | | IPage<LocItem> pageResult = warehouseStockService.pageByStock(pageParam, queryWrapper); |
| | | List<LocItem> records = pageResult.getRecords(); |
| | | for (LocItem record : records) { |
| | | PageParam<ViewStockManage, BaseParam> pageParam = new PageParam<>(baseParam, ViewStockManage.class); |
| | | WarehouseStockParam stockParam = JSONObject.parseObject(JSONObject.toJSONString(param), WarehouseStockParam.class); |
| | | String type = stockParam.getAggType(); |
| | | ViewStockManage stock = stockParam.getStock(); |
| | | QueryWrapper<ViewStockManage> wrapper = new QueryWrapper<>(); |
| | | |
| | | if (type.equals(ViewStockType.VIEW_STOCK_TYPE_SUPPLIER.val)) { |
| | | wrapper.groupBy("splr_id"); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_BATCH.val)) { |
| | | wrapper.groupBy("batch"); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_WAREHOUSE.val)) { |
| | | wrapper.groupBy("warehouse"); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_FIELDSINDEX.val)) { |
| | | wrapper.groupBy("fields_index"); |
| | | } else { |
| | | wrapper.groupBy("matnr_id"); |
| | | } |
| | | IPage<ViewStockManage> pageResult = warehouseStockService.pageByStock(pageParam, wrapper); |
| | | List<ViewStockManage> records = pageResult.getRecords(); |
| | | for (ViewStockManage record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | pageResult.setRecords(records); |
| | | |
| | | return R.ok(pageResult); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @PostMapping("/histories/page") |
| | | public R histories(@RequestBody Map<String, Object> param) { |
| | | if (Objects.isNull(param)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | BaseParam baseParam = buildParam(param, BaseParam.class); |
| | | PageParam<StockItem, BaseParam> pageParam = new PageParam<>(baseParam, StockItem.class); |
| | | WarehouseStockParam stockParam = JSONObject.parseObject(JSONObject.toJSONString(param), WarehouseStockParam.class); |
| | | String type = stockParam.getAggType(); |
| | | ViewStockManage stock = stockParam.getStock(); |
| | | QueryWrapper<StockItem> wrapper = new QueryWrapper<>(); |
| | | |
| | | if (type.equals(ViewStockType.VIEW_STOCK_TYPE_SUPPLIER.val)) { |
| | | wrapper.eq("splr_id", stock.getSplrId()); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_BATCH.val)) { |
| | | wrapper.eq("batch", stock.getBatch()); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_WAREHOUSE.val)) { |
| | | wrapper.eq("warehouse", stock.getWarehouse()); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_FIELDSINDEX.val)) { |
| | | wrapper.eq("fields_index", stock.getFieldsIndex()); |
| | | } else { |
| | | wrapper.eq("matnr_id", stock.getMatnrId()); |
| | | } |
| | | IPage<StockItem> pageResult = warehouseStockService.pageByHistories(pageParam, wrapper); |
| | | |
| | | List<StockItem> records = pageResult.getRecords(); |
| | | for (StockItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | pageResult.setRecords(records); |
| | | |
| | | return R.ok(pageResult); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:locItem:list')") |
| | | @PostMapping("/info") |
| | | public R stockInfo(@RequestBody Map<String, Object> param) { |
| | | if (Objects.isNull(param)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | BaseParam baseParam = buildParam(param, BaseParam.class); |
| | | PageParam<ViewStockManage, BaseParam> pageParam = new PageParam<>(baseParam, ViewStockManage.class); |
| | | WarehouseStockParam stockParam = JSONObject.parseObject(JSONObject.toJSONString(param), WarehouseStockParam.class); |
| | | String type = stockParam.getAggType(); |
| | | if (Objects.isNull(type)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | ViewStockManage stock = stockParam.getStock(); |
| | | LambdaQueryWrapper<ViewStockManage> wrapper = new LambdaQueryWrapper<ViewStockManage>(); |
| | | |
| | | if (type.equals(ViewStockType.VIEW_STOCK_TYPE_SUPPLIER.val)) { |
| | | wrapper.eq(ViewStockManage::getSplrId, stock.getSplrId()); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_BATCH.val)) { |
| | | wrapper.eq(ViewStockManage::getBatch, stock.getBatch()); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_WAREHOUSE.val)) { |
| | | wrapper.eq(ViewStockManage::getWarehouse, stock.getWarehouse()); |
| | | } else if (type.equals(ViewStockType.VIEW_STOCK_TYPE_FIELDSINDEX.val)) { |
| | | wrapper.eq(ViewStockManage::getFieldsIndex, stock.getFieldsIndex()); |
| | | } else { |
| | | wrapper.eq(ViewStockManage::getMatnrCode, stock.getMatnrCode()); |
| | | } |
| | | |
| | | return R.ok(warehouseStockService.page(pageParam, wrapper)); |
| | | } |
| | | |
| | | } |