|
|
@@ -8,7 +8,10 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
import com.alibaba.excel.metadata.Head;
|
|
|
+import com.alibaba.excel.metadata.data.ImageData;
|
|
|
+import com.alibaba.excel.metadata.data.WriteCellData;
|
|
|
import com.alibaba.excel.util.DateUtils;
|
|
|
+import com.alibaba.excel.util.FileUtils;
|
|
|
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
|
|
|
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
@@ -31,6 +34,7 @@ import com.yc.ship.framework.common.util.collection.CollectionUtils;
|
|
|
import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
import com.yc.ship.framework.common.util.object.ObjectUtils;
|
|
|
import com.yc.ship.framework.dict.core.DictFrameworkUtils;
|
|
|
+import com.yc.ship.framework.excel.core.merge.MergeStrategy;
|
|
|
import com.yc.ship.framework.ip.core.utils.AreaUtils;
|
|
|
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
import com.yc.ship.framework.security.core.LoginUser;
|
|
|
@@ -136,9 +140,13 @@ import com.yc.ship.module.trade.utils.AgencyAuthUtils;
|
|
|
import com.yc.ship.module.trade.utils.excel.ExcelStyleHandler;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.ss.util.RegionUtil;
|
|
|
+import org.apache.poi.util.IOUtils;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
@@ -146,9 +154,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@@ -2405,10 +2413,16 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
tradeOrderBindDO.setRemark("提交营销政策");
|
|
|
shipTradeOrderCreateReqVO.setTradeOrderBindDO(tradeOrderBindDO);
|
|
|
}
|
|
|
+ List<TradeOrderRoomModelVO> roomModelList = createVO.getRoomModelList();
|
|
|
+ Map<String, TradeOrderRoomModelVO> roomMap = CollectionUtils.convertMap(roomModelList, TradeOrderRoomModelVO::getRoomIndexId);
|
|
|
ShipTradeOrderCreateReqVO.OrderItem orderItem = new ShipTradeOrderCreateReqVO.OrderItem();
|
|
|
List<ShipTradeOrderCreateReqVO.OrderDetail> detailList = new ArrayList<>();
|
|
|
ShipTradeOrderCreateReqVO.OrderDetail orderDetail = new ShipTradeOrderCreateReqVO.OrderDetail();
|
|
|
for (TradeVistorReqVO tradeVistorReqVO : createVO.getTourist()) {
|
|
|
+ TradeOrderRoomModelVO roomModelVO = roomMap.get(tradeVistorReqVO.getRoomIndexId());
|
|
|
+ if(Objects.nonNull(roomModelVO) && Objects.nonNull(roomModelVO.getRoomId())) {
|
|
|
+ tradeVistorReqVO.setRoomId(String.valueOf(roomModelVO.getRoomId()));
|
|
|
+ }
|
|
|
List<ShipTradeOrderCreateReqVO.Visitor> visitorList = new ArrayList<>();
|
|
|
ShipTradeOrderCreateReqVO.OrderDetail visitorDetailId = new ShipTradeOrderCreateReqVO.OrderDetail();
|
|
|
//BeanUtils.copyProperties(orderDetail, ShipTradeOrderCreateReqVO.OrderDetail.class);
|
|
|
@@ -2439,6 +2453,10 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
List<ShipTradeOrderCreateReqVO.Visitor> visitorList1 = new ArrayList<>();
|
|
|
for (String touristId : tradeSpuReqVO.getTourist()) {
|
|
|
TradeVistorReqVO tradeVistorReqVO = createVO.getTourist().stream().filter(v -> v.getId().equals(touristId)).findFirst().orElseGet(TradeVistorReqVO::new);
|
|
|
+ TradeOrderRoomModelVO roomModelVO = roomMap.get(tradeVistorReqVO.getRoomIndexId());
|
|
|
+ if(Objects.nonNull(roomModelVO) && Objects.nonNull(roomModelVO.getRoomId())) {
|
|
|
+ tradeVistorReqVO.setRoomId(String.valueOf(roomModelVO.getRoomId()));
|
|
|
+ }
|
|
|
ShipTradeOrderCreateReqVO.Visitor visitor = getVisitor1(tradeVistorReqVO);
|
|
|
visitorList1.add(visitor);
|
|
|
BigDecimal price = tradeSpuReqVO.getPrice() == null ? BigDecimal.ZERO : tradeSpuReqVO.getPrice();
|
|
|
@@ -2484,7 +2502,7 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
|
|
|
// 创建订单房型数据
|
|
|
List<TradeOrderRoomModelDO> tradeOrderRoomDOList = new ArrayList<>();
|
|
|
- List<TradeOrderRoomModelVO> roomModelList = createVO.getRoomModelList();
|
|
|
+
|
|
|
roomModelList.forEach(roomModel -> {
|
|
|
TradeOrderRoomModelDO tradeOrderRoomDO = BeanUtils.toBean(roomModel, TradeOrderRoomModelDO.class);
|
|
|
tradeOrderRoomDO.setOrderId(orderId);
|
|
|
@@ -2588,6 +2606,7 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
visitor.setYczz(tradeVistorReqVO.getYichang());
|
|
|
visitor.setCqzz(tradeVistorReqVO.getChongqing());
|
|
|
visitor.setRoomId(tradeVistorReqVO.getRoomId());
|
|
|
+ visitor.setInitRoomId(tradeVistorReqVO.getRoomId());
|
|
|
visitor.setNationality(tradeVistorReqVO.getNationality());
|
|
|
visitor.setGender(tradeVistorReqVO.getGender());
|
|
|
visitor.setBirthday(tradeVistorReqVO.getBirthday());
|
|
|
@@ -2706,7 +2725,13 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
List<ShipTradeOrderCreateReqVO.OrderDetail> detailList = new ArrayList<>();
|
|
|
ShipTradeOrderCreateReqVO.OrderDetail orderDetail = new ShipTradeOrderCreateReqVO.OrderDetail();
|
|
|
// 处理游客信息
|
|
|
+ List<TradeOrderRoomModelVO> roomModelList = createVO.getRoomModelList();
|
|
|
+ Map<String, TradeOrderRoomModelVO> roomMap = CollectionUtils.convertMap(roomModelList, TradeOrderRoomModelVO::getRoomIndexId);
|
|
|
for (TradeVistorReqVO tradeVistorReqVO : createVO.getTourist()) {
|
|
|
+ TradeOrderRoomModelVO roomModelVO = roomMap.get(tradeVistorReqVO.getRoomIndexId());
|
|
|
+ if(Objects.nonNull(roomModelVO) && Objects.nonNull(roomModelVO.getRoomId())) {
|
|
|
+ tradeVistorReqVO.setRoomId(String.valueOf(roomModelVO.getRoomId()));
|
|
|
+ }
|
|
|
List<ShipTradeOrderCreateReqVO.Visitor> visitorList = new ArrayList<>();
|
|
|
ShipTradeOrderCreateReqVO.OrderDetail visitorDetailId = new ShipTradeOrderCreateReqVO.OrderDetail();
|
|
|
String visitorId = tradeVistorReqVO.getId();
|
|
|
@@ -2742,6 +2767,10 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
List<ShipTradeOrderCreateReqVO.Visitor> visitorList1 = new ArrayList<>();
|
|
|
for (String touristId : tradeSpuReqVO.getTourist()) {
|
|
|
TradeVistorReqVO tradeVistorReqVO = createVO.getTourist().stream().filter(v -> v.getId().equals(touristId)).findFirst().orElseGet(TradeVistorReqVO::new);
|
|
|
+ TradeOrderRoomModelVO roomModelVO = roomMap.get(tradeVistorReqVO.getRoomIndexId());
|
|
|
+ if(Objects.nonNull(roomModelVO) && Objects.nonNull(roomModelVO.getRoomId())) {
|
|
|
+ tradeVistorReqVO.setRoomId(String.valueOf(roomModelVO.getRoomId()));
|
|
|
+ }
|
|
|
ShipTradeOrderCreateReqVO.Visitor visitor = getVisitor1(tradeVistorReqVO);
|
|
|
visitorList1.add(visitor);
|
|
|
BigDecimal price = tradeSpuReqVO.getPrice() == null ? BigDecimal.ZERO : tradeSpuReqVO.getPrice();
|
|
|
@@ -3417,6 +3446,40 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
TradeOrderTotalVO summary = BeanUtils.toBean(tradeOrderTotalDO, TradeOrderTotalVO.class);
|
|
|
orderRespNewVO.setSummary(summary);
|
|
|
|
|
|
+ // 计算领队单价
|
|
|
+ Integer leaderTotalNum = summary.getLeaderTotalNum();
|
|
|
+ if(leaderTotalNum != null && leaderTotalNum > 0) {
|
|
|
+ BigDecimal leaderPrice = summary.getLeaderAmount().divide(new BigDecimal(leaderTotalNum), 2, RoundingMode.HALF_UP);
|
|
|
+ countryList.stream().forEach(item -> {
|
|
|
+ if(Objects.equals(item.getType(), "leader")) {
|
|
|
+ item.setActualPrice(leaderPrice);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 计算陪同单价
|
|
|
+ Integer withTotalNum = summary.getWithTotalNum();
|
|
|
+ if(withTotalNum != null && withTotalNum > 0) {
|
|
|
+ BigDecimal withPrice = summary.getWithAmount().divide(new BigDecimal(withTotalNum), 2, RoundingMode.HALF_UP);
|
|
|
+ countryList.stream().forEach(item -> {
|
|
|
+ if(Objects.equals(item.getType(), "with")) {
|
|
|
+ item.setActualPrice(withPrice);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 添加16免1
|
|
|
+ Integer freeNum = summary.getFreeNum();
|
|
|
+ if(freeNum != null && freeNum > 0) {
|
|
|
+ BigDecimal freePrice = summary.getFreeAmount().divide(new BigDecimal(freeNum), 2, RoundingMode.HALF_UP);
|
|
|
+ TradeOrderConfirmationCountryRespVO countryRespVO = new TradeOrderConfirmationCountryRespVO();
|
|
|
+ countryRespVO.setActualPrice(freePrice.negate());
|
|
|
+ countryRespVO.setNum(freeNum);
|
|
|
+ countryRespVO.setType("free");
|
|
|
+ countryRespVO.setRoomModelName("16免1");
|
|
|
+ countryRespVO.setRoomModelShortName("16免1");
|
|
|
+ countryRespVO.setNationalityName("-");
|
|
|
+ countryRespVO.setFloor(0);
|
|
|
+ countryList.add(countryRespVO);
|
|
|
+ }
|
|
|
//设置游轮航次信息
|
|
|
VoyageDO voyageDO = voyageService.getVoyage(tradeOrderDO.getVoyageId());
|
|
|
orderRespNewVO.setVoyage(BeanUtils.toBean(voyageDO, VoyageRespVO.class));
|
|
|
@@ -3433,112 +3496,149 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
|
|
|
@Override
|
|
|
public File createConfirmaction(Long id, Double totalMoney) {
|
|
|
- TradeOrderConfirmationVO orderConfirmation = getOrderConfirmation(id);
|
|
|
- InputStream template = getClass().getClassLoader().getResourceAsStream("templates/confirmation_template.xlsx");
|
|
|
- String tmpFile = "/tmp/" + orderConfirmation.getId() + ".xlsx";
|
|
|
- ExcelWriter excelWriter = EasyExcel.write(tmpFile).withTemplate(template).build();
|
|
|
- ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcelFactory.writerSheet();
|
|
|
- // 需要合并单元格的writeSheet
|
|
|
- WriteSheet writeSheet = excelWriterSheetBuilder.registerWriteHandler(new MergeStrategy()).build();
|
|
|
- FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
|
|
|
-
|
|
|
- // 订单信息
|
|
|
- Map<String, Object> orderData = new HashMap<>();
|
|
|
- orderData.put("orderNo", orderConfirmation.getOrderNo());
|
|
|
- orderData.put("shipName", orderConfirmation.getShipName());
|
|
|
- orderData.put("shipNameEn", orderConfirmation.getShipNameEn());
|
|
|
- orderData.put("groupNo", orderConfirmation.getGroupNo());
|
|
|
- orderData.put("sourceName", orderConfirmation.getSourceName());
|
|
|
- orderData.put("linkMan", orderConfirmation.getLinkMan());
|
|
|
- orderData.put("linkMobile", orderConfirmation.getLinkMobile());
|
|
|
- orderData.put("amount", orderConfirmation.getAmount());
|
|
|
- orderData.put("remark", orderConfirmation.getRemark());
|
|
|
-
|
|
|
- VoyageRespVO voyage = orderConfirmation.getVoyage();
|
|
|
- //此处改为订单号最后的序号,如CJXLY-20260526-YC-13订单,登船序号应为13
|
|
|
- String[] split = orderConfirmation.getOrderNo().split("-");
|
|
|
- String split1 = split[split.length - 1];
|
|
|
- orderData.put("voyageCode", split1);
|
|
|
-
|
|
|
- orderData.put("boardingTime", DateUtil.format(Date.from(voyage.getBoardingTime().atZone(ZoneOffset.ofHours(8)).toInstant()), "yyyy-MM-dd HH:mm"));
|
|
|
- orderData.put("startTime", DateUtil.format(Date.from(voyage.getStartTime().atZone(ZoneOffset.ofHours(8)).toInstant()), "yyyy-MM-dd HH:mm"));
|
|
|
- orderData.put("leaveTime", DateUtil.format(Date.from(voyage.getLeaveTime().atZone(ZoneOffset.ofHours(8)).toInstant()), "yyyy-MM-dd HH:mm"));
|
|
|
-
|
|
|
- ResourceRouteDO resourceRouteDO = orderConfirmation.getResourceRouteDO();
|
|
|
- String resourceRoute = "重庆-宜昌";
|
|
|
- String resourceRouteEn = "Chongqing-Yichang";
|
|
|
- if (resourceRouteDO != null && resourceRouteDO.getDirection() != null && resourceRouteDO.getDirection() == 1) {
|
|
|
- resourceRoute = "宜昌-重庆";
|
|
|
- resourceRouteEn = "Yichang-Chongqing";
|
|
|
- }
|
|
|
- orderData.put("resourceRoute", resourceRoute);
|
|
|
- orderData.put("resourceRouteEn", resourceRouteEn);
|
|
|
-
|
|
|
- // 房型信息
|
|
|
- List<Map<String, Object>> roomData = new ArrayList<>();
|
|
|
- List<TradeOrderConfirmationCountryRespVO> countryList = orderConfirmation.getCountryList();
|
|
|
- if (countryList != null) {
|
|
|
- countryList.forEach(item -> {
|
|
|
- String roomModelName = item.getRoomModelName();
|
|
|
- if (item.getFloor() == null) {
|
|
|
- if ("leader".equals(item.getType())) {
|
|
|
- roomModelName = roomModelName + "(领队)";
|
|
|
- } else if ("with".equals(item.getType())) {
|
|
|
- roomModelName = roomModelName + "(陪同)";
|
|
|
+ try {
|
|
|
+ TradeOrderConfirmationVO orderConfirmation = getOrderConfirmation(id);
|
|
|
+ InputStream template = getClass().getClassLoader().getResourceAsStream("templates/confirmation_template.xlsx");
|
|
|
+ String tmpFile = "/tmp/" + orderConfirmation.getId() + ".xlsx";
|
|
|
+ ExcelWriter excelWriter = EasyExcel.write(tmpFile).withTemplate(template).build();
|
|
|
+ ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcelFactory.writerSheet();
|
|
|
+ // 需要合并单元格的writeSheet
|
|
|
+ WriteSheet writeSheet = excelWriterSheetBuilder.registerWriteHandler(new MergeStrategy()).build();
|
|
|
+ FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
|
|
|
+
|
|
|
+ // 订单信息
|
|
|
+ Map<String, Object> orderData = new HashMap<>();
|
|
|
+ orderData.put("orderNo", orderConfirmation.getOrderNo());
|
|
|
+ orderData.put("shipName", orderConfirmation.getShipName());
|
|
|
+ orderData.put("shipNameEn", orderConfirmation.getShipNameEn());
|
|
|
+ orderData.put("groupNo", orderConfirmation.getGroupNo());
|
|
|
+ orderData.put("sourceName", orderConfirmation.getSourceName());
|
|
|
+ orderData.put("linkMan", orderConfirmation.getLinkMan());
|
|
|
+ orderData.put("linkMobile", orderConfirmation.getLinkMobile());
|
|
|
+ orderData.put("amount", orderConfirmation.getAmount());
|
|
|
+ orderData.put("remark", orderConfirmation.getRemark());
|
|
|
+
|
|
|
+ VoyageRespVO voyage = orderConfirmation.getVoyage();
|
|
|
+ //此处改为订单号最后的序号,如CJXLY-20260526-YC-13订单,登船序号应为13
|
|
|
+ String[] split = orderConfirmation.getOrderNo().split("-");
|
|
|
+ String split1 = split[split.length - 1];
|
|
|
+ orderData.put("voyageCode", split1);
|
|
|
+
|
|
|
+ orderData.put("boardingTime", DateUtil.format(Date.from(voyage.getBoardingTime().atZone(ZoneOffset.ofHours(8)).toInstant()), "yyyy-MM-dd HH:mm"));
|
|
|
+ orderData.put("startTime", DateUtil.format(Date.from(voyage.getStartTime().atZone(ZoneOffset.ofHours(8)).toInstant()), "yyyy-MM-dd HH:mm"));
|
|
|
+ orderData.put("leaveTime", DateUtil.format(Date.from(voyage.getLeaveTime().atZone(ZoneOffset.ofHours(8)).toInstant()), "yyyy-MM-dd HH:mm"));
|
|
|
+
|
|
|
+ ResourceRouteDO resourceRouteDO = orderConfirmation.getResourceRouteDO();
|
|
|
+ String resourceRoute = "重庆-宜昌";
|
|
|
+ String resourceRouteEn = "Chongqing-Yichang";
|
|
|
+ if (resourceRouteDO != null && resourceRouteDO.getDirection() != null && resourceRouteDO.getDirection() == 1) {
|
|
|
+ resourceRoute = "宜昌-重庆";
|
|
|
+ resourceRouteEn = "Yichang-Chongqing";
|
|
|
+ }
|
|
|
+ orderData.put("resourceRoute", resourceRoute);
|
|
|
+ orderData.put("resourceRouteEn", resourceRouteEn);
|
|
|
+
|
|
|
+ // 房型信息
|
|
|
+ List<Map<String, Object>> roomData = new ArrayList<>();
|
|
|
+ List<TradeOrderConfirmationCountryRespVO> countryList = orderConfirmation.getCountryList();
|
|
|
+ if (countryList != null) {
|
|
|
+ countryList.forEach(item -> {
|
|
|
+ String roomModelName = item.getRoomModelName();
|
|
|
+ if (item.getFloor() == null) {
|
|
|
+ if ("leader".equals(item.getType())) {
|
|
|
+ roomModelName = roomModelName + "(领队)";
|
|
|
+ } else if ("with".equals(item.getType())) {
|
|
|
+ roomModelName = roomModelName + "(陪同)";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ roomModelName = roomModelName + "(" + item.getFloor() + "F)";
|
|
|
}
|
|
|
- } else {
|
|
|
- roomModelName = roomModelName + "(" + item.getFloor() + "F)";
|
|
|
- }
|
|
|
- Map<String, Object> room = new HashMap<>();
|
|
|
- room.put("roomModelName", roomModelName);
|
|
|
- room.put("countryName", item.getNationalityName());
|
|
|
- room.put("personTypeDes", getPersonTypeDes1(item.getType()));
|
|
|
- room.put("personTypeDesEn", getPersonTypeDesEn1(item.getType()));
|
|
|
- room.put("qty", item.getNum());
|
|
|
- room.put("price", item.getActualPrice());
|
|
|
- room.put("realMoney", item.getActualPrice().multiply(new BigDecimal(item.getNum())));
|
|
|
- roomData.add(room);
|
|
|
- });
|
|
|
+ Map<String, Object> room = new HashMap<>();
|
|
|
+ room.put("roomModelName", roomModelName);
|
|
|
+ room.put("countryName", item.getNationalityName());
|
|
|
+ room.put("personTypeDes", getPersonTypeDes1(item.getType()));
|
|
|
+ room.put("personTypeDesEn", getPersonTypeDesEn1(item.getType()));
|
|
|
+ room.put("qty", item.getNum());
|
|
|
+ room.put("price", item.getActualPrice());
|
|
|
+ room.put("realMoney", item.getActualPrice().multiply(new BigDecimal(item.getNum())));
|
|
|
+ roomData.add(room);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ orderData.put("countryDes", orderConfirmation.getCountryDesc());
|
|
|
+ orderData.put("useRoomTotalDesc", orderConfirmation.getUseRoomTotalDesc());
|
|
|
+ TradeOrderTotalVO summary = orderConfirmation.getSummary();
|
|
|
+ if (summary != null) {
|
|
|
+ orderData.put("roomModelDes", summary.getUseRoomTotalNum());
|
|
|
+ } else {
|
|
|
+ orderData.put("roomModelDes", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ orderData.put("totalMoney", totalMoney);
|
|
|
+ orderData.put("creatorName", orderConfirmation.getCreatorName());
|
|
|
+ orderData.put("auditorName", orderConfirmation.getAuditorName());
|
|
|
+ orderData.put("firstDate", DateUtil.format(org.apache.commons.lang3.time.DateUtils.addDays(Date.from(orderConfirmation.getCreateTime().atZone(ZoneOffset.ofHours(8)).toInstant()), 7), "yyyy-MM-dd"));
|
|
|
+ orderData.put("lastDate", DateUtil.format(org.apache.commons.lang3.time.DateUtils.addDays(Date.from(voyage.getStartTime().atZone(ZoneOffset.ofHours(8)).toInstant()), -21), "yyyy-MM-dd"));
|
|
|
+ orderData.put("today", DateUtil.format(new Date(), "yyyy-MM-dd"));
|
|
|
+
|
|
|
+ // 游客信息
|
|
|
+ List<Map<String, Object>> tradeVisitorData = new ArrayList<>();
|
|
|
+ List<TradeVisitorDO> tradeVisitorList = orderConfirmation.getTradeVisitorList();
|
|
|
+ for (int i = 0; i < tradeVisitorList.size(); i++) {
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
+ TradeVisitorDO tradeVisitorDO = tradeVisitorList.get(i);
|
|
|
+ item.put("index", String.valueOf((i + 1)));
|
|
|
+ item.put("name", StringUtils.isEmpty(tradeVisitorDO.getName()) ? "" : tradeVisitorDO.getName());
|
|
|
+ item.put("nationality", StringUtils.isEmpty(tradeVisitorDO.getNationalityName()) ? "" : tradeVisitorDO.getNationalityName());
|
|
|
+ item.put("gender", (tradeVisitorDO.getGender() == null || tradeVisitorDO.getGender() == 0) ? "女" : "男");
|
|
|
+ item.put("dob", StringUtils.isEmpty(tradeVisitorDO.getBirthday()) ? "" : tradeVisitorDO.getBirthday());
|
|
|
+ item.put("credentialTypeName", DictFrameworkUtils.getDictDataLabel(DictTypeConstants.VISITOR_CREDENTIAL_TYPE, tradeVisitorDO.getCredentialType()));
|
|
|
+ item.put("idno", StringUtils.isEmpty(tradeVisitorDO.getCredentialNo()) ? "" : tradeVisitorDO.getCredentialNo());
|
|
|
+ tradeVisitorData.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 填充单条数据
|
|
|
+ excelWriter.fill(orderData, writeSheet);
|
|
|
+ // 填充列表数据
|
|
|
+ excelWriter.fill(new FillWrapper("room", roomData), fillConfig, writeSheet);
|
|
|
+ excelWriter.fill(new FillWrapper("visitor", tradeVisitorData), fillConfig, writeSheet);
|
|
|
+ excelWriter.finish();
|
|
|
+ File file = new File(tmpFile);
|
|
|
+// drawImage(file);
|
|
|
+ return file;
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- orderData.put("countryDes", orderConfirmation.getCountryDesc());
|
|
|
- orderData.put("useRoomTotalDesc", orderConfirmation.getUseRoomTotalDesc());
|
|
|
- TradeOrderTotalVO summary = orderConfirmation.getSummary();
|
|
|
- if (summary != null) {
|
|
|
- orderData.put("roomModelDes", summary.getUseRoomTotalNum());
|
|
|
- } else {
|
|
|
- orderData.put("roomModelDes", 0);
|
|
|
- }
|
|
|
-
|
|
|
- orderData.put("totalMoney", totalMoney);
|
|
|
- orderData.put("creatorName", orderConfirmation.getCreatorName());
|
|
|
- orderData.put("auditorName", orderConfirmation.getAuditorName());
|
|
|
- orderData.put("firstDate", DateUtil.format(org.apache.commons.lang3.time.DateUtils.addDays(Date.from(orderConfirmation.getCreateTime().atZone(ZoneOffset.ofHours(8)).toInstant()), 7), "yyyy-MM-dd"));
|
|
|
- orderData.put("lastDate", DateUtil.format(org.apache.commons.lang3.time.DateUtils.addDays(Date.from(voyage.getStartTime().atZone(ZoneOffset.ofHours(8)).toInstant()), -21), "yyyy-MM-dd"));
|
|
|
- orderData.put("today", DateUtil.format(new Date(), "yyyy-MM-dd"));
|
|
|
-
|
|
|
- // 游客信息
|
|
|
- List<Map<String, Object>> tradeVisitorData = new ArrayList<>();
|
|
|
- List<TradeVisitorDO> tradeVisitorList = orderConfirmation.getTradeVisitorList();
|
|
|
- for (int i = 0; i < tradeVisitorList.size(); i++) {
|
|
|
- Map<String, Object> item = new HashMap<>();
|
|
|
- TradeVisitorDO tradeVisitorDO = tradeVisitorList.get(i);
|
|
|
- item.put("index", String.valueOf((i + 1)));
|
|
|
- item.put("name", StringUtils.isEmpty(tradeVisitorDO.getName()) ? "" : tradeVisitorDO.getName());
|
|
|
- item.put("nationality", StringUtils.isEmpty(tradeVisitorDO.getNationalityName()) ? "" : tradeVisitorDO.getNationalityName());
|
|
|
- item.put("gender", (tradeVisitorDO.getGender() == null || tradeVisitorDO.getGender() == 0) ? "女" : "男");
|
|
|
- item.put("dob", StringUtils.isEmpty(tradeVisitorDO.getBirthday()) ? "" : tradeVisitorDO.getBirthday());
|
|
|
- item.put("credentialTypeName", DictFrameworkUtils.getDictDataLabel(DictTypeConstants.VISITOR_CREDENTIAL_TYPE, tradeVisitorDO.getCredentialType()));
|
|
|
- item.put("idno", StringUtils.isEmpty(tradeVisitorDO.getCredentialNo()) ? "" : tradeVisitorDO.getCredentialNo());
|
|
|
- tradeVisitorData.add(item);
|
|
|
- }
|
|
|
-
|
|
|
- // 填充单条数据
|
|
|
- excelWriter.fill(orderData, writeSheet);
|
|
|
- // 填充列表数据
|
|
|
- excelWriter.fill(new FillWrapper("room", roomData), fillConfig, writeSheet);
|
|
|
- excelWriter.fill(new FillWrapper("visitor", tradeVisitorData), fillConfig, writeSheet);
|
|
|
- excelWriter.finish();
|
|
|
- return new File(tmpFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void drawImage(File excelFilePath) throws IOException, InvalidFormatException {
|
|
|
+ Workbook workbook = new XSSFWorkbook(excelFilePath);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ InputStream logo = getClass().getClassLoader().getResourceAsStream("templates/logo.png");
|
|
|
+ byte[] bytes = IOUtils.toByteArray(logo);
|
|
|
+ // 读取图片文件到byte数组
|
|
|
+ int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
|
|
|
+ logo.close();
|
|
|
+
|
|
|
+ // 创建drawing patriarch和anchor对象
|
|
|
+ CreationHelper helper = workbook.getCreationHelper();
|
|
|
+ Drawing drawing = sheet.createDrawingPatriarch();
|
|
|
+ ClientAnchor anchor = helper.createClientAnchor();
|
|
|
+
|
|
|
+ int lastRowNum = sheet.getLastRowNum();
|
|
|
+ // 设置图片位置和大小(例如,放在A1单元格)
|
|
|
+ anchor.setCol1(5); // Column A
|
|
|
+ anchor.setRow1(lastRowNum); // Row 1
|
|
|
+
|
|
|
+ // 创建图片对象并设置到workbook中
|
|
|
+ Picture pict = drawing.createPicture(anchor, pictureIdx);
|
|
|
+ pict.resize(); // 根据anchor调整图片大小
|
|
|
+
|
|
|
+ // 关闭流并保存文件
|
|
|
+ FileOutputStream out = new FileOutputStream(excelFilePath);
|
|
|
+ workbook.write(out);
|
|
|
+ out.close();
|
|
|
+ workbook.close();
|
|
|
}
|
|
|
|
|
|
@Override
|