|  |  |  | 
|---|
|  |  |  | 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.entity.WarehouseAreasItem; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 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.PostMapping; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | String type = Objects.isNull(stockParam.getAggType()) ? ViewStockType.VIEW_STOCK_TYPE_MATNR.val : stockParam.getAggType(); | 
|---|
|  |  |  | ViewStockManage stock = stockParam.getStock(); | 
|---|
|  |  |  | QueryWrapper<ViewStockManage> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wrapper.groupBy("matnr_id"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | FieldsUtils.setFieldsFilters(wrapper, pageParam, ViewStockManage.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<ViewStockManage> pageResult = warehouseStockService.pageByStock(pageParam, wrapper); | 
|---|
|  |  |  | List<ViewStockManage> records = pageResult.getRecords(); | 
|---|
|  |  |  | for (ViewStockManage record : records) { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | String type = Objects.isNull(stockParam.getAggType()) ? ViewStockType.VIEW_STOCK_TYPE_MATNR.val : stockParam.getAggType(); | 
|---|
|  |  |  | ViewStockManage stock = stockParam.getStock(); | 
|---|
|  |  |  | QueryWrapper<StockItem> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | String type = Objects.isNull(stockParam.getAggType()) ? ViewStockType.VIEW_STOCK_TYPE_MATNR.val : stockParam.getAggType(); | 
|---|
|  |  |  | if (Objects.isNull(type)) { | 
|---|
|  |  |  | return R.error("参数不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } 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()); | 
|---|
|  |  |  | if (StringUtils.isBlank(stock.getFieldsIndex())) { | 
|---|
|  |  |  | wrapper.isNull(ViewStockManage::getFieldsIndex); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wrapper.eq(ViewStockManage::getFieldsIndex, stock.getFieldsIndex()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wrapper.eq(ViewStockManage::getMatnrCode, stock.getMatnrCode()); | 
|---|
|  |  |  | } | 
|---|