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개씩 청크로 나누기 */
const CHUNK_SIZE = 100
const pdfBuffers: Uint8Array[] = []
const createTime = formatDateString()
for (let i = 0; i < suitable.length; i += CHUNK_SIZE) {
const chunk = suitable.slice(i, i + CHUNK_SIZE)
const content = React.createElement(
Document,
null,
React.createElement(SuitablePdf, {
createTime,
data: chunk,
fileTitle: fileTitle,
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
* @param buffers PDF

View File

@ -47,7 +47,7 @@ const styles = StyleSheet.create({
display: 'flex',
flexWrap: 'wrap',
flexDirection: 'row',
gap: 20
gap: 20,
},
tableCard: {
width: '48.7%',
@ -66,11 +66,11 @@ const styles = StyleSheet.create({
},
tableTit01: {
paddingRight: 6,
borderRight: '1px solid #101010'
borderRight: '1px solid #101010',
},
tableTit02: {
padding: '0 6',
borderRight: '1px solid #101010'
borderRight: '1px solid #101010',
},
tableTit03: {
paddingLeft: 6,
@ -100,7 +100,7 @@ const styles = StyleSheet.create({
color: '#fff',
backgroundColor: '#18B490',
border: '1px solid #18B490',
textAlign: 'center'
textAlign: 'center',
},
tableTd: {
display: 'flex',
@ -134,20 +134,17 @@ const styles = StyleSheet.create({
},
})
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')}`
}
export default function SuitablePdf({ data, fileTitle, firstPage }: { data: Suitable[]; fileTitle: string; firstPage: boolean }) {
const createTime = formatDateString()
export default function SuitablePdf({
createTime,
data,
fileTitle,
firstPage,
}: {
createTime: string
data: Suitable[]
fileTitle: string
firstPage: boolean
}) {
return (
<Page size="A4" orientation="landscape" style={styles.page}>
{/* Intro Section */}
@ -194,10 +191,18 @@ export default function SuitablePdf({ data, fileTitle, firstPage }: { data: Suit
<View>
{JSON.parse(item.detail)?.map((subItem: SuitableDetail) => (
<View key={subItem.id} style={styles.tableRow}>
<View style={[styles.tableCol01, styles.tableTd, styles.marginT]}><Text>{item.roofShCd}</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 style={[styles.tableCol01, styles.tableTd, styles.marginT]}>
<Text>{item.roofShCd}</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>