| | |
| | | import com.consum.base.pojo.RecordUserInfoVO; |
| | | import com.consum.base.pojo.UseRecordSkuVO; |
| | | import com.consum.base.pojo.dto.UseRecordDTO; |
| | | import com.consum.base.pojo.excel.TransferExcelTemplate; |
| | | import com.consum.base.pojo.query.TransferQry; |
| | | import com.consum.base.pojo.request.LWhFormTransferParam; |
| | | import com.consum.base.pojo.request.ProcureModelInfoParam; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | /** |
| | | * @Description 导出调拨出库单 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | |
| | | @ApiOperation(value = "调拨单导出", notes = "调拨单导出") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"), |
| | | @ApiImplicitParam(name = "type", value = "导出类型 1 入库 2 出库", required = true, dataType = "Integer"), |
| | | }) |
| | | @GetMapping("/list/export") |
| | | public void export(Long id, Integer type, HttpServletResponse response) throws IOException { |
| | | public void export(Long id, Integer type, HttpServletResponse response) throws Exception { |
| | | |
| | | TemplateExportParams params; |
| | | String fileName; |
| | | if (type == 1) { |
| | | params = new TemplateExportParams("import/调拨入库单.xls"); |
| | | fileName = "调拨入库单"; |
| | | } else { |
| | | params = new TemplateExportParams("import/调拨出库单.xls"); |
| | | fileName = "调拨出库单"; |
| | | } |
| | | Map<String, Object> map = this.lWhFormTransferService.export(id, type); |
| | | params.setHeadingStartRow(2); |
| | | List<TransferExcelTemplate> export = this.lWhFormTransferService.export(id, type); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, map); |
| | | try (OutputStream outputStream = response.getOutputStream()) { |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("调拨入库单.xls", "utf-8")); |
| | | workbook.write(outputStream); |
| | | workbook.close(); |
| | | } |
| | | int countNum = export.stream().filter(item -> item.getNum() != null).mapToInt(TransferExcelTemplate::getNum).sum(); |
| | | int totalAmount = export.stream().filter(item -> item.getTotalAmount() != null).mapToInt(TransferExcelTemplate::getTotalAmount).sum(); |
| | | Optional<TransferExcelTemplate> first = export.stream().findFirst(); |
| | | TransferExcelTemplate entity = first.get(); |
| | | String businessFormCode = entity.getBusinessFormCode(); |
| | | Long createTime = entity.getCreateTime(); |
| | | String operatorName = entity.getOperatorName(); |
| | | String tenantName = entity.getTenantName(); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("code", businessFormCode); |
| | | map.put("date", DateUtils.toShowDate(createTime)); |
| | | map.put("tenantName", tenantName); |
| | | map.put("name", operatorName); |
| | | map.put("countNum", countNum); |
| | | map.put("totalAmount", totalAmount); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, TransferExcelTemplate.class, export, map); |
| | | downLoadExcel(fileName, response, workbook); |
| | | |
| | | } |
| | | |
| | | |