Merge pull request 'fix: 지붕재적합성 pdf 생성시간 통일' (#81) from feature/suitable into dev

Reviewed-on: #81
This commit is contained in:
seul 2025-06-27 15:03:07 +09:00
commit 443c3f7fb9
2 changed files with 50 additions and 28 deletions

View File

@ -93,12 +93,14 @@ async function createSuitablePdf(request: NextRequest): Promise<NextResponse> {
/* pdf 생성 : mainId 100개씩 청크로 나누기 */ /* pdf 생성 : mainId 100개씩 청크로 나누기 */
const CHUNK_SIZE = 100 const CHUNK_SIZE = 100
const pdfBuffers: Uint8Array[] = [] const pdfBuffers: Uint8Array[] = []
const createTime = formatDateString()
for (let i = 0; i < suitable.length; i += CHUNK_SIZE) { for (let i = 0; i < suitable.length; i += CHUNK_SIZE) {
const chunk = suitable.slice(i, i + CHUNK_SIZE) const chunk = suitable.slice(i, i + CHUNK_SIZE)
const content = React.createElement( const content = React.createElement(
Document, Document,
null, null,
React.createElement(SuitablePdf, { React.createElement(SuitablePdf, {
createTime,
data: chunk, data: chunk,
fileTitle: fileTitle, fileTitle: fileTitle,
firstPage: i === 0, firstPage: i === 0,
@ -127,6 +129,21 @@ async function createSuitablePdf(request: NextRequest): Promise<NextResponse> {
} }
} }
/**
* @description
* @returns
*/
const formatDateString = () => {
const now = new Date()
const year = now.getFullYear()
const month = now.getMonth() + 1
const day = now.getDate()
const hours = now.getHours()
const minutes = now.getMinutes()
return `${year}${month}${day}${hours}:${minutes.toString().padStart(2, '0')}`
}
/** /**
* @description PDF * @description PDF
* @param buffers PDF * @param buffers PDF

View File

@ -47,9 +47,9 @@ const styles = StyleSheet.create({
display: 'flex', display: 'flex',
flexWrap: 'wrap', flexWrap: 'wrap',
flexDirection: 'row', flexDirection: 'row',
gap: 20 gap: 20,
}, },
tableCard:{ tableCard: {
width: '48.7%', width: '48.7%',
}, },
tableTitWrap: { tableTitWrap: {
@ -58,7 +58,7 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
marginBottom: 5, marginBottom: 5,
}, },
tableTit:{ tableTit: {
fontSize: 8, fontSize: 8,
fontWeight: 500, fontWeight: 500,
fontFamily: 'NotoSansJP', fontFamily: 'NotoSansJP',
@ -66,11 +66,11 @@ const styles = StyleSheet.create({
}, },
tableTit01: { tableTit01: {
paddingRight: 6, paddingRight: 6,
borderRight: '1px solid #101010' borderRight: '1px solid #101010',
}, },
tableTit02: { tableTit02: {
padding: '0 6', padding: '0 6',
borderRight: '1px solid #101010' borderRight: '1px solid #101010',
}, },
tableTit03: { tableTit03: {
paddingLeft: 6, paddingLeft: 6,
@ -100,7 +100,7 @@ const styles = StyleSheet.create({
color: '#fff', color: '#fff',
backgroundColor: '#18B490', backgroundColor: '#18B490',
border: '1px solid #18B490', border: '1px solid #18B490',
textAlign: 'center' textAlign: 'center',
}, },
tableTd: { tableTd: {
display: 'flex', display: 'flex',
@ -113,10 +113,10 @@ const styles = StyleSheet.create({
border: '1px solid #CBCBCB', border: '1px solid #CBCBCB',
padding: 3, padding: 3,
}, },
marginL:{ marginL: {
marginLeft: -1, marginLeft: -1,
}, },
marginT:{ marginT: {
marginTop: -1, marginTop: -1,
}, },
footer: { footer: {
@ -134,20 +134,17 @@ const styles = StyleSheet.create({
}, },
}) })
const formatDateString = () => { export default function SuitablePdf({
const now = new Date() createTime,
const year = now.getFullYear() data,
const month = now.getMonth() + 1 fileTitle,
const day = now.getDate() firstPage,
const hours = now.getHours() }: {
const minutes = now.getMinutes() createTime: string
data: Suitable[]
return `${year}${month}${day}${hours}:${minutes.toString().padStart(2, '0')}` fileTitle: string
} firstPage: boolean
}) {
export default function SuitablePdf({ data, fileTitle, firstPage }: { data: Suitable[]; fileTitle: string; firstPage: boolean }) {
const createTime = formatDateString()
return ( return (
<Page size="A4" orientation="landscape" style={styles.page}> <Page size="A4" orientation="landscape" style={styles.page}>
{/* Intro Section */} {/* Intro Section */}
@ -185,19 +182,27 @@ export default function SuitablePdf({ data, fileTitle, firstPage }: { data: Suit
{/* Table Header */} {/* Table Header */}
<View style={styles.tableRow}> <View style={styles.tableRow}>
<Text style={[styles.tableCol01, styles.tableTh]}></Text> <Text style={[styles.tableCol01, styles.tableTh]}></Text>
<Text style={[styles.tableCol02, styles.tableTh , styles.marginL]}></Text> <Text style={[styles.tableCol02, styles.tableTh, styles.marginL]}></Text>
<Text style={[styles.tableCol03, styles.tableTh, styles.marginL]}></Text> <Text style={[styles.tableCol03, styles.tableTh, styles.marginL]}></Text>
<Text style={[styles.tableCol04 , styles.tableTh, styles.marginL]}></Text> <Text style={[styles.tableCol04, styles.tableTh, styles.marginL]}></Text>
</View> </View>
{/* Table Body */} {/* Table Body */}
<View> <View>
{JSON.parse(item.detail)?.map((subItem: SuitableDetail) => ( {JSON.parse(item.detail)?.map((subItem: SuitableDetail) => (
<View key={subItem.id} style={styles.tableRow}> <View key={subItem.id} style={styles.tableRow}>
<View style={[styles.tableCol01, styles.tableTd, styles.marginT]}><Text>{item.roofShCd}</Text></View> <View style={[styles.tableCol01, styles.tableTd, styles.marginT]}>
<View style={[styles.tableCol02, styles.tableTd, styles.marginL, styles.marginT]}><Text>{subItem.trestleMfpcCd}</Text></View> <Text>{item.roofShCd}</Text>
<View style={[styles.tableCol03, styles.tableTd, styles.marginL, styles.marginT]}><Text>{subItem.trestleManufacturerProductName}</Text></View> </View>
<View style={[styles.tableCol04, styles.tableTd, styles.marginL, styles.marginT]}><Text>{subItem.memo}</Text></View> <View style={[styles.tableCol02, styles.tableTd, styles.marginL, styles.marginT]}>
<Text>{subItem.trestleMfpcCd}</Text>
</View>
<View style={[styles.tableCol03, styles.tableTd, styles.marginL, styles.marginT]}>
<Text>{subItem.trestleManufacturerProductName}</Text>
</View>
<View style={[styles.tableCol04, styles.tableTd, styles.marginL, styles.marginT]}>
<Text>{subItem.memo}</Text>
</View>
</View> </View>
))} ))}
</View> </View>