|
|
|
|
@ -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.PageResult;
|
|
|
|
|
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.checklog.vo.CheckLogPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.checklog.vo.CheckLogRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.controller.admin.checklog.vo.CheckLogSaveReqVO;
|
|
|
|
|
@ -15,6 +14,8 @@ import cn.iocoder.yudao.module.logistics.dal.dataobject.checkconf.CheckConfDO;
|
|
|
|
|
import cn.iocoder.yudao.module.logistics.service.checkconf.CheckConfService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
@ -27,6 +28,10 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@ -125,9 +130,67 @@ public class CheckLogController {
|
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
List<CheckLogDO> list = checkLogService.getCheckLogPage(pageReqVO).getList();
|
|
|
|
|
// 导出 Excel
|
|
|
|
|
ExcelUtils.write(response, "盘点.xls", "数据", CheckLogRespVO.class,
|
|
|
|
|
BeanUtils.toBean(list, CheckLogRespVO.class));
|
|
|
|
|
|
|
|
|
|
// 动态盘点列配置(与 getColumns 一致)
|
|
|
|
|
Map<String, DictDataDO> dictDataNameList = dictDataService.getDictValueMap("scan_conf_name");
|
|
|
|
|
List<CheckConfDO> checkConfList = checkConfService.list(new QueryWrapper<CheckConfDO>()
|
|
|
|
|
.ne("check_scan_type", 0)
|
|
|
|
|
.eq("is_Display", 1)
|
|
|
|
|
.eq("is_Enable", 1));
|
|
|
|
|
Map<String, String> directionMap = dictDataService.getDictValueMap("direction")
|
|
|
|
|
.entrySet().stream().collect(java.util.stream.Collectors.toMap(
|
|
|
|
|
Map.Entry::getKey, e -> e.getValue().getLabel()));
|
|
|
|
|
|
|
|
|
|
// 动态表头
|
|
|
|
|
List<List<String>> head = new ArrayList<>();
|
|
|
|
|
head.add(Collections.singletonList("盘点批次号"));
|
|
|
|
|
head.add(Collections.singletonList("工单号"));
|
|
|
|
|
head.add(Collections.singletonList("位置"));
|
|
|
|
|
for (CheckConfDO conf : checkConfList) {
|
|
|
|
|
DictDataDO dictData = dictDataNameList.get(conf.getCheckName());
|
|
|
|
|
String remark = dictData != null && dictData.getLabel() != null
|
|
|
|
|
? dictData.getLabel().replaceAll("[a-zA-Z]", "")
|
|
|
|
|
: conf.getCheckName();
|
|
|
|
|
head.add(Collections.singletonList(remark));
|
|
|
|
|
head.add(Collections.singletonList("wms" + remark));
|
|
|
|
|
}
|
|
|
|
|
head.add(Collections.singletonList("盘点状态"));
|
|
|
|
|
head.add(Collections.singletonList("时间"));
|
|
|
|
|
|
|
|
|
|
// 动态数据
|
|
|
|
|
List<List<Object>> data = new ArrayList<>();
|
|
|
|
|
for (CheckLogDO log : list) {
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
row.add(log.getBatchNumber());
|
|
|
|
|
row.add(log.getTaskId());
|
|
|
|
|
row.add(position(log, directionMap));
|
|
|
|
|
for (CheckConfDO conf : checkConfList) {
|
|
|
|
|
String key = conf.getCheckName();
|
|
|
|
|
Map<String, String> extend = log.getExtendInfo() == null ? java.util.Collections.emptyMap() : log.getExtendInfo();
|
|
|
|
|
Map<String, String> wmsExtend = log.getWmsExtendInfo() == null ? java.util.Collections.emptyMap() : log.getWmsExtendInfo();
|
|
|
|
|
row.add(extend.get(key));
|
|
|
|
|
row.add(wmsExtend.get(key));
|
|
|
|
|
}
|
|
|
|
|
row.add(log.getStatusName() != null ? log.getStatusName() : log.getStatus());
|
|
|
|
|
row.add(log.getExportTime() != null ? log.getExportTime() : log.getCreateTime());
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 计算盘点位置:巷道名 + 方向 + 层-列 + 深浅 */
|
|
|
|
|
private String position(CheckLogDO log, Map<String, String> directionMap) {
|
|
|
|
|
String direction = directionMap.getOrDefault(String.valueOf(log.getDirection()), "");
|
|
|
|
|
return log.getStreetName() + "-" + direction + log.getRow() + "层-" + log.getColumn() + "列"
|
|
|
|
|
+ (log.getSeparation() != null && log.getSeparation() == 2 ? "-深" : "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|