|
37 | 37 | import com.wansenai.utils.constants.CommonConstants;
|
38 | 38 | import com.wansenai.utils.enums.BaseCodeEnum;
|
39 | 39 | import com.wansenai.utils.enums.OtherShipmentCodeEnum;
|
| 40 | +import com.wansenai.utils.excel.ExcelUtils; |
40 | 41 | import com.wansenai.utils.response.Response;
|
41 | 42 | import com.wansenai.vo.warehouse.OtherShipmentDetailVO;
|
42 | 43 | import com.wansenai.vo.warehouse.OtherShipmentVO;
|
| 44 | +import jakarta.servlet.http.HttpServletResponse; |
43 | 45 | import org.springframework.stereotype.Service;
|
44 | 46 | import org.springframework.util.StringUtils;
|
45 | 47 |
|
@@ -179,6 +181,47 @@ public Response<Page<OtherShipmentVO>> getOtherShipmentsPageList(QueryOtherShipm
|
179 | 181 | return Response.responseData(result);
|
180 | 182 | }
|
181 | 183 |
|
| 184 | + private List<OtherShipmentVO> getOtherShipmentsList(QueryOtherShipmentDTO queryOtherShipmentDTO) { |
| 185 | + var wrapperMainMapper = lambdaQuery() |
| 186 | + .eq(queryOtherShipmentDTO.getCustomerId() != null, WarehouseReceiptMain::getRelatedPersonId, queryOtherShipmentDTO.getCustomerId()) |
| 187 | + .eq(queryOtherShipmentDTO.getOperatorId() != null, WarehouseReceiptMain::getCreateBy, queryOtherShipmentDTO.getOperatorId()) |
| 188 | + .eq(queryOtherShipmentDTO.getStatus() != null, WarehouseReceiptMain::getStatus, queryOtherShipmentDTO.getStatus()) |
| 189 | + .eq(StringUtils.hasLength(queryOtherShipmentDTO.getReceiptNumber()), WarehouseReceiptMain::getReceiptNumber, queryOtherShipmentDTO.getReceiptNumber()) |
| 190 | + .eq(StringUtils.hasLength(queryOtherShipmentDTO.getOtherReceipt()), WarehouseReceiptMain::getReceiptNumber, queryOtherShipmentDTO.getOtherReceipt()) |
| 191 | + .like(StringUtils.hasLength(queryOtherShipmentDTO.getRemark()), WarehouseReceiptMain::getRemark, queryOtherShipmentDTO.getRemark()) |
| 192 | + .ge(StringUtils.hasLength(queryOtherShipmentDTO.getStartDate()), WarehouseReceiptMain::getCreateTime, queryOtherShipmentDTO.getStartDate()) |
| 193 | + .le(StringUtils.hasLength(queryOtherShipmentDTO.getEndDate()), WarehouseReceiptMain::getCreateTime, queryOtherShipmentDTO.getEndDate()) |
| 194 | + .eq(WarehouseReceiptMain::getType, "其他出库") |
| 195 | + .eq(WarehouseReceiptMain::getDeleteFlag, CommonConstants.NOT_DELETED) |
| 196 | + .list(); |
| 197 | + |
| 198 | + var otherShipmentVOList = new ArrayList<OtherShipmentVO>(wrapperMainMapper.size() + 1); |
| 199 | + wrapperMainMapper.forEach(item -> { |
| 200 | + |
| 201 | + var product = productService.getById(item.getProductId()); |
| 202 | + var productInfo = ""; |
| 203 | + if(product != null) { |
| 204 | + productInfo = product.getProductName() + "|" + product.getProductStandard() + "|" + product.getProductModel() + "|" + product.getProductUnit(); |
| 205 | + } |
| 206 | + |
| 207 | + var operator = userService.getById(item.getCreateBy()); |
| 208 | + var otherShipmentVO = OtherShipmentVO.builder() |
| 209 | + .id(item.getId()) |
| 210 | + .receiptNumber(item.getReceiptNumber()) |
| 211 | + .productInfo(productInfo) |
| 212 | + .customerName(commonService.getCustomerName(item.getRelatedPersonId())) |
| 213 | + .receiptDate(item.getReceiptDate()) |
| 214 | + .operator(Optional.ofNullable(operator).map(SysUser::getName).orElse("")) |
| 215 | + .productNumber(item.getTotalProductNumber()) |
| 216 | + .totalAmount(item.getTotalAmount()) |
| 217 | + .status(item.getStatus()) |
| 218 | + .build(); |
| 219 | + |
| 220 | + otherShipmentVOList.add(otherShipmentVO); |
| 221 | + }); |
| 222 | + return otherShipmentVOList; |
| 223 | + } |
| 224 | + |
182 | 225 | @Override
|
183 | 226 | public Response<OtherShipmentDetailVO> getOtherShipmentsDetail(Long id) {
|
184 | 227 | if (id == null) {
|
@@ -383,4 +426,13 @@ public Response<String> updateOtherShipmentsStatus(List<Long> ids, Integer statu
|
383 | 426 | }
|
384 | 427 | return Response.responseMsg(OtherShipmentCodeEnum.UPDATE_OTHER_SHIPMENT_STOCK_SUCCESS);
|
385 | 428 | }
|
| 429 | + |
| 430 | + @Override |
| 431 | + public void exportOtherShipments(QueryOtherShipmentDTO queryOtherShipmentDTO, HttpServletResponse response) throws Exception { |
| 432 | + var data = getOtherShipmentsList(queryOtherShipmentDTO); |
| 433 | + if (!data.isEmpty()) { |
| 434 | + var file = ExcelUtils.exportFile(ExcelUtils.DEFAULT_FILE_PATH, "其他出库", data); |
| 435 | + ExcelUtils.downloadExcel(file, "其他出库", response); |
| 436 | + } |
| 437 | + } |
386 | 438 | }
|
0 commit comments