|
|
|
@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderPageReqVO;
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderPageReqVO;
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderRespVO;
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderRespVO;
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderSaveReqVO;
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderSaveReqVO;
|
|
|
|
@ -19,6 +18,8 @@ import cn.iocoder.yudao.module.camera.service.checklog.CheckLogService;
|
|
|
|
import cn.iocoder.yudao.module.camera.service.order.OrderService;
|
|
|
|
import cn.iocoder.yudao.module.camera.service.order.OrderService;
|
|
|
|
import cn.iocoder.yudao.module.camera.service.stock.StockService;
|
|
|
|
import cn.iocoder.yudao.module.camera.service.stock.StockService;
|
|
|
|
import cn.iocoder.yudao.module.camera.service.street.StreetService;
|
|
|
|
import cn.iocoder.yudao.module.camera.service.street.StreetService;
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
|
|
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
@ -30,9 +31,13 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -158,9 +163,69 @@ public class OrderController {
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
List<OrderDO> list = orderService.getOrderPage(pageReqVO).getList();
|
|
|
|
List<OrderDO> list = orderService.getOrderPage(pageReqVO).getList();
|
|
|
|
// 导出 Excel
|
|
|
|
// 巷道名映射 srmNumber -> name
|
|
|
|
ExcelUtils.write(response, "随行记录.xls", "数据", OrderRespVO.class,
|
|
|
|
Map<String, String> streetMap = streetService.list().stream()
|
|
|
|
BeanUtils.toBean(list, OrderRespVO.class));
|
|
|
|
.collect(Collectors.toMap(StreetDO::getPlcId, StreetDO::getName, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 动态表头
|
|
|
|
|
|
|
|
List<List<String>> head = new ArrayList<>();
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("开始时间"));
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("随行工单号"));
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("巷道名"));
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("托盘号"));
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("位置"));
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("图片"));
|
|
|
|
|
|
|
|
head.add(Collections.singletonList("时间"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 动态数据
|
|
|
|
|
|
|
|
List<List<Object>> data = new ArrayList<>();
|
|
|
|
|
|
|
|
for (OrderDO order : list) {
|
|
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
|
|
row.add(order.getStartTime());
|
|
|
|
|
|
|
|
row.add(order.getTaskId());
|
|
|
|
|
|
|
|
row.add(streetMap.get(order.getSrmNumber()));
|
|
|
|
|
|
|
|
row.add(order.getTrayCode());
|
|
|
|
|
|
|
|
row.add(position(order));
|
|
|
|
|
|
|
|
row.add(order.getPics());
|
|
|
|
|
|
|
|
row.add(formatTimeDiff(order.getStartTime(), order.getEndTime()));
|
|
|
|
|
|
|
|
data.add(row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EasyExcel.write(response.getOutputStream())
|
|
|
|
|
|
|
|
.head(head)
|
|
|
|
|
|
|
|
.autoCloseStream(false)
|
|
|
|
|
|
|
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
|
|
|
|
|
|
|
.sheet("数据").doWrite(data);
|
|
|
|
|
|
|
|
response.addHeader("Content-Disposition", "attachment;filename="
|
|
|
|
|
|
|
|
+ URLEncoder.encode("随行记录.xls", StandardCharsets.UTF_8.name()));
|
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 计算位置:from -> to */
|
|
|
|
|
|
|
|
private String position(OrderDO order) {
|
|
|
|
|
|
|
|
String from = order.getFromSide() == 2 ? "库外"
|
|
|
|
|
|
|
|
: (order.getFromDirection() == 1 ? "左侧-" : "右侧-")
|
|
|
|
|
|
|
|
+ order.getFromRow() + "层-" + order.getFromColumn() + "列"
|
|
|
|
|
|
|
|
+ (order.getFromSeparation() == 2 ? "深货位" : "");
|
|
|
|
|
|
|
|
String to = order.getToSide() == 2 ? "库外"
|
|
|
|
|
|
|
|
: (order.getToDirection() == 1 ? "左侧-" : "右侧-")
|
|
|
|
|
|
|
|
+ order.getToRow() + "层-" + order.getToColumn() + "列"
|
|
|
|
|
|
|
|
+ (order.getToSeparation() == 2 ? "深货位" : "");
|
|
|
|
|
|
|
|
return from + "->" + to;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 计算时间差,格式 分钟:秒;未结束显示 未结束 */
|
|
|
|
|
|
|
|
private String formatTimeDiff(LocalDateTime start, LocalDateTime end) {
|
|
|
|
|
|
|
|
if (end == null) {
|
|
|
|
|
|
|
|
return "未结束";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
long diffSeconds = java.time.Duration.between(start, end).getSeconds();
|
|
|
|
|
|
|
|
if (diffSeconds <= 0) {
|
|
|
|
|
|
|
|
return "0:00";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
long minutes = diffSeconds / 60;
|
|
|
|
|
|
|
|
long seconds = diffSeconds % 60;
|
|
|
|
|
|
|
|
return minutes + ":" + String.format("%02d", seconds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|