| | |
| | | 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.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; |
| | |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | 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.*; |
| | |
| | | private LocItemService locItemService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private ListExportService listExportService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | private final ListExportHandler<LocItem, BaseParam> locDeadReportExportHandler = new ListExportHandler<>() { |
| | | @Override |
| | | public List<LocItem> listByIds(List<Long> ids) { |
| | | return locItemService.listByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public List<LocItem> listByFilter(Map<String, Object> sanitizedMap, BaseParam baseParam) { |
| | | PageParam<LocItem, BaseParam> pageParam = new PageParam<>(baseParam, LocItem.class); |
| | | return locItemService.list(pageParam.buildWrapper(true)); |
| | | } |
| | | |
| | | @Override |
| | | public void fillExportFields(List<LocItem> records) { |
| | | fillLocItemExtendFields(records); |
| | | buildPageRowsUtils.rowsMap(records); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> toExportRow(LocItem record, List<ExcelUtil.ExportColumn> columns) { |
| | | return buildLocDeadReportExportRow(record, columns); |
| | | } |
| | | |
| | | @Override |
| | | public String defaultReportTitle() { |
| | | return "库存停滞报表"; |
| | | } |
| | | }; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @PostMapping("/locDeadReport/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | |
| | | QueryWrapper<LocItem> wrapper = pageParam.buildWrapper(true); |
| | | /**拼接扩展字段*/ |
| | | PageParam<LocItem, BaseParam> page = locItemService.page(pageParam, wrapper); |
| | | List<LocItem> records = page.getRecords(); |
| | | for (LocItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | page.setRecords(records); |
| | | fillLocItemExtendFields(page.getRecords()); |
| | | |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @PostMapping("/locDeadReport/useO/page") |
| | | public R locUseOPage(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | |
| | | locItemQueryWrapper.apply(applySql); |
| | | /**拼接扩展字段*/ |
| | | PageParam<LocItem, BaseParam> page = locItemService.page(pageParam, locItemQueryWrapper); |
| | | List<LocItem> records = page.getRecords(); |
| | | for (LocItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | page.setRecords(records); |
| | | fillLocItemExtendFields(page.getRecords()); |
| | | |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | } |
| | |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @ApiOperation("生成库存出库任务") |
| | | @PostMapping("/locDeadReport/generate/task") |
| | | public R generateTask(@RequestBody LocToTaskParams param) { |
| | |
| | | * @param map |
| | | * @return |
| | | */ |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @ApiOperation("生成盘点出库任务") |
| | | @PostMapping("/locDeadReport/check/task") |
| | | public R genStatisticalTask(@RequestBody LocToTaskParams map) { |
| | |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @PostMapping("/locDeadReport/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(locItemService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @PostMapping({"/locDeadReport/many/{ids}", "/locDeadReport/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(locItemService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @GetMapping("/locDeadReport/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(locItemService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:save')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:save')") |
| | | @OperationLog("Create 库位明细") |
| | | @PostMapping("/locDeadReport/save") |
| | | public R save(@RequestBody LocItem locItem) { |
| | |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(locItem)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:update')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:update')") |
| | | @OperationLog("Update 库位明细") |
| | | @PostMapping("/locDeadReport/update") |
| | | public R update(@RequestBody LocItem locItem) { |
| | |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(locItem)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:remove')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:remove')") |
| | | @OperationLog("Delete 库位明细") |
| | | @PostMapping("/locDeadReport/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | |
| | | return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @PostMapping("/locDeadReport/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:statisticReport:list')") |
| | | @PreAuthorize("hasAuthority('manager:stockStatistic:list')") |
| | | @PostMapping("/locDeadReport/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(locItemService.list()), LocItem.class), response); |
| | | listExportService.export( |
| | | map, |
| | | exportMap -> buildParam(exportMap, BaseParam.class), |
| | | locDeadReportExportHandler, |
| | | response |
| | | ); |
| | | } |
| | | |
| | | private void fillLocItemExtendFields(List<LocItem> records) { |
| | | for (LocItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Map<String, Object> buildLocDeadReportExportRow(LocItem record, List<ExcelUtil.ExportColumn> columns) { |
| | | BeanWrapper beanWrapper = new BeanWrapperImpl(record); |
| | | Map<String, Object> row = new LinkedHashMap<>(); |
| | | row.put("deadTime", record.getDeadTime()); |
| | | row.put("typeText", record.getType$()); |
| | | row.put("wkTypeText", record.getWkType$()); |
| | | row.put("statusText", record.getStatus$()); |
| | | row.put("createByText", record.getCreateBy$()); |
| | | row.put("createTimeText", record.getCreateTime$()); |
| | | row.put("updateByText", record.getUpdateBy$()); |
| | | row.put("updateTimeText", record.getUpdateTime$()); |
| | | |
| | | for (ExcelUtil.ExportColumn column : columns) { |
| | | if (row.containsKey(column.getSource())) { |
| | | continue; |
| | | } |
| | | if (beanWrapper.isReadableProperty(column.getSource())) { |
| | | row.put(column.getSource(), beanWrapper.getPropertyValue(column.getSource())); |
| | | } |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | } |