Merge branch '0.8.X' of http://49.232.154.205:10100/DeXun/klp-oa into 0.8.X
This commit is contained in:
@@ -5708,41 +5708,134 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 构建EasyExcel导出数据 - O(n)复杂度
|
||||
List<WmsCoilAbnormalExportVo> exportData = new ArrayList<>();
|
||||
// 5. 计算最大异常数,用于动态生成横向异常列组
|
||||
int maxAbnormalCount = 1;
|
||||
for (List<WmsCoilAbnormal> list : abnormalMap.values()) {
|
||||
if (list.size() > maxAbnormalCount) {
|
||||
maxAbnormalCount = list.size();
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 构建动态表头:钢卷信息 + 改判原因 + N组异常信息
|
||||
List<List<String>> headers = new ArrayList<>();
|
||||
// 钢卷信息列(25列)
|
||||
headers.add(Arrays.asList("类型"));
|
||||
headers.add(Arrays.asList("逻辑库区"));
|
||||
headers.add(Arrays.asList("实际库区"));
|
||||
headers.add(Arrays.asList("入场卷号"));
|
||||
headers.add(Arrays.asList("厂家卷号"));
|
||||
headers.add(Arrays.asList("成品卷号"));
|
||||
headers.add(Arrays.asList("日期"));
|
||||
headers.add(Arrays.asList("重量"));
|
||||
headers.add(Arrays.asList("用途"));
|
||||
headers.add(Arrays.asList("切边要求"));
|
||||
headers.add(Arrays.asList("包装种类"));
|
||||
headers.add(Arrays.asList("产品质量"));
|
||||
headers.add(Arrays.asList("原料材质"));
|
||||
headers.add(Arrays.asList("库存状态"));
|
||||
headers.add(Arrays.asList("备注"));
|
||||
headers.add(Arrays.asList("名称"));
|
||||
headers.add(Arrays.asList("规格"));
|
||||
headers.add(Arrays.asList("长度"));
|
||||
headers.add(Arrays.asList("材质"));
|
||||
headers.add(Arrays.asList("厂家"));
|
||||
headers.add(Arrays.asList("表面处理"));
|
||||
headers.add(Arrays.asList("锌层"));
|
||||
headers.add(Arrays.asList("物品ID"));
|
||||
headers.add(Arrays.asList("操作完成时间"));
|
||||
headers.add(Arrays.asList("调拨类型"));
|
||||
// 改判原因列
|
||||
headers.add(Arrays.asList("改判原因"));
|
||||
// N组异常信息列
|
||||
String[] abnormalColNames = {"产线", "位置", "长度坐标", "缺陷开始位置", "缺陷结束位置",
|
||||
"缺陷代码", "缺陷类型", "缺陷率", "缺陷重量", "程度",
|
||||
"主标记", "整卷标记", "异常备注", "板面"};
|
||||
for (int i = 1; i <= maxAbnormalCount; i++) {
|
||||
for (String colName : abnormalColNames) {
|
||||
headers.add(Arrays.asList(i + "." + colName));
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 构建数据行:一钢卷一行,异常信息横向拼接
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
List<List<Object>> exportData = new ArrayList<>();
|
||||
|
||||
for (WmsMaterialCoilVo coil : coilList) {
|
||||
Long coilId = coil.getCoilId();
|
||||
List<WmsCoilAbnormal> abnormalList = abnormalMap.getOrDefault(coilId, new ArrayList<>());
|
||||
String rejudgeReason = rejudgeReasonMap.get(coilId);
|
||||
List<Object> row = new ArrayList<>();
|
||||
|
||||
if (abnormalList.isEmpty()) {
|
||||
// 无异常信息的钢卷,创建一行空异常数据
|
||||
WmsCoilAbnormalExportVo dto = createExportVo(coil, rejudgeReason, null, sdf);
|
||||
dto.setCoilId(coilId);
|
||||
exportData.add(dto);
|
||||
} else {
|
||||
// 有异常信息的钢卷,每个异常创建一行
|
||||
for (WmsCoilAbnormal abnormal : abnormalList) {
|
||||
WmsCoilAbnormalExportVo dto = createExportVo(coil, rejudgeReason, abnormal, sdf);
|
||||
dto.setCoilId(coilId);
|
||||
exportData.add(dto);
|
||||
// 钢卷基本信息
|
||||
row.add(coil.getItemType() != null ? coil.getItemType() : "");
|
||||
row.add(coil.getWarehouseName() != null ? coil.getWarehouseName() : "");
|
||||
row.add(coil.getActualWarehouseName() != null ? coil.getActualWarehouseName() : "");
|
||||
row.add(coil.getEnterCoilNo() != null ? coil.getEnterCoilNo() : "");
|
||||
row.add(coil.getSupplierCoilNo() != null ? coil.getSupplierCoilNo() : "");
|
||||
row.add(coil.getCurrentCoilNo() != null ? coil.getCurrentCoilNo() : "");
|
||||
row.add(coil.getCreateTime() != null ? sdf.format(coil.getCreateTime()) : "");
|
||||
row.add(coil.getNetWeight() != null ? coil.getNetWeight().toString() : "");
|
||||
row.add(coil.getBusinessPurpose() != null ? coil.getBusinessPurpose() : "");
|
||||
row.add(coil.getTrimmingRequirement() != null ? coil.getTrimmingRequirement() : "");
|
||||
row.add(coil.getPackagingRequirement() != null ? coil.getPackagingRequirement() : "");
|
||||
row.add(coil.getQualityStatus() != null ? coil.getQualityStatus() : "");
|
||||
row.add(coil.getPackingStatus() != null ? coil.getPackingStatus() : "");
|
||||
row.add(coil.getStatus() != null ? coil.getStatus().toString() : "");
|
||||
row.add(coil.getRemark() != null ? coil.getRemark() : "");
|
||||
row.add(coil.getItemName() != null ? coil.getItemName() : "");
|
||||
row.add(coil.getSpecification() != null ? coil.getSpecification() : "");
|
||||
row.add(coil.getLength() != null ? coil.getLength().toString() : "");
|
||||
row.add(coil.getMaterial() != null ? coil.getMaterial() : "");
|
||||
row.add(coil.getManufacturer() != null ? coil.getManufacturer() : "");
|
||||
row.add(coil.getSurfaceTreatmentDesc() != null ? coil.getSurfaceTreatmentDesc() : "");
|
||||
row.add(coil.getZincLayer() != null ? coil.getZincLayer() : "");
|
||||
row.add(coil.getItemId() != null ? coil.getItemId().toString() : "");
|
||||
row.add(coil.getActionCompleteTime() != null ? sdf.format(coil.getActionCompleteTime()) : "");
|
||||
row.add(coil.getTransferType() != null ? coil.getTransferType() : "");
|
||||
// 改判原因
|
||||
row.add(rejudgeReason != null ? rejudgeReason : "");
|
||||
|
||||
// 异常信息组(每组17列)
|
||||
for (int i = 0; i < maxAbnormalCount; i++) {
|
||||
if (i < abnormalList.size()) {
|
||||
WmsCoilAbnormal a = abnormalList.get(i);
|
||||
row.add(a.getProductionLine() != null ? a.getProductionLine() : "");
|
||||
row.add(a.getPosition() != null ? a.getPosition() : "");
|
||||
row.add(a.getLength() != null ? a.getLength().toString() : "");
|
||||
row.add(a.getStartPosition() != null ? a.getStartPosition().toString() : "");
|
||||
row.add(a.getEndPosition() != null ? a.getEndPosition().toString() : "");
|
||||
row.add(a.getDefectCode() != null ? a.getDefectCode() : "");
|
||||
row.add(a.getDefectType() != null ? a.getDefectType() : "");
|
||||
row.add(a.getDefectRate() != null ? a.getDefectRate().toString() : "");
|
||||
row.add(a.getDefectWeight() != null ? a.getDefectWeight().toString() : "");
|
||||
row.add(a.getDegree() != null ? a.getDegree() : "");
|
||||
// row.add(a.getJudgeLevel() != null ? a.getJudgeLevel() : "");
|
||||
// row.add(a.getJudgeBy() != null ? a.getJudgeBy() : "");
|
||||
// row.add(a.getJudgeTime() != null ? sdf.format(a.getJudgeTime()) : "");
|
||||
row.add(a.getMainMark() != null ? a.getMainMark().toString() : "");
|
||||
row.add(a.getWholeCoilMark() != null ? a.getWholeCoilMark().toString() : "");
|
||||
row.add(a.getRemark() != null ? a.getRemark() : "");
|
||||
row.add(a.getPlateSurface() != null ? a.getPlateSurface() : "");
|
||||
} else {
|
||||
// 不足的异常组填充空字符串
|
||||
for (int j = 0; j < 17; j++) {
|
||||
row.add("");
|
||||
}
|
||||
}
|
||||
}
|
||||
exportData.add(row);
|
||||
}
|
||||
|
||||
// 6. 使用EasyExcel导出 - O(n)复杂度,瞬间完成
|
||||
// 8. 使用EasyExcel动态表头导出
|
||||
try {
|
||||
// 设置响应头
|
||||
String filename = "abnormal_report_" + System.currentTimeMillis() + ".xlsx";
|
||||
String encoded = URLEncoder.encode(filename, StandardCharsets.UTF_8.name());
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encoded);
|
||||
|
||||
// 使用EasyExcel写入,正常导出
|
||||
EasyExcel.write(response.getOutputStream(), WmsCoilAbnormalExportVo.class)
|
||||
EasyExcel.write(response.getOutputStream())
|
||||
.head(headers)
|
||||
.sheet("异常报表")
|
||||
.doWrite(exportData);
|
||||
|
||||
@@ -5751,90 +5844,6 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 创建导出DTO对象
|
||||
*/
|
||||
private WmsCoilAbnormalExportVo createExportVo(WmsMaterialCoilVo coil, String rejudgeReason,
|
||||
WmsCoilAbnormal abnormal, SimpleDateFormat sdf) {
|
||||
WmsCoilAbnormalExportVo dto = new WmsCoilAbnormalExportVo();
|
||||
|
||||
// 钢卷基本信息(前25列)
|
||||
dto.setItemType(coil.getItemType() != null ? coil.getItemType() : "");
|
||||
dto.setWarehouseName(coil.getWarehouseName() != null ? coil.getWarehouseName() : "");
|
||||
dto.setActualWarehouseName(coil.getActualWarehouseName() != null ? coil.getActualWarehouseName() : "");
|
||||
dto.setEnterCoilNo(coil.getEnterCoilNo() != null ? coil.getEnterCoilNo() : "");
|
||||
dto.setSupplierCoilNo(coil.getSupplierCoilNo() != null ? coil.getSupplierCoilNo() : "");
|
||||
dto.setCurrentCoilNo(coil.getCurrentCoilNo() != null ? coil.getCurrentCoilNo() : "");
|
||||
dto.setCreateTime(coil.getCreateTime() != null ? sdf.format(coil.getCreateTime()) : "");
|
||||
dto.setNetWeight(coil.getNetWeight() != null ? coil.getNetWeight().toString() : "");
|
||||
dto.setBusinessPurpose(coil.getBusinessPurpose() != null ? coil.getBusinessPurpose() : "");
|
||||
dto.setTrimmingRequirement(coil.getTrimmingRequirement() != null ? coil.getTrimmingRequirement() : "");
|
||||
dto.setPackagingRequirement(coil.getPackagingRequirement() != null ? coil.getPackagingRequirement() : "");
|
||||
dto.setQualityStatus(coil.getQualityStatus() != null ? coil.getQualityStatus() : "");
|
||||
dto.setPackingStatus(coil.getPackingStatus() != null ? coil.getPackingStatus() : "");
|
||||
dto.setStatus(coil.getStatus() != null ? coil.getStatus().toString() : "");
|
||||
dto.setRemark(coil.getRemark() != null ? coil.getRemark() : "");
|
||||
dto.setItemName(coil.getItemName() != null ? coil.getItemName() : "");
|
||||
dto.setSpecification(coil.getSpecification() != null ? coil.getSpecification() : "");
|
||||
dto.setLength(coil.getLength() != null ? coil.getLength().toString() : "");
|
||||
dto.setMaterial(coil.getMaterial() != null ? coil.getMaterial() : "");
|
||||
dto.setManufacturer(coil.getManufacturer() != null ? coil.getManufacturer() : "");
|
||||
dto.setSurfaceTreatmentDesc(coil.getSurfaceTreatmentDesc() != null ? coil.getSurfaceTreatmentDesc() : "");
|
||||
dto.setZincLayer(coil.getZincLayer() != null ? coil.getZincLayer() : "");
|
||||
dto.setItemId(coil.getItemId() != null ? coil.getItemId().toString() : "");
|
||||
dto.setActionCompleteTime(coil.getActionCompleteTime() != null ? sdf.format(coil.getActionCompleteTime()) : "");
|
||||
dto.setTransferType(coil.getTransferType() != null ? coil.getTransferType() : "");
|
||||
|
||||
// 改判原因(第26列)
|
||||
dto.setRejudgeReason(rejudgeReason != null ? rejudgeReason : "");
|
||||
|
||||
// 异常信息(后17列)
|
||||
if (abnormal != null) {
|
||||
dto.setProductionLine(abnormal.getProductionLine() != null ? abnormal.getProductionLine() : "");
|
||||
dto.setPosition(abnormal.getPosition() != null ? abnormal.getPosition() : "");
|
||||
dto.setAbnormalLength(abnormal.getLength() != null ? abnormal.getLength().toString() : "");
|
||||
dto.setStartPosition(abnormal.getStartPosition() != null ? abnormal.getStartPosition().toString() : "");
|
||||
dto.setEndPosition(abnormal.getEndPosition() != null ? abnormal.getEndPosition().toString() : "");
|
||||
dto.setDefectCode(abnormal.getDefectCode() != null ? abnormal.getDefectCode() : "");
|
||||
dto.setDefectType(abnormal.getDefectType() != null ? abnormal.getDefectType() : "");
|
||||
dto.setDefectRate(abnormal.getDefectRate() != null ? abnormal.getDefectRate().toString() : "");
|
||||
dto.setDefectWeight(abnormal.getDefectWeight() != null ? abnormal.getDefectWeight().toString() : "");
|
||||
dto.setDegree(abnormal.getDegree() != null ? abnormal.getDegree() : "");
|
||||
dto.setJudgeLevel(abnormal.getJudgeLevel() != null ? abnormal.getJudgeLevel() : "");
|
||||
dto.setJudgeBy(abnormal.getJudgeBy() != null ? abnormal.getJudgeBy() : "");
|
||||
dto.setJudgeTime(abnormal.getJudgeTime() != null ? sdf.format(abnormal.getJudgeTime()) : "");
|
||||
dto.setMainMark(abnormal.getMainMark() != null ? abnormal.getMainMark().toString() : "");
|
||||
dto.setWholeCoilMark(abnormal.getWholeCoilMark() != null ? abnormal.getWholeCoilMark().toString() : "");
|
||||
dto.setAbnormalRemark(abnormal.getRemark() != null ? abnormal.getRemark() : "");
|
||||
dto.setPlateSurface(abnormal.getPlateSurface() != null ? abnormal.getPlateSurface() : "");
|
||||
// dto.setSourceSystem(abnormal.getSourceSystem() != null ? abnormal.getSourceSystem().toString() : "");
|
||||
// dto.setProcessSource(abnormal.getProcessSource() != null ? abnormal.getProcessSource() : "");
|
||||
} else {
|
||||
// 空异常信息
|
||||
dto.setProductionLine("");
|
||||
dto.setPosition("");
|
||||
dto.setAbnormalLength("");
|
||||
dto.setStartPosition("");
|
||||
dto.setEndPosition("");
|
||||
dto.setDefectCode("");
|
||||
dto.setDefectType("");
|
||||
dto.setDefectRate("");
|
||||
dto.setDefectWeight("");
|
||||
dto.setDegree("");
|
||||
dto.setJudgeLevel("");
|
||||
dto.setJudgeBy("");
|
||||
dto.setJudgeTime("");
|
||||
dto.setMainMark("");
|
||||
dto.setWholeCoilMark("");
|
||||
dto.setAbnormalRemark("");
|
||||
dto.setPlateSurface("");
|
||||
// dto.setSourceSystem("");
|
||||
// dto.setProcessSource("");
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryEarliestHotRolledMaterial(String enterCoilNo) {
|
||||
if (StringUtils.isBlank(enterCoilNo)) {
|
||||
@@ -5937,28 +5946,4 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象解析为Date类型
|
||||
* 支持Number、Date和字符串格式的时间对象
|
||||
*
|
||||
* @param obj 时间对象,可以是Number、Date或String
|
||||
* @return 解析后的Date对象,解析失败返回null
|
||||
*/
|
||||
private Date parseDateFromObject(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
if (obj instanceof Number) {
|
||||
// 处理时间戳格式
|
||||
return new Date(((Number) obj).longValue());
|
||||
}
|
||||
if (obj instanceof Date) {
|
||||
// 已经是Date类型,直接返回
|
||||
return (Date) obj;
|
||||
}
|
||||
// 字符串格式,使用工具类解析
|
||||
return DateUtils.parseDate(obj.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user