|
|
@ -7,10 +7,16 @@ import com.gaotao.modules.automatedWarehouse.entity.WmsOrderTaskData; |
|
|
import com.gaotao.modules.automatedWarehouse.entity.WmsOrderTaskDetailData; |
|
|
import com.gaotao.modules.automatedWarehouse.entity.WmsOrderTaskDetailData; |
|
|
import com.gaotao.modules.check.entity.*; |
|
|
import com.gaotao.modules.check.entity.*; |
|
|
import com.gaotao.modules.check.service.PhysicalInventoryService; |
|
|
import com.gaotao.modules.check.service.PhysicalInventoryService; |
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.net.URLEncoder; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -405,7 +411,6 @@ public class PhysicalInventoryController { |
|
|
* @Description PDA提交盘点结果 - rqrq |
|
|
* @Description PDA提交盘点结果 - rqrq |
|
|
* @param query 包含site、countNo、palletId、scannedLabels、username |
|
|
* @param query 包含site、countNo、palletId、scannedLabels、username |
|
|
* @return R |
|
|
* @return R |
|
|
* @author rqrq |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/pda/submitCount") |
|
|
@PostMapping("/pda/submitCount") |
|
|
@SuppressWarnings("unchecked") |
|
|
@SuppressWarnings("unchecked") |
|
|
@ -544,4 +549,211 @@ public class PhysicalInventoryController { |
|
|
java.util.List<CountAdjustmentTransSubData> rows = countAdjustmentService.queryAdjustmentTransSubList(site, transNo); |
|
|
java.util.List<CountAdjustmentTransSubData> rows = countAdjustmentService.queryAdjustmentTransSubList(site, transNo); |
|
|
return R.ok().put("rows", rows); |
|
|
return R.ok().put("rows", rows); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ==================== 导出功能 ==================== - rqrq |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 导出盘点数据到Excel(多sheet)- rqrq |
|
|
|
|
|
* @param query 请求参数(包含site、countNo) |
|
|
|
|
|
* @param response HttpServletResponse |
|
|
|
|
|
* @author rqrq |
|
|
|
|
|
*/ |
|
|
|
|
|
@PostMapping("/exportCountDataExcel") |
|
|
|
|
|
public void exportCountDataExcel(@RequestBody java.util.Map<String, String> query, HttpServletResponse response) throws IOException { |
|
|
|
|
|
System.out.println("============ 开始导出盘点数据Excel ============"); |
|
|
|
|
|
String site = query.get("site"); |
|
|
|
|
|
String countNo = query.get("countNo"); |
|
|
|
|
|
System.out.println("site=" + site + ", countNo=" + countNo); |
|
|
|
|
|
|
|
|
|
|
|
// 获取各个Tab页的数据 - rqrq |
|
|
|
|
|
CountLabelData labelQuery = new CountLabelData(); |
|
|
|
|
|
labelQuery.setSite(site); |
|
|
|
|
|
labelQuery.setCountNo(countNo); |
|
|
|
|
|
List<CountLabelData> labelList = physicalInventoryService.searchCountLabelList(labelQuery); |
|
|
|
|
|
|
|
|
|
|
|
CountMaterialSummary summaryQuery = new CountMaterialSummary(); |
|
|
|
|
|
summaryQuery.setSite(site); |
|
|
|
|
|
summaryQuery.setCountNo(countNo); |
|
|
|
|
|
List<CountMaterialSummary> summaryList = physicalInventoryService.searchMaterialSummary(summaryQuery); |
|
|
|
|
|
|
|
|
|
|
|
CountPalletData palletQuery = new CountPalletData(); |
|
|
|
|
|
palletQuery.setSite(site); |
|
|
|
|
|
palletQuery.setCountNo(countNo); |
|
|
|
|
|
List<CountPalletData> palletList = physicalInventoryService.searchCountPalletList(palletQuery); |
|
|
|
|
|
|
|
|
|
|
|
CountResultData resultQuery = new CountResultData(); |
|
|
|
|
|
resultQuery.setSite(site); |
|
|
|
|
|
resultQuery.setCountNo(countNo); |
|
|
|
|
|
List<CountResultData> resultList = physicalInventoryService.searchCountResultList(resultQuery); |
|
|
|
|
|
|
|
|
|
|
|
CountAdjustmentRequest adjustmentQuery = new CountAdjustmentRequest(); |
|
|
|
|
|
adjustmentQuery.setSite(site); |
|
|
|
|
|
adjustmentQuery.setCountNo(countNo); |
|
|
|
|
|
List<CountAdjustmentTransData> adjustmentList = countAdjustmentService.queryAdjustmentTransList(adjustmentQuery); |
|
|
|
|
|
|
|
|
|
|
|
// 创建工作簿 - rqrq |
|
|
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
|
|
|
|
|
|
|
|
// 创建表头样式 - rqrq |
|
|
|
|
|
CellStyle headerStyle = workbook.createCellStyle(); |
|
|
|
|
|
headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
|
|
|
|
|
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
|
headerStyle.setBorderBottom(BorderStyle.THIN); |
|
|
|
|
|
headerStyle.setBorderTop(BorderStyle.THIN); |
|
|
|
|
|
headerStyle.setBorderLeft(BorderStyle.THIN); |
|
|
|
|
|
headerStyle.setBorderRight(BorderStyle.THIN); |
|
|
|
|
|
headerStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
|
Font headerFont = workbook.createFont(); |
|
|
|
|
|
headerFont.setBold(true); |
|
|
|
|
|
headerStyle.setFont(headerFont); |
|
|
|
|
|
|
|
|
|
|
|
// Sheet1: 标签明细 - rqrq |
|
|
|
|
|
Sheet sheet1 = workbook.createSheet("标签明细"); |
|
|
|
|
|
String[] labelHeaders = {"标签号", "物料号", "物料描述", "数量", "批号", "栈板号", "所在层数", "标签类型", "盘点状态", "盘点人", "盘点时间", "仓库", "库位"}; |
|
|
|
|
|
createHeaderRow(sheet1, labelHeaders, headerStyle); |
|
|
|
|
|
int rowNum1 = 1; |
|
|
|
|
|
for (CountLabelData item : labelList) { |
|
|
|
|
|
Row row = sheet1.createRow(rowNum1++); |
|
|
|
|
|
row.createCell(0).setCellValue(item.getUnitId() != null ? item.getUnitId() : ""); |
|
|
|
|
|
row.createCell(1).setCellValue(item.getPartNo() != null ? item.getPartNo() : ""); |
|
|
|
|
|
row.createCell(2).setCellValue(item.getPartDesc() != null ? item.getPartDesc() : ""); |
|
|
|
|
|
row.createCell(3).setCellValue(item.getQty() != null ? item.getQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(4).setCellValue(item.getBatchNo() != null ? item.getBatchNo() : ""); |
|
|
|
|
|
row.createCell(5).setCellValue(item.getPalletId() != null ? item.getPalletId() : ""); |
|
|
|
|
|
row.createCell(6).setCellValue(item.getLocationZ() != null ? item.getLocationZ() : 0); |
|
|
|
|
|
row.createCell(7).setCellValue(item.getLabelTypeDesc() != null ? item.getLabelTypeDesc() : ""); |
|
|
|
|
|
row.createCell(8).setCellValue(item.getCountFlagDesc() != null ? item.getCountFlagDesc() : ""); |
|
|
|
|
|
row.createCell(9).setCellValue(item.getCountUser() != null ? item.getCountUser() : ""); |
|
|
|
|
|
row.createCell(10).setCellValue(item.getCountDate() != null ? item.getCountDate().toString() : ""); |
|
|
|
|
|
row.createCell(11).setCellValue(item.getWarehouseName() != null ? item.getWarehouseName() : ""); |
|
|
|
|
|
row.createCell(12).setCellValue(item.getLocationName() != null ? item.getLocationName() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sheet2: 物料汇总 - rqrq |
|
|
|
|
|
Sheet sheet2 = workbook.createSheet("物料汇总"); |
|
|
|
|
|
String[] summaryHeaders = {"物料号", "物料描述", "批号", "WDR号", "仓库", "库位", "标签数", "总数量", "栈板数", "已盘点", "进度"}; |
|
|
|
|
|
createHeaderRow(sheet2, summaryHeaders, headerStyle); |
|
|
|
|
|
int rowNum2 = 1; |
|
|
|
|
|
for (CountMaterialSummary item : summaryList) { |
|
|
|
|
|
Row row = sheet2.createRow(rowNum2++); |
|
|
|
|
|
row.createCell(0).setCellValue(item.getPartNo() != null ? item.getPartNo() : ""); |
|
|
|
|
|
row.createCell(1).setCellValue(item.getPartDesc() != null ? item.getPartDesc() : ""); |
|
|
|
|
|
row.createCell(2).setCellValue(item.getBatchNo() != null ? item.getBatchNo() : ""); |
|
|
|
|
|
row.createCell(3).setCellValue(item.getWdr() != null ? item.getWdr() : ""); |
|
|
|
|
|
row.createCell(4).setCellValue(item.getWarehouseName() != null ? item.getWarehouseName() : ""); |
|
|
|
|
|
row.createCell(5).setCellValue(item.getLocationName() != null ? item.getLocationName() : ""); |
|
|
|
|
|
row.createCell(6).setCellValue(item.getLabelCount() != null ? item.getLabelCount() : 0); |
|
|
|
|
|
row.createCell(7).setCellValue(item.getTotalQty() != null ? item.getTotalQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(8).setCellValue(item.getPalletCount() != null ? item.getPalletCount() : 0); |
|
|
|
|
|
row.createCell(9).setCellValue(item.getCheckedLabelCount() != null ? item.getCheckedLabelCount() : 0); |
|
|
|
|
|
row.createCell(10).setCellValue(item.getProgressPercent() != null ? item.getProgressPercent() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sheet3: 栈板明细 - rqrq |
|
|
|
|
|
Sheet sheet3 = workbook.createSheet("栈板明细"); |
|
|
|
|
|
String[] palletHeaders = {"序号", "栈板号", "标签数", "已盘点", "进度", "盘点状态", "站点区域", "站点ID", "所在层数", "盘点人", "盘点时间"}; |
|
|
|
|
|
createHeaderRow(sheet3, palletHeaders, headerStyle); |
|
|
|
|
|
int rowNum3 = 1; |
|
|
|
|
|
for (CountPalletData item : palletList) { |
|
|
|
|
|
Row row = sheet3.createRow(rowNum3++); |
|
|
|
|
|
row.createCell(0).setCellValue(item.getSeqNo() != null ? item.getSeqNo() : 0); |
|
|
|
|
|
row.createCell(1).setCellValue(item.getPalletId() != null ? item.getPalletId() : ""); |
|
|
|
|
|
row.createCell(2).setCellValue(item.getLabelCount() != null ? item.getLabelCount() : 0); |
|
|
|
|
|
row.createCell(3).setCellValue(item.getCheckedCount() != null ? item.getCheckedCount() : 0); |
|
|
|
|
|
row.createCell(4).setCellValue(item.getProgressPercent() != null ? item.getProgressPercent() : ""); |
|
|
|
|
|
row.createCell(5).setCellValue(item.getCountFlagDesc() != null ? item.getCountFlagDesc() : ""); |
|
|
|
|
|
row.createCell(6).setCellValue(item.getStationArea() != null ? item.getStationArea() : ""); |
|
|
|
|
|
row.createCell(7).setCellValue(item.getStationId() != null ? item.getStationId() : ""); |
|
|
|
|
|
row.createCell(8).setCellValue(item.getLocationZ() != null ? item.getLocationZ() : 0); |
|
|
|
|
|
row.createCell(9).setCellValue(item.getCountUser() != null ? item.getCountUser() : ""); |
|
|
|
|
|
row.createCell(10).setCellValue(item.getCountDate() != null ? item.getCountDate().toString() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sheet4: 盘点结果 - rqrq |
|
|
|
|
|
Sheet sheet4 = workbook.createSheet("盘点结果"); |
|
|
|
|
|
String[] resultHeaders = {"标签号", "物料号", "物料描述", "数量", "差异数量", "批号", "栈板号", "盘点结果", "处理方式", "盘点人", "盘点时间", "备注"}; |
|
|
|
|
|
createHeaderRow(sheet4, resultHeaders, headerStyle); |
|
|
|
|
|
int rowNum4 = 1; |
|
|
|
|
|
for (CountResultData item : resultList) { |
|
|
|
|
|
Row row = sheet4.createRow(rowNum4++); |
|
|
|
|
|
row.createCell(0).setCellValue(item.getUnitId() != null ? item.getUnitId() : ""); |
|
|
|
|
|
row.createCell(1).setCellValue(item.getPartNo() != null ? item.getPartNo() : ""); |
|
|
|
|
|
row.createCell(2).setCellValue(item.getPartDesc() != null ? item.getPartDesc() : ""); |
|
|
|
|
|
row.createCell(3).setCellValue(item.getQty() != null ? item.getQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(4).setCellValue(item.getDiffQty() != null ? item.getDiffQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(5).setCellValue(item.getBatchNo() != null ? item.getBatchNo() : ""); |
|
|
|
|
|
row.createCell(6).setCellValue(item.getPalletId() != null ? item.getPalletId() : ""); |
|
|
|
|
|
row.createCell(7).setCellValue(item.getCountResultDesc() != null ? item.getCountResultDesc() : ""); |
|
|
|
|
|
row.createCell(8).setCellValue(item.getHandleTypeDesc() != null ? item.getHandleTypeDesc() : ""); |
|
|
|
|
|
row.createCell(9).setCellValue(item.getCountUser() != null ? item.getCountUser() : ""); |
|
|
|
|
|
row.createCell(10).setCellValue(item.getCountDate() != null ? item.getCountDate().toString() : ""); |
|
|
|
|
|
row.createCell(11).setCellValue(item.getRemark() != null ? item.getRemark() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sheet5: 盘点结果差异 - rqrq |
|
|
|
|
|
Sheet sheet5 = workbook.createSheet("盘点结果差异"); |
|
|
|
|
|
String[] resultDiffHeaders = {"标签号", "物料号", "物料描述", "数量", "差异数量", "批号", "栈板号", "盘点结果", "是否处理", "处理方式", "盘点人", "盘点时间", "备注"}; |
|
|
|
|
|
createHeaderRow(sheet5, resultDiffHeaders, headerStyle); |
|
|
|
|
|
int rowNum5 = 1; |
|
|
|
|
|
for (CountResultData item : resultList) { |
|
|
|
|
|
if (!"OK".equals(item.getCountResult())) { |
|
|
|
|
|
Row row = sheet5.createRow(rowNum5++); |
|
|
|
|
|
row.createCell(0).setCellValue(item.getUnitId() != null ? item.getUnitId() : ""); |
|
|
|
|
|
row.createCell(1).setCellValue(item.getPartNo() != null ? item.getPartNo() : ""); |
|
|
|
|
|
row.createCell(2).setCellValue(item.getPartDesc() != null ? item.getPartDesc() : ""); |
|
|
|
|
|
row.createCell(3).setCellValue(item.getQty() != null ? item.getQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(4).setCellValue(item.getDiffQty() != null ? item.getDiffQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(5).setCellValue(item.getBatchNo() != null ? item.getBatchNo() : ""); |
|
|
|
|
|
row.createCell(6).setCellValue(item.getPalletId() != null ? item.getPalletId() : ""); |
|
|
|
|
|
row.createCell(7).setCellValue(item.getCountResultDesc() != null ? item.getCountResultDesc() : ""); |
|
|
|
|
|
row.createCell(8).setCellValue(item.getHandleFlagDesc() != null ? item.getHandleFlagDesc() : ""); |
|
|
|
|
|
row.createCell(9).setCellValue(item.getHandleTypeDesc() != null ? item.getHandleTypeDesc() : ""); |
|
|
|
|
|
row.createCell(10).setCellValue(item.getCountUser() != null ? item.getCountUser() : ""); |
|
|
|
|
|
row.createCell(11).setCellValue(item.getCountDate() != null ? item.getCountDate().toString() : ""); |
|
|
|
|
|
row.createCell(12).setCellValue(item.getRemark() != null ? item.getRemark() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sheet6: 盘盈盘亏明细 - rqrq |
|
|
|
|
|
Sheet sheet6 = workbook.createSheet("盘盈盘亏明细"); |
|
|
|
|
|
String[] adjustmentHeaders = {"单据号", "事务类型", "行号", "物料号", "数量", "批号", "库位", "方向", "仓库", "操作人"}; |
|
|
|
|
|
createHeaderRow(sheet6, adjustmentHeaders, headerStyle); |
|
|
|
|
|
int rowNum6 = 1; |
|
|
|
|
|
for (CountAdjustmentTransData item : adjustmentList) { |
|
|
|
|
|
Row row = sheet6.createRow(rowNum6++); |
|
|
|
|
|
row.createCell(0).setCellValue(item.getTransNo() != null ? item.getTransNo() : ""); |
|
|
|
|
|
row.createCell(1).setCellValue(item.getTransTypeDesc() != null ? item.getTransTypeDesc() : ""); |
|
|
|
|
|
row.createCell(2).setCellValue(item.getItemNo() != null ? item.getItemNo() : 0); |
|
|
|
|
|
row.createCell(3).setCellValue(item.getPartNo() != null ? item.getPartNo() : ""); |
|
|
|
|
|
row.createCell(4).setCellValue(item.getTransQty() != null ? item.getTransQty().doubleValue() : 0); |
|
|
|
|
|
row.createCell(5).setCellValue(item.getBatchNo() != null ? item.getBatchNo() : ""); |
|
|
|
|
|
row.createCell(6).setCellValue(item.getLocationId() != null ? item.getLocationId() : ""); |
|
|
|
|
|
row.createCell(7).setCellValue(item.getDirectionDesc() != null ? item.getDirectionDesc() : ""); |
|
|
|
|
|
row.createCell(8).setCellValue(item.getWarehouseId() != null ? item.getWarehouseId() : ""); |
|
|
|
|
|
row.createCell(9).setCellValue(item.getUserName() != null ? item.getUserName() : ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 设置响应头 - rqrq |
|
|
|
|
|
String fileName = "盘点数据_" + countNo + ".xlsx"; |
|
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8")); |
|
|
|
|
|
|
|
|
|
|
|
// 写入响应 - rqrq |
|
|
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
|
|
workbook.close(); |
|
|
|
|
|
System.out.println("============ 导出盘点数据Excel完成 ============"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建表头行 - rqrq |
|
|
|
|
|
*/ |
|
|
|
|
|
private void createHeaderRow(Sheet sheet, String[] headers, CellStyle headerStyle) { |
|
|
|
|
|
Row headerRow = sheet.createRow(0); |
|
|
|
|
|
for (int i = 0; i < headers.length; i++) { |
|
|
|
|
|
Cell cell = headerRow.createCell(i); |
|
|
|
|
|
cell.setCellValue(headers[i]); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
sheet.setColumnWidth(i, 15 * 256); // 设置列宽 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |