Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 구매서 조회 및 상세조회 페이지 구현 #238

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package error.pirate.backend.common;

import io.micrometer.common.util.StringUtils;
import lombok.Data;
import lombok.RequiredArgsConstructor;

Expand All @@ -25,6 +26,13 @@ public class Pagination {

private int totalPageNo;

public String getSearchEndDate() {
if(StringUtils.isNotEmpty(searchEndDate)) {
return searchEndDate + " 23:59:59";
}
return null;
}

public int getOffset() {
return (pageNo - 1) * limit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class PurchaseItemResponse {

private Long itemSeq; // 품목 번호

private String warehouseName; // 입고창고명

private String itemName; // 품목 이름

private String itemImageUrl; // 품목 사진 url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class PurchaseRequest extends Pagination {

private String clientName; // 거래처명
private String clientName;

private PurchaseStatus purchaseStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ public class PurchaseResponse {

private String clientName; // 거래처 이름

private String warehouseName; // 입고창고명

private String purchaseName; // 구매처명

private PurchaseStatus purchaseStatus; // 상태

@Setter
private String purchaseStatusValue;

private LocalDateTime purchaseContractDate; // 계약일

private LocalDateTime purchaseRegDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public PurchaseResponsePagination readPurchaseList(PurchaseRequest request) {

int totalCount = purchaseMapper.readPurchaseListCount(request);

purchaseResponseList.forEach(order -> order.setPurchaseStatusValue(order.getPurchaseStatus().getValue()));

Pagination pagination = new Pagination();
pagination.responsePaging(request.getPageNo(), totalCount);

Expand All @@ -48,7 +50,7 @@ public byte[] purchaseExcelDown(PurchaseRequest request) {
request.setOffset(null);
List<PurchaseResponse> purchaseResponseList = purchaseMapper.readPurchaseList(request);

String[] headers = {"구매서명", "구매서 품목", "거래처명", "입고 창고명", "계약일", "상태"};
String[] headers = {"구매서명", "구매서 품목", "거래처명", "계약일", "상태"};
String[][] excel = new String[purchaseResponseList.size()][headers.length];

for(int i=0 ; i<purchaseResponseList.size() ; i++) {
Expand All @@ -61,11 +63,10 @@ public byte[] purchaseExcelDown(PurchaseRequest request) {
.map(PurchaseItemResponse::getItemName)
.collect(Collectors.joining(", "));// 품목
excel[i][2] = dto.getClientName();
excel[i][3] = dto.getWarehouseName();
excel[i][4] = dto.getPurchaseContractDate() != null
excel[i][3] = dto.getPurchaseContractDate() != null
? dto.getPurchaseContractDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
: null;
excel[i][5] = String.valueOf(dto.getPurchaseStatus());
excel[i][4] = String.valueOf(dto.getPurchaseStatus());
}

return excelDownBody.excelDownBody(excel, headers, "구매서");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class PurchaseOrderResponse {

private PurchaseOrderStatus purchaseOrderStatus; // 발주서 상태

@Setter
private String purchaseOrderStatusValue;

private LocalDateTime purchaseOrderDueDate; // 발주서 계약 납기일

private LocalDateTime purchaseOrderTargetDueDate; // 발주서 목표 납기일
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public PurchaseOrderResponsePagination readPurchaseOrderList(PurchaseOrderReques

int totalCount = purchaseOrderMapper.readPurchaseOrderListCount(purchaseOrderRequest);

purchaseOrderResponseList.forEach(order -> order.setPurchaseOrderStatusValue(order.getPurchaseOrderStatus().getValue()));

Pagination pagination = new Pagination();
pagination.responsePaging(purchaseOrderRequest.getPageNo(), totalCount);

Expand Down
39 changes: 20 additions & 19 deletions SCM/backend/src/main/resources/mappers/purchase/PurchaseMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@
tp.purchase_extended_price,
tp.purchase_note,
tu.user_name,
tc.client_name,
tw.warehouse_name
tc.client_name
FROM tb_purchase tp
JOIN tb_user tu USING (user_seq)
JOIN tb_warehouse tw USING (warehouse_seq)
JOIN tb_client tc ON (tu.user_seq = tc.user_seq)
JOIN tb_purchase_order tpo USING (purchase_order_seq)
JOIN tb_client tc ON (tpo.client_seq = tc.client_seq)
<trim prefix="WHERE" prefixOverrides="AND">
<if test="searchStartDate != null and searchStartDate != ''">
<![CDATA[
AND #{searchStartDate} <= tpo.purchase_order_target_due_date
AND #{searchStartDate} <= tp.purchase_contract_date
]]>
</if>
<if test="searchEndDate != null and searchEndDate != ''">
<![CDATA[
AND #{searchEndDate} >= tpo.purchase_order_target_due_date
AND #{searchEndDate} >= tp.purchase_contract_date
]]>
</if>
<if test="clientName != null">
AND tc.client_name LIKE CONCAT('%', #{clientName}, '%')
<if test="searchName != null">
AND tc.client_name LIKE CONCAT('%', #{searchName}, '%')
</if>
<if test="purchaseStatus != null">
AND tp.purchase_status = #{purchaseStatus}
<if test="searchStatus != null">
AND tp.purchase_status = #{searchStatus}
</if>
</trim>
ORDER BY tp.purchase_seq
Expand All @@ -52,9 +51,11 @@
tpi.purchase_item_status,
tpi.purchase_item_note,
ti.item_name,
ti.item_image_url
ti.item_image_url,
tw.warehouse_name
FROM tb_purchase_item tpi
JOIN tb_item ti USING (item_seq)
JOIN tb_warehouse tw ON (ti.warehouse_seq = tw.warehouse_seq)
WHERE tpi.purchase_seq = #{purchaseSeq}
ORDER BY tpi.purchase_item_seq
</select>
Expand All @@ -64,24 +65,24 @@
COUNT(*)
FROM tb_purchase tp
JOIN tb_user tu USING (user_seq)
JOIN tb_warehouse tw USING (warehouse_seq)
JOIN tb_client tc ON (tu.user_seq = tc.user_seq)
JOIN tb_purchase_order tpo USING (purchase_order_seq)
JOIN tb_client tc ON (tpo.client_seq = tc.client_seq)
<trim prefix="WHERE" prefixOverrides="AND">
<if test="searchStartDate != null and searchStartDate != ''">
<![CDATA[
AND #{searchStartDate} <= tpo.purchase_order_target_due_date
AND #{searchStartDate} <= tp.purchase_contract_date
]]>
</if>
<if test="searchEndDate != null and searchEndDate != ''">
<![CDATA[
AND #{searchEndDate} >= tpo.purchase_order_target_due_date
AND #{searchEndDate} >= tp.purchase_contract_date
]]>
</if>
<if test="clientName != null">
AND tc.client_name LIKE CONCAT('%', #{clientName}, '%')
<if test="searchName != null">
AND tc.client_name LIKE CONCAT('%', #{searchName}, '%')
</if>
<if test="purchaseStatus != null">
AND tp.purchase_status = #{purchaseStatus}
<if test="searchStatus != null">
AND tp.purchase_status = #{searchStatus}
</if>
</trim>
</select>
Expand Down
2 changes: 1 addition & 1 deletion SCM/frontend/src/components/common/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import statisticsIcon from '@/assets/statisticsIcon.svg'
<b-nav-item-dropdown>
<template #button-content><orderIcon class="icon" />주문관리</template>
<b-dropdown-item href="#"><RouterLink to="/purchaseOrder" active-class="active none-decoration" replace>발주서 관리</RouterLink></b-dropdown-item>
<b-dropdown-item href="#">구매서 관리</b-dropdown-item>
<b-dropdown-item href="#"><RouterLink to="/purchase" active-class="active none-decoration" replace>구매서 관리</RouterLink></b-dropdown-item>
</b-nav-item-dropdown>
<b-nav-item-dropdown>
<template #button-content><productionIcon class="icon" />생산관리</template>
Expand Down
Loading