|
39 | 39 | import com.wansenai.utils.enums.AllotShipmentCodeEnum;
|
40 | 40 | import com.wansenai.utils.enums.BaseCodeEnum;
|
41 | 41 | import com.wansenai.utils.enums.OtherShipmentCodeEnum;
|
| 42 | +import com.wansenai.utils.excel.ExcelUtils; |
42 | 43 | import com.wansenai.utils.response.Response;
|
43 | 44 | import com.wansenai.vo.warehouse.AllotReceiptDetailVO;
|
44 | 45 | import com.wansenai.vo.warehouse.AllotReceiptVO;
|
| 46 | +import jakarta.servlet.http.HttpServletResponse; |
45 | 47 | import org.springframework.stereotype.Service;
|
46 | 48 | import org.springframework.transaction.annotation.Transactional;
|
47 | 49 | import org.springframework.util.StringUtils;
|
@@ -180,6 +182,44 @@ public Response<Page<AllotReceiptVO>> getAllotReceiptPageList(QueryAllotReceiptD
|
180 | 182 | return Response.responseData(result);
|
181 | 183 | }
|
182 | 184 |
|
| 185 | + private List<AllotReceiptVO> getAllotReceiptList(QueryAllotReceiptDTO queryAllotReceiptDTO) { |
| 186 | + var wrapperMainMapper = lambdaQuery() |
| 187 | + .eq(queryAllotReceiptDTO.getOperatorId() != null, WarehouseReceiptMain::getCreateBy, queryAllotReceiptDTO.getOperatorId()) |
| 188 | + .eq(queryAllotReceiptDTO.getStatus() != null, WarehouseReceiptMain::getStatus, queryAllotReceiptDTO.getStatus()) |
| 189 | + .eq(StringUtils.hasLength(queryAllotReceiptDTO.getReceiptNumber()), WarehouseReceiptMain::getReceiptNumber, queryAllotReceiptDTO.getReceiptNumber()) |
| 190 | + .like(StringUtils.hasLength(queryAllotReceiptDTO.getRemark()), WarehouseReceiptMain::getRemark, queryAllotReceiptDTO.getRemark()) |
| 191 | + .ge(StringUtils.hasLength(queryAllotReceiptDTO.getStartDate()), WarehouseReceiptMain::getCreateTime, queryAllotReceiptDTO.getStartDate()) |
| 192 | + .le(StringUtils.hasLength(queryAllotReceiptDTO.getEndDate()), WarehouseReceiptMain::getCreateTime, queryAllotReceiptDTO.getEndDate()) |
| 193 | + .eq(WarehouseReceiptMain::getType, "调拨出库") |
| 194 | + .eq(WarehouseReceiptMain::getDeleteFlag, CommonConstants.NOT_DELETED) |
| 195 | + .list(); |
| 196 | + |
| 197 | + var allotReceiptVOList = new ArrayList<AllotReceiptVO>(wrapperMainMapper.size() + 1); |
| 198 | + wrapperMainMapper.forEach(item -> { |
| 199 | + |
| 200 | + var product = productService.getById(item.getProductId()); |
| 201 | + var productInfo = ""; |
| 202 | + if(product != null) { |
| 203 | + productInfo = product.getProductName() + "|" + product.getProductStandard() + "|" + product.getProductModel() + "|" + product.getProductUnit(); |
| 204 | + } |
| 205 | + |
| 206 | + var operator = userService.getById(item.getCreateBy()); |
| 207 | + var allotReceiptVO = AllotReceiptVO.builder() |
| 208 | + .id(item.getId()) |
| 209 | + .receiptNumber(item.getReceiptNumber()) |
| 210 | + .productInfo(productInfo) |
| 211 | + .receiptDate(item.getReceiptDate()) |
| 212 | + .operator(Optional.ofNullable(operator).map(SysUser::getName).orElse("")) |
| 213 | + .productNumber(item.getTotalProductNumber()) |
| 214 | + .totalAmount(item.getTotalAmount()) |
| 215 | + .status(item.getStatus()) |
| 216 | + .build(); |
| 217 | + |
| 218 | + allotReceiptVOList.add(allotReceiptVO); |
| 219 | + }); |
| 220 | + return allotReceiptVOList; |
| 221 | + } |
| 222 | + |
183 | 223 | @Override
|
184 | 224 | public Response<AllotReceiptDetailVO> getAllotReceiptDetail(Long id) {
|
185 | 225 | if (id == null) {
|
@@ -433,4 +473,13 @@ public Response<String> updateAllotReceiptStatus(List<Long> ids, Integer status)
|
433 | 473 | }
|
434 | 474 | return Response.responseMsg(AllotShipmentCodeEnum.UPDATE_ALLOT_SHIPMENT_STOCK_RECEIPT_SUCCESS);
|
435 | 475 | }
|
| 476 | + |
| 477 | + @Override |
| 478 | + public void exportAllotReceipt(QueryAllotReceiptDTO queryAllotReceiptDTO, HttpServletResponse response) throws Exception { |
| 479 | + var data = getAllotReceiptList(queryAllotReceiptDTO); |
| 480 | + if (!data.isEmpty()) { |
| 481 | + var file = ExcelUtils.exportFile(ExcelUtils.DEFAULT_FILE_PATH, "调拨出库", data); |
| 482 | + ExcelUtils.downloadExcel(file, "调拨出库", response); |
| 483 | + } |
| 484 | + } |
436 | 485 | }
|
0 commit comments