| | |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.enumerates.ClothesOrderStatusEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.AppContants; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelSheetPO; |
| | |
| | | import cc.mrbird.febs.mall.dto.activity.AdminCategoryUpdateDto; |
| | | import cc.mrbird.febs.mall.dto.clothes.*; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.ClothesOrderMapper; |
| | | import cc.mrbird.febs.mall.mapper.ClothesTypeMapper; |
| | | import cc.mrbird.febs.mall.service.ClothesTypeService; |
| | | import cc.mrbird.febs.mall.vo.clothes.AdminClothesPrintLocationVo; |
| | | import cc.mrbird.febs.mall.vo.clothes.AdminClothesPrintMemberStatureVo; |
| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSON; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Validated |
| | |
| | | public class AdminClothesTypeController extends BaseController { |
| | | |
| | | private final ClothesTypeService clothesTypeService; |
| | | private final ClothesOrderMapper clothesOrderMapper; |
| | | private final ClothesTypeMapper clothesTypeMapper; |
| | | private final RedisUtils redisUtils; |
| | | |
| | | /** |
| | |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("exportOrderList/{ids}") |
| | | @GetMapping("exportOrderList") |
| | | @ControllerEndpoint(operation = "订单列表", exceptionMessage = "导出失败") |
| | | public FebsResponse exportOrderList(@NotBlank(message = "{required}") @PathVariable String ids, HttpServletResponse response) throws IOException { |
| | | public FebsResponse exportOrderList(ClothesOrder clothesOrder, HttpServletResponse response) throws IOException { |
| | | if(ObjectUtil.isNull(clothesOrder.getIds())){ |
| | | throw new FebsException("请选择要导出的订单"); |
| | | } |
| | | String ids = clothesOrder.getIds(); |
| | | List<String> List = StrUtil.splitTrim(ids, ","); |
| | | if(CollUtil.isNotEmpty( List)){ |
| | | ArrayList<Long> orderIds = new ArrayList<>(); |
| | |
| | | } |
| | | if(CollUtil.isNotEmpty(orderIds)){ |
| | | |
| | | clothesTypeService.exportOrderList(orderIds,response); |
| | | List<ExcelSheetPO> res = new ArrayList<>(); |
| | | |
| | | ExcelSheetPO orderSheet = new ExcelSheetPO(); |
| | | String title = "订单列表"; |
| | | orderSheet.setSheetName(title); |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"订单ID", "订单编号", "收货姓名", "收货电话", "收货地址", "商品详情", "备注", "物流单号", "物流公司", "物流公司码"}; |
| | | orderSheet.setHeaders(header); |
| | | |
| | | QueryRequest request = new QueryRequest(); |
| | | request.setPageNum(1); |
| | | request.setPageSize(9999); |
| | | List<ClothesOrder> dataList = clothesOrderMapper.selectList( |
| | | Wrappers.lambdaQuery(ClothesOrder.class) |
| | | .in(ClothesOrder::getId, orderIds) |
| | | .eq(ClothesOrder::getDelFlag, 0) |
| | | .eq(ClothesOrder::getStatus, ClothesOrderStatusEnum.WAIT_SHIPPING.getValue())); |
| | | Map<Long, ClothesType> longClothesTypeHashMap = new HashMap<>(); |
| | | if(CollUtil.isNotEmpty(dataList)){ |
| | | Set<Long> typeIds = dataList.stream().map(ClothesOrder::getTypeId).collect(Collectors.toSet()); |
| | | List<ClothesType> clothesTypes = clothesTypeMapper.selectList( |
| | | Wrappers.lambdaQuery(ClothesType.class) |
| | | .in(ClothesType::getId, typeIds) |
| | | ); |
| | | if(CollUtil.isNotEmpty(clothesTypes)){ |
| | | //stream操作clothesTypes,返回一个HashMap<Long, ClothesType>, key为clothesType.id, value为clothesType |
| | | longClothesTypeHashMap = clothesTypes.stream().collect(Collectors.toMap(ClothesType::getId, clothesType -> clothesType)); |
| | | } |
| | | } |
| | | |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | |
| | | if (dataList.size() > 0) { |
| | | for (ClothesOrder item : dataList) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | temp.add(item.getId()); |
| | | temp.add(item.getOrderNo()); |
| | | temp.add(item.getName()); |
| | | temp.add(item.getPhone()); |
| | | temp.add(item.getAddress()); |
| | | temp.add(longClothesTypeHashMap.get(item.getTypeId()).getName()); |
| | | temp.add(item.getRemark()); |
| | | list.add(temp); |
| | | } |
| | | } |
| | | orderSheet.setDataList(list); |
| | | res.add(orderSheet); |
| | | response = ResponseHeadUtil.setExcelHead(response); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), "yyyyMMDDHHmmss") + ".xlsx".trim(), "UTF-8")); |
| | | OutputStream os = response.getOutputStream(); |
| | | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true); |
| | | } |
| | | } |
| | | return null; |