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

판매등록 기능 구현 완료 #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Corperate_Project/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/admin/.m2/repository/com/oracle/database/jdbc/ojdbc8/21.7.0.0/ojdbc8-21.7.0.0.jar">
<classpathentry kind="lib" path="C:/Users/USER/.m2/repository/com/oracle/database/jdbc/ojdbc8/21.7.0.0/ojdbc8-21.7.0.0.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class LotRestController {

// 판매에서 로트 불러오기
@GetMapping(value="/getLot/{itemNo}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<LotVO>> getLot(@PathVariable("itemNo") int no) {
public ResponseEntity<List<String>> getLot(@PathVariable("itemNo") String no) {
System.out.println("?:" + no);
return new ResponseEntity<>(service.getLot(no), HttpStatus.OK);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ordersheet.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -14,12 +15,14 @@
import org.springframework.web.bind.annotation.RestController;

import com.spring.domain.ClientVO;
import com.spring.domain.ItemDTO;
import com.spring.domain.MemberVO;
import com.spring.domain.OrderSheetDetailVO;
import com.spring.domain.OrderSheetVO;
import com.spring.domain.PageDTO;
import com.spring.paging.Criteria;
import com.spring.service.ClientService;
import com.spring.service.LotRestService;
import com.spring.service.MemberService;
import com.spring.service.OrderSheetService;

Expand All @@ -37,6 +40,9 @@ public class OrderSheetRestController {
@Autowired
private MemberService ms;

@Autowired
private LotRestService ls;


//testURL : http://localhost:8080/ordersheet/orderdetail/11
@GetMapping(value={"/orderdetail/{mainNo}"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Expand Down Expand Up @@ -77,6 +83,8 @@ public ResponseEntity<Map<String, Object>> selectOrder(@PathVariable("no") int n

//수주 디테일 조회
List<OrderSheetDetailVO> list = service.getSubList(no);
List<String> lot_lists;
List<ItemDTO> itemDTOlist = new ArrayList<ItemDTO>();

for(OrderSheetDetailVO osdv : list) {
osdv.setNo(osdv.getNo());
Expand All @@ -89,6 +97,11 @@ public ResponseEntity<Map<String, Object>> selectOrder(@PathVariable("no") int n
ClientVO osdvCv = cs.selectOne(Integer.toString(osdv.getClient_no()));
osdv.setClient_name(osdvCv.getName());


lot_lists = ls.getLot(osdv.getItem_no());

itemDTOlist.add(new ItemDTO(osdv,lot_lists));

}

for(OrderSheetDetailVO osdv : list) {
Expand Down Expand Up @@ -124,6 +137,7 @@ public ResponseEntity<Map<String, Object>> selectOrder(@PathVariable("no") int n

map.put("detailList", list);
map.put("order", vo);
map.put("itemDTOlist", itemDTOlist);


return new ResponseEntity<>(map, HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.spring.domain.SellVO;
import com.spring.paging.Client_Paging;
import com.spring.service.ItemService;
import com.spring.service.OrderSheetService;
import com.spring.service.SellDetailService;
import com.spring.service.SellService;

Expand All @@ -40,6 +41,9 @@ public class SellController {
@Autowired(required = false)
private ItemService iservice;

//@Autowired(required = false)
//private OrderSheetService osservice;

@GetMapping(value="/list")
public void list(Model model) {

Expand All @@ -65,7 +69,7 @@ public String insertSold(Model model, SellVO sell, SellDetailVO selldetail) {
// System.out.println(memlists.get(i));
// }

System.out.println(sell.getOrder_no());

System.out.println(sell.getDay());
service.insert(sell);
System.out.println("selldetail 판매상세번호:"+selldetail.getNo());
Expand All @@ -75,7 +79,10 @@ public String insertSold(Model model, SellVO sell, SellDetailVO selldetail) {
System.out.println("selldetail 로트코드:"+selldetail.getLot_code());
System.out.println("selldetail 판매번호:"+selldetail.getSell_no());
sdservice.insert(selldetail);


// 판매 등록 시, 수주서 상태 변경
// osservice.updateStatusToSold(sell.getOrder_no());
return "redirect:/sell/origin/list";
}

Expand All @@ -93,7 +100,7 @@ public String deleteSold(Model model, @RequestParam(value="no") int no) {
@PostMapping(value="/update")
public String updateSold(Model model, SellVO sell) {

System.out.println(sell.getNo()+"/"+sell.getOrder_no()+"/"+sell.getMember_no()+"/"+sell.getDay());
System.out.println(sell.getNo()+"/"+sell.getMember_no()+"/"+sell.getDay());

service.update(sell);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.RestController;

import com.spring.domain.SellDetailVO;
import com.spring.domain.SellVO;
import com.spring.service.SellService;

@RestController
Expand All @@ -23,7 +24,8 @@ public class SellRestController {

//testURL : http://localhost:8080/ordersheet/orderdetail/11
@GetMapping(value={"/more/{mainNo}"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<SellDetailVO>> clientlist(@PathVariable("mainNo") int mainNo) {
public ResponseEntity<List<SellVO>> clientlist(@PathVariable("mainNo") int mainNo) {
System.out.println("mainNo : " + mainNo);
return new ResponseEntity<>(service.getSubList(mainNo), HttpStatus.OK);
}

Expand Down
20 changes: 20 additions & 0 deletions Corperate_Project/src/main/java/com/spring/domain/ItemDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.spring.domain;

import java.util.List;

import com.spring.paging.Paging;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ItemDTO {

private OrderSheetDetailVO orderSheetDetailVO;
private List<String> lotList;

}

// Generic이 적용된 클래스 정의방식.
// 이렇게 정의한 이유는 ClientVO의 list를 담거나 MemverVO의 list를 모두 담을 수 있는 재사용성 높은 코드를 작성하기 위함.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.spring.domain;

import java.util.ArrayList;

import lombok.Data;

@Data
public class SellDetailVO {

private int no;
private int item_no;
private int amount;
private int sell_price;
private String lot_code;
private ArrayList<Integer> item_no;
private ArrayList<Integer> amount;
private ArrayList<Integer> sell_price;
private ArrayList<String> lot_code;
private int sell_no;
private String item_name;
private int in_price;
private int out_price;
private String sell_day;
private int order_sheet_no;


private String code;
Expand Down
14 changes: 13 additions & 1 deletion Corperate_Project/src/main/java/com/spring/domain/SellVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ public class SellVO {

private int no;
private int member_no;
private int order_no;
private String day;

private String name;

private int item_no;
private int amount;
private int sell_price;
private String lot_code;
private int sell_no;
private String item_name;
private int in_price;
private int out_price;
private String sell_day;
private int order_sheet_no;


private String code;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

public interface LotRestMapper {

public List<LotVO> getLot(int no);
public List<String> getLot(String no);

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public int insertDetailSheet(

//수주상태 준비완료 > 발주중
public void updateStatus(int order_no);

//판매 완료시, 발주중 상태에서 판매 완료 상태로 변경
public void updateStatusToSold(int order_no);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.spring.domain.SearchVO;
import com.spring.domain.SellDetailVO;
import com.spring.paging.Client_Paging;

public interface SellDetailMapper {

void insert(SellDetailVO selldetail);

public List<SellDetailVO> read();

public List<SellDetailVO> selectAll(Client_Paging pageInfo);

public int getTotalCount(SearchVO searchvo);

void insert(@Param("itemNo")int itemNo,@Param("itemAmount") int itemAmount,@Param("itemPrice") int itemPrice,@Param("lot_code") String lot_code,@Param("order_sheet_no") int order_sheet_no);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public interface SellMapper {

public void update(SellVO sell);

public List<SellDetailVO> getSubList(int mainNo);
public List<SellVO> getSubList(int mainNo);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

public interface LotRestService {

public List<LotVO> getLot(int no);
public List<String> getLot(String no);



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ public class LotRestServiceImpl implements LotRestService{
private LotRestMapper mapper;

@Override
public List<LotVO> getLot(int no) {
public List<String> getLot(String no) {
System.out.println("리스트 사이즈 : " + mapper.getLot(no).size() + "/ 아이템 넘버 :"+ no );
List<String> lists = mapper.getLot(no);

for(int i = 0 ; i < lists.size();i++) {
System.out.println(lists.get(i));
}
return mapper.getLot(no);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public interface OrderSheetService {

//발주할때 수주참조하면 수주상태 준비완료>발주중
public void updateStatus(int order_no);
public void updateStatusToSold(int order_no);
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,10 @@ public void updateStatus(int order_no) {
mapper.updateStatus(order_no);

}

@Override
public void updateStatusToSold(int order_no) {
mapper.updateStatusToSold(order_no);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ public class SellDetailServiceImpl implements SellDetailService{
@Override
public void insert(SellDetailVO selldetail) {

mapper.insert(selldetail); // 존재하지 않는 레코드를 얻으려고하면 null이 반환됨
}

int len = selldetail.getItem_no().size();

for (int i = 0; i < len; i++) {
int itemNo = selldetail.getItem_no().get(i);
int itemAmount = selldetail.getAmount().get(i);
int itemPrice = selldetail.getSell_price().get(i);
String lot_code = selldetail.getLot_code().get(i);
mapper.insert(itemNo,itemAmount,itemPrice,lot_code,selldetail.getOrder_sheet_no());
}
}


@Override
public List<SellDetailVO> read() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface SellService {

public void update(SellVO sell);

public List<SellDetailVO> getSubList(int mainNo);
public List<SellVO> getSubList(int mainNo);


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class SellServiceImpl implements SellService{
public void insert(SellVO sell) {

System.out.println("SellServiceImpl member_no :"+sell.getMember_no());
System.out.println("SellServiceImpl order_no :"+sell.getOrder_no());
System.out.println("SellServiceImpl day :"+sell.getDay());

mapper.insert(sell); // 존재하지 않는 레코드를 얻으려고하면 null이 반환됨
Expand All @@ -45,8 +44,8 @@ public void update(SellVO sell) {
}

@Override
public List<SellDetailVO> getSubList(int mainNo) {
System.out.println("판매 리스트 불러오기");
public List<SellVO> getSubList(int mainNo) {
System.out.println("판매 리스트 불러오기13");
return mapper.getSubList(mainNo); // 존재하지 않는 레코드를 얻으려고하면 null이 반환됨
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.spring.mapper.LotRestMapper">
<select id="getLot" resultType="com.spring.domain.LotVO">
select * from lot where item_no = #{no} order by code asc

<select id="getLot" resultType="String">
select code from lot where item_no = #{no} order by code asc
</select>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@
where no = #{order_no}
and status = 0
</update>

<!-- 수주상태 준비완료,발주중 > 판매완료 -->
<update id="updateStatusToSold">
update ORDER_SHEET
set status = 2
where no = #{order_no}
</update>


</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<mapper namespace="com.spring.mapper.SellDetailMapper">

<insert id="insert">
insert into sell_detail values(sell_detail_seq.nextval,#{item_no},#{amount},#{sell_price},#{lot_code},sell_seq.currval)
insert into sell_detail values(sell_detail_seq.nextval,#{itemNo},#{itemAmount},#{itemPrice},#{lot_code},sell_seq.currval,#{order_sheet_no})
</insert>

<select id="read" resultType="com.spring.domain.SellDetailVO">
Expand Down
Loading