| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.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.service.ListExportHandler; |
| | | import com.vincent.rsf.server.common.service.ListExportService; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.manager.controller.params.WarehouseAreaParam; |
| | | import com.vincent.rsf.server.manager.entity.Loc; |
| | | import com.vincent.rsf.server.manager.entity.WarehouseAreas; |
| | |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanWrapper; |
| | | import org.springframework.beans.BeanWrapperImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.*; |
| | | |
| | | @Api(tags = "仓库库区") |
| | |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | @Autowired |
| | | private ListExportService listExportService; |
| | | |
| | | private final ListExportHandler<WarehouseAreas, BaseParam> warehouseAreasExportHandler = new ListExportHandler<>() { |
| | | @Override |
| | | public List<WarehouseAreas> listByIds(List<Long> ids) { |
| | | return warehouseAreasService.listByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public List<WarehouseAreas> listByFilter(Map<String, Object> sanitizedMap, BaseParam baseParam) { |
| | | PageParam<WarehouseAreas, BaseParam> pageParam = new PageParam<>(baseParam, WarehouseAreas.class); |
| | | QueryWrapper<WarehouseAreas> queryWrapper = pageParam.buildWrapper(true); |
| | | return warehouseAreasService.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> toExportRow(WarehouseAreas record, List<ExcelUtil.ExportColumn> columns) { |
| | | BeanWrapper beanWrapper = new BeanWrapperImpl(record); |
| | | Map<String, Object> row = new LinkedHashMap<>(); |
| | | |
| | | for (ExcelUtil.ExportColumn column : columns) { |
| | | if (beanWrapper.isReadableProperty(column.getSource())) { |
| | | row.put(column.getSource(), beanWrapper.getPropertyValue(column.getSource())); |
| | | } |
| | | } |
| | | |
| | | return row; |
| | | } |
| | | |
| | | @Override |
| | | public String defaultReportTitle() { |
| | | return "仓库库区报表"; |
| | | } |
| | | }; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreas:list')") |
| | | @PostMapping("/warehouseAreas/page") |
| | |
| | | @PostMapping("/warehouseAreas/update") |
| | | public R update(@RequestBody WarehouseAreas warehouseAreas) { |
| | | warehouseAreas.setUpdateBy(getLoginUserId()); |
| | | WarehouseAreas areas = warehouseAreasService.getById(warehouseAreas.getWarehouseId()); |
| | | WarehouseAreas areas = warehouseAreasService.getById(warehouseAreas.getId()); |
| | | if (Objects.isNull(areas)) { |
| | | throw new CoolException("数据错误:仓库库区不存在!!"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | warehouseAreas.setUpdateTime(new Date()); |
| | | if (!warehouseAreasService.updateById(warehouseAreas)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreas:list')") |
| | | @PostMapping("/warehouseAreas/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(warehouseAreasService.list(), WarehouseAreas.class), response); |
| | | listExportService.export( |
| | | map, |
| | | exportMap -> buildParam(exportMap, BaseParam.class), |
| | | warehouseAreasExportHandler, |
| | | response |
| | | ); |
| | | } |
| | | |
| | | } |