Merge pull request 'fix: 지붕재적합성 pdf 생성시간 통일' (#81) from feature/suitable into dev
Reviewed-on: #81
This commit is contained in:
commit
443c3f7fb9
@ -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 버퍼
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user