| | |
| | | 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.AsyncListExportTaskService; |
| | | 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.common.utils.FileServerUtil; |
| | | import com.vincent.rsf.server.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.manager.entity.WarehouseAreasItem; |
| | | import com.vincent.rsf.server.manager.service.WarehouseAreasItemService; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import com.vincent.rsf.server.system.entity.ExportTask; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.BeanWrapper; |
| | | import org.springframework.beans.BeanWrapperImpl; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "库区库存明细") |
| | | @RestController |
| | | public class WarehouseAreasItemController extends BaseController { |
| | | private static final String EXPORT_RESOURCE_KEY = "warehouseAreasItem"; |
| | | private static final String EXPORT_DEFAULT_REPORT_TITLE = "收货库存报表"; |
| | | |
| | | @Autowired |
| | | private WarehouseAreasItemService warehouseAreasItemService; |
| | | |
| | | @Autowired |
| | | private ListExportService listExportService; |
| | | |
| | | @Autowired |
| | | private AsyncListExportTaskService asyncListExportTaskService; |
| | | |
| | | private final ListExportHandler<WarehouseAreasItem, BaseParam> warehouseAreasItemExportHandler = new ListExportHandler<>() { |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public String defaultReportTitle() { |
| | | return "收货库存报表"; |
| | | return EXPORT_DEFAULT_REPORT_TITLE; |
| | | } |
| | | }; |
| | | |
| | |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreasItem:list')") |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreasItem:export')") |
| | | @PostMapping("/warehouseAreasItem/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | listExportService.export( |
| | |
| | | ); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreasItem:export')") |
| | | @PostMapping("/warehouseAreasItem/export/async") |
| | | public R createAsyncExportTask(@RequestBody Map<String, Object> map) { |
| | | ExportTask task = asyncListExportTaskService.createTask( |
| | | EXPORT_RESOURCE_KEY, |
| | | EXPORT_DEFAULT_REPORT_TITLE, |
| | | map, |
| | | getTenantId(), |
| | | getLoginUserId() |
| | | ); |
| | | asyncListExportTaskService.executeAsync( |
| | | task.getId(), |
| | | EXPORT_RESOURCE_KEY, |
| | | new HashMap<>(map), |
| | | exportMap -> buildParam(exportMap, BaseParam.class), |
| | | warehouseAreasItemExportHandler |
| | | ); |
| | | return R.ok("导出任务已创建").add(buildPageRowsUtils.rowsMap(task)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreasItem:export')") |
| | | @GetMapping("/warehouseAreasItem/export/task/{taskId}") |
| | | public R getExportTask(@PathVariable("taskId") Long taskId) { |
| | | ExportTask task = asyncListExportTaskService.getTask( |
| | | taskId, |
| | | EXPORT_RESOURCE_KEY, |
| | | getTenantId(), |
| | | getLoginUserId() |
| | | ); |
| | | if (task == null) { |
| | | return R.error("导出任务不存在"); |
| | | } |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(task)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreasItem:export')") |
| | | @GetMapping("/warehouseAreasItem/export/task/{taskId}/download") |
| | | public void downloadExportTask( |
| | | @PathVariable("taskId") Long taskId, |
| | | HttpServletResponse response, |
| | | HttpServletRequest request |
| | | ) { |
| | | File file = asyncListExportTaskService.getDownloadFile( |
| | | taskId, |
| | | EXPORT_RESOURCE_KEY, |
| | | getTenantId(), |
| | | getLoginUserId() |
| | | ); |
| | | FileServerUtil.preview(file, true, file.getName(), null, null, response, request); |
| | | } |
| | | |
| | | private void fillExtendFields(List<WarehouseAreasItem> records) { |
| | | for (WarehouseAreasItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |