|
|
|
@ -15,11 +15,20 @@ import com.gaotao.modules.shopOrder.entity.*; |
|
|
|
import com.gaotao.modules.shopOrder.entity.SfdcRollsReportExecuteData; |
|
|
|
import com.gaotao.modules.shopOrder.service.ProductionReportService; |
|
|
|
import com.gaotao.modules.sys.service.SysMsgService; |
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
import org.apache.poi.xssf.streaming.SXSSFSheet; |
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -244,4 +253,120 @@ public class ProductionReportServiceImpl implements ProductionReportService { |
|
|
|
|
|
|
|
return responseData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportSfdcRollsReport(SFDCRollsOutData indata, HttpServletResponse response) throws IOException { |
|
|
|
if (indata == null) { |
|
|
|
indata = new SFDCRollsOutData(); |
|
|
|
} |
|
|
|
indata.setPage(null); |
|
|
|
indata.setLimit(null); |
|
|
|
|
|
|
|
String fileName = URLEncoder.encode( |
|
|
|
"订单产出标签统计_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()), |
|
|
|
"UTF-8" |
|
|
|
).replace("+", "%20"); |
|
|
|
|
|
|
|
response.setCharacterEncoding(StandardCharsets.UTF_8.name()); |
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + fileName + ".xlsx"); |
|
|
|
|
|
|
|
SXSSFWorkbook workbook = new SXSSFWorkbook(500); |
|
|
|
workbook.setCompressTempFiles(true); |
|
|
|
SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
try { |
|
|
|
SXSSFSheet sheet = workbook.createSheet("订单产出标签统计"); |
|
|
|
int rowIndex = 0; |
|
|
|
Row headerRow = sheet.createRow(rowIndex++); |
|
|
|
fillSfdcRollsExportHeader(headerRow); |
|
|
|
|
|
|
|
List<SFDCRollsOutData> records = productionReportMapper.searchSfdcRollsReport(indata); |
|
|
|
if (records != null) { |
|
|
|
for (SFDCRollsOutData item : records) { |
|
|
|
Row row = sheet.createRow(rowIndex++); |
|
|
|
fillSfdcRollsExportRow(row, item, dateTimeFormatter); |
|
|
|
} |
|
|
|
} |
|
|
|
sheet.flushRows(500); |
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
response.flushBuffer(); |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
workbook.close(); |
|
|
|
} finally { |
|
|
|
workbook.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void fillSfdcRollsExportHeader(Row headerRow) { |
|
|
|
String[] headers = new String[]{ |
|
|
|
"卷标签", "卷数量", "良品数", "面损", "性能不良", "不良数", "良率", "总数", "Packing List", |
|
|
|
"物料编码", "物料名称", "规格型号", "上级卷标签号", "上机卷标签类型", |
|
|
|
"来源工单号", "来源派工单号", "来源工序号", "生产机台", "创建人", "创建时间", |
|
|
|
"消耗工单号", "消耗派工单号", "消耗工序号", "消耗机台", "上机时间", "下机时间", |
|
|
|
"标签类型", "状态", "标签备注" |
|
|
|
}; |
|
|
|
for (int i = 0; i < headers.length; i++) { |
|
|
|
headerRow.createCell(i).setCellValue(headers[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void fillSfdcRollsExportRow(Row row, SFDCRollsOutData item, SimpleDateFormat dateTimeFormatter) { |
|
|
|
String[] values = new String[]{ |
|
|
|
safeValue(item.getRollNo()), |
|
|
|
safeValue(item.getRollQty()), |
|
|
|
safeValue(item.getGoodQty()), |
|
|
|
safeValue(item.getSurfaceLossQty()), |
|
|
|
safeValue(item.getPoorPerformanceQty()), |
|
|
|
safeValue(item.getDefectQty()), |
|
|
|
safeValue(item.getYieldRate()), |
|
|
|
safeValue(item.getTotalQty()), |
|
|
|
safeValue(item.getPackingList()), |
|
|
|
safeValue(item.getPartNo()), |
|
|
|
safeValue(item.getPartDesc()), |
|
|
|
safeValue(item.getSpec()), |
|
|
|
safeValue(item.getParentRollNo()), |
|
|
|
safeValue(item.getParentRollType()), |
|
|
|
safeValue(item.getOrderNo()), |
|
|
|
formatWholeNumber(item.getCreatedOpsSeqNo()), |
|
|
|
formatWholeNumber(item.getCreatedOpsItemNo()), |
|
|
|
safeValue(item.getProductionResourceID()), |
|
|
|
safeValue(item.getCreatedby()), |
|
|
|
formatDate(item.getCreatedDate(), dateTimeFormatter), |
|
|
|
safeValue(item.getConsumeOrderNo()), |
|
|
|
safeValue(item.getConsumeSeqNo()), |
|
|
|
safeValue(item.getConsumeItemNo()), |
|
|
|
safeValue(item.getConsumptionResourceID()), |
|
|
|
formatDate(item.getDate1(), dateTimeFormatter), |
|
|
|
formatDate(item.getDate2(), dateTimeFormatter), |
|
|
|
safeValue(item.getRollType()), |
|
|
|
safeValue(item.getFinalStatus()), |
|
|
|
safeValue(item.getRemark()) |
|
|
|
}; |
|
|
|
for (int i = 0; i < values.length; i++) { |
|
|
|
row.createCell(i).setCellValue(values[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String formatWholeNumber(double value) { |
|
|
|
if (value == (long) value) { |
|
|
|
return String.valueOf((long) value); |
|
|
|
} |
|
|
|
return String.valueOf(value); |
|
|
|
} |
|
|
|
|
|
|
|
private String formatDate(Date value, SimpleDateFormat formatter) { |
|
|
|
if (value == null) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
return formatter.format(value); |
|
|
|
} |
|
|
|
|
|
|
|
private String safeValue(Object value) { |
|
|
|
if (value == null) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
return String.valueOf(value); |
|
|
|
} |
|
|
|
} |