mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 12:13:24 +09:00
#수정
stock.list.jsp StockMapper.xml #추가 stock.create.jsp WarehouseController.java WarehouseDto.java WarehouseMapper.java WarehouseMapper.xml WarehouseService.java
This commit is contained in:
101
src/main/java/com/no1/wms/warehouse/WarehouseController.java
Normal file
101
src/main/java/com/no1/wms/warehouse/WarehouseController.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
public class WarehouseController {
|
||||
|
||||
@Autowired
|
||||
WarehouseService service;
|
||||
|
||||
// 재고 리스트 출력
|
||||
@GetMapping("warehouse/list")
|
||||
public String list(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
@RequestParam(name = "p", defaultValue = "1") int page, Model m) {
|
||||
int count = service.count(searchn, search);
|
||||
|
||||
int perPage = 10; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
//스톡서비스로 재고 리스트 출력 메서트 작성
|
||||
List<Object> dto = service.list(searchn, search, perPage);
|
||||
m.addAttribute("list", dto);
|
||||
|
||||
int pageNum = 4;//보여질 페이지 번호 수
|
||||
int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수
|
||||
|
||||
int begin = (page - 1) / pageNum * pageNum + 1;
|
||||
int end = begin + pageNum - 1;
|
||||
if (end > totalPages) {
|
||||
end = totalPages;
|
||||
}
|
||||
m.addAttribute("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
m.addAttribute("totalPages", totalPages);
|
||||
|
||||
return "warehouse/list";
|
||||
}
|
||||
|
||||
|
||||
// 재고 상세페이지
|
||||
@PostMapping("warehouse/read/{id}")
|
||||
public String read(@PathVariable String id, Model m) {
|
||||
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
||||
WarehouseDto dto = service.warehouseOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "warehouse/read/";
|
||||
}
|
||||
|
||||
|
||||
// 수정 - 폼
|
||||
@GetMapping("/warehouse/update/{id}")
|
||||
public String update(@PathVariable String id, Model m) {
|
||||
WarehouseDto dto = service.warehouseOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "warehouse/update";
|
||||
}
|
||||
|
||||
|
||||
// 수정 프로세스
|
||||
@PutMapping("/warehouse/update_process")
|
||||
@ResponseBody
|
||||
public String updateProcess(WarehouseDto dto) {
|
||||
service.updateWarehouse(dto);
|
||||
return "redirect:list";
|
||||
}
|
||||
|
||||
|
||||
// 생성 폼
|
||||
@GetMapping("/warehouse/create")
|
||||
public String create()
|
||||
{
|
||||
return "stock/create";
|
||||
}
|
||||
|
||||
|
||||
// 생성 프로세스
|
||||
@PostMapping("/warehouse/create_process")
|
||||
@ResponseBody
|
||||
public String createProcess(WarehouseDto dto) {
|
||||
service.createWarehouse(dto);
|
||||
return "redirect:list";// 글목록
|
||||
}
|
||||
|
||||
|
||||
// 삭제
|
||||
@DeleteMapping("/warehouse/delete")
|
||||
@ResponseBody
|
||||
public int delete(String id) {
|
||||
int i = service.deleteWarehouse(id);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/no1/wms/warehouse/WarehouseDto.java
Normal file
15
src/main/java/com/no1/wms/warehouse/WarehouseDto.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseDto {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private int capacity;
|
||||
private int current_capacity;
|
||||
private String manager_id;
|
||||
private String address;
|
||||
private boolean activation;
|
||||
}
|
||||
26
src/main/java/com/no1/wms/warehouse/WarehouseMapper.java
Normal file
26
src/main/java/com/no1/wms/warehouse/WarehouseMapper.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface WarehouseMapper {
|
||||
|
||||
int count(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
List<Object> list(Map<String, Object> m);
|
||||
|
||||
int updateWarehouse(WarehouseDto dto);
|
||||
|
||||
int createWarehouse(WarehouseDto dto);
|
||||
|
||||
WarehouseDto warehouseOne(String id);
|
||||
|
||||
int deleteWarehouse(String id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
61
src/main/java/com/no1/wms/warehouse/WarehouseService.java
Normal file
61
src/main/java/com/no1/wms/warehouse/WarehouseService.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class WarehouseService {
|
||||
@Autowired
|
||||
WarehouseMapper mapper;
|
||||
|
||||
public int count(int searchn, String search) {
|
||||
|
||||
System.out.println(searchn+search);
|
||||
|
||||
Map<String,Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", 0);
|
||||
m.put("perPage", 10000);
|
||||
return mapper.count(m);
|
||||
}
|
||||
|
||||
|
||||
public List<Object> list(int searchn, String search, int start){
|
||||
|
||||
System.out.println(searchn+search);
|
||||
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", start);
|
||||
m.put("perPage", 10);
|
||||
|
||||
return mapper.list(m);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public WarehouseDto warehouseOne(String id) {
|
||||
return mapper.warehouseOne(id);
|
||||
}
|
||||
|
||||
|
||||
public int createWarehouse(WarehouseDto dto) {
|
||||
return mapper.createWarehouse(dto);
|
||||
}
|
||||
|
||||
|
||||
public int updateWarehouse(WarehouseDto dto) {
|
||||
return mapper.updateWarehouse(dto);
|
||||
}
|
||||
|
||||
|
||||
public int deleteWarehouse(String id) {
|
||||
return mapper.deleteWarehouse(id);
|
||||
}
|
||||
}
|
||||
@@ -9,23 +9,23 @@
|
||||
select count(*) from stock left join warehouse on stock.warehouse_id = warehouse.id left join product on stock.product_id = product.id left join product_category on product.kan_code = product_category.kan_code
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> stock.activation = 1 and warehouse.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> stock.activation = 1 and product.name like concat('%',#{search},'%') </when>
|
||||
<when test="searchn == 0"> stock.activation = 1 and product.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> stock.activation = 1 and product_category.cls_Nm_4 like concat('%',#{search},'%') </when>
|
||||
</choose>
|
||||
</where>
|
||||
order by stock.id desc limit #{start}, #{perPage}
|
||||
</select>
|
||||
|
||||
<select id="list" parameterType="map" resultType="com.no1.wms.stock.StockDto">
|
||||
select * from stock left join warehouse on stock.warehouse_id = warehouse.id left join product on stock.product_id = product.id left join product_category on product.kan_code = product_category.kan_code
|
||||
<where>
|
||||
<select id="count" parameterType="map" resultType="java.lang.Integer">
|
||||
select * from stock left join warehouse on stock.warehouse_id = warehouse.id left join product on stock.product_id = product.id left join product_category on product.kan_code = product_category.kan_code
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> stock.activation = 1 and warehouse.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> stock.activation = 1 and product.name like concat('%',#{search},'%') </when>
|
||||
<when test="searchn == 0"> stock.activation = 1 and product.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> stock.activation = 1 and product_category.cls_Nm_4 like concat('%',#{search},'%') </when>
|
||||
</choose>
|
||||
</where>
|
||||
order by stock.id desc limit #{start}, #{perPage}
|
||||
</select>
|
||||
order by stock.id desc limit #{start}, #{perPage}
|
||||
</select>
|
||||
|
||||
<select id="stockOne" parameterType="String" resultType="com.no1.wms.stock.StockDto">
|
||||
selct * from stock where id = #{id}
|
||||
|
||||
59
src/main/resources/mappers/WarehouseMapper.xml
Normal file
59
src/main/resources/mappers/WarehouseMapper.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.no1.wms.warehouse.WarehouseMapper">
|
||||
|
||||
<!-- select -->
|
||||
<select id="count" parameterType="map" resultType="java.lang.Integer">
|
||||
select count(*) from warehouse left join account on warehouse.manager_id = account.id
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> warehouse.activation = 1 and warehouse.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> warehouse.activation = 1 and warehouse.capacity like concat('%',#{search},'%') </when>
|
||||
<when test="searchn == 3"> warehouse.activation = 1 and warehouse.current_capacity like concat('%',#{search},'%')</when>
|
||||
</choose>
|
||||
</where>
|
||||
order by stock.id desc limit #{start}, #{perPage}
|
||||
</select>
|
||||
|
||||
<select id="list" parameterType="map" resultType="com.no1.wms.warehouse.WarehouseDto">
|
||||
select * from warehouse left join account on warehouse.manager_id = account.id
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> warehouse.activation = 1 and warehouse.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> warehouse.activation = 1 and warehouse.capacity like concat('%',#{search},'%') </when>
|
||||
<when test="searchn == 3"> warehouse.activation = 1 and warehouse.current_capacity like concat('%',#{search},'%')</when>
|
||||
</choose>
|
||||
</where>
|
||||
order by stock.id desc limit #{start}, #{perPage}
|
||||
</select>
|
||||
|
||||
<select id="warehouseOne" parameterType="String" resultType="com.no1.wms.warehouse.WarehouseDto">
|
||||
selct * from warehouse where id = #{id}
|
||||
</select>
|
||||
<!-- select -->
|
||||
|
||||
|
||||
<!-- update -->
|
||||
<update id="updateWarehouse" parameterType="com.no1.wms.warehouse.WarehouseDto">
|
||||
update warehouse
|
||||
set capacity = #{dto.capacity}, name = #{dto.name}
|
||||
where id = #{dto.id}
|
||||
</update>
|
||||
<!-- update -->
|
||||
|
||||
|
||||
<!-- insert -->
|
||||
<insert id="createWarehouse" parameterType="com.no1.wms.warehouse.WarehouseDto">
|
||||
insert into warehouse (id, warehouse_id, product_id, quantity, activation)
|
||||
values ((UUID), #{dto.warehouse_id}, #{dto.product_id}, #{dto.quantity}, 1)
|
||||
</insert>
|
||||
<!-- insert -->
|
||||
|
||||
<!-- delete -->
|
||||
<delete id="deleteWarehouse" parameterType="String">
|
||||
delete from warehouse where no = #{id}
|
||||
</delete>
|
||||
<!-- delete -->
|
||||
</mapper>
|
||||
60
src/main/webapp/WEB-INF/views/stock/create.jsp
Normal file
60
src/main/webapp/WEB-INF/views/stock/create.jsp
Normal file
@@ -0,0 +1,60 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>재고 생성</title>
|
||||
<style type="text/css">
|
||||
.header {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container" >
|
||||
<div class="header">
|
||||
<h1>재고 관리 생성</h1>
|
||||
</div>
|
||||
<hr>
|
||||
<div class = "row">
|
||||
<div class = "col-6">
|
||||
<form>
|
||||
<input type="text" name="search" maxlength="50" readonly/>
|
||||
<input type="submit" class="btn btn-primary" id = "search_modal_show_button" value="검색" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="search_modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" >
|
||||
<div class="modal-content align: center" id="search_modal_content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5 col-" id="searchModalLabel">재고명 검색</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
<script src="../../utils.js" type="text/javascript"></script>
|
||||
<script>
|
||||
//검색 팝업 모달 관련
|
||||
const searchModalBootStrap = new bootstrap.Modal("#search_modal");
|
||||
$("#search_modal_show_button").on("click", function(){
|
||||
searchModalBootStrap.show();
|
||||
});
|
||||
|
||||
/*
|
||||
* 검색 팝업 모달 닫는 함수
|
||||
*/
|
||||
function hideSearchModal(){
|
||||
searchModalBootStrap.hide();
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -13,30 +14,92 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="header">
|
||||
<h1>재고 리스트</h1>
|
||||
</div>
|
||||
<hr>
|
||||
<<script src="../../utils.js" type="text/javascript"></script>
|
||||
<script>
|
||||
/*
|
||||
yes no 모달의 확인 버튼을 누를때 재정의할 function
|
||||
|
||||
yesNoModal.yesFunction = myYesFunction;
|
||||
function myYesFunction(){
|
||||
alert("재정의 됨");
|
||||
}
|
||||
*/
|
||||
$(function(){
|
||||
$('.tabcontent > div').hide();
|
||||
$('.tabnav a').click(function () {
|
||||
$('.tabcontent > div').hide().filter(this.hash).fadeIn();
|
||||
$('.tabnav a').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
return false;
|
||||
}).filter(':eq(0)').click();
|
||||
});
|
||||
<div class="body">
|
||||
<!--탭키명 -->
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">
|
||||
재고
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">
|
||||
부족한 재고
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
|
||||
<div id="search" align="center">
|
||||
<form action="search">
|
||||
<select name="searchn">
|
||||
<option value="0">제품명</option>
|
||||
<option value="1">카테고리</option>
|
||||
</select>
|
||||
<input type="text" name="search" maxlength="50"/>
|
||||
<input type="submit" class="btn btn-primary" value="검색" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!--재고 리스트 -->
|
||||
<c:if test="${count != 0 }">
|
||||
<table align="center">
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<th>제품명</th>
|
||||
<th>창고명</th>
|
||||
</tr>
|
||||
<c:forEach items="${list}" var="stock">
|
||||
<tr>
|
||||
<td><a href ="read/${stock.id}">${stock.id}</a></td>
|
||||
<td>${stock.product_name }</td>
|
||||
<td>${stock.warehouse_name }</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
|
||||
<!-- 엑셀 다운로드-->
|
||||
<div class="excelButton" align="left">
|
||||
<button id="excelButton" value="excelButton">다운로드</button>
|
||||
</div>
|
||||
<div id="page" align="center">
|
||||
<c:if test="${begin > pageNum }">
|
||||
<a href="list?p=${begin-1 }">[<]</a>
|
||||
</c:if>
|
||||
<c:forEach begin="${begin }" end="${end}" var="i">
|
||||
<a href="list?p=${i}">${i}</a>
|
||||
</c:forEach>
|
||||
<c:if test="${end < totalPages }">
|
||||
<a href="list?p=${end+1}">[>]</a>
|
||||
</c:if>
|
||||
</div>
|
||||
|
||||
<div class="createButton" align="right">
|
||||
<button id="createButton" href="create">생성</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
|
||||
탭2 내용
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
<script src="../../utils.js" type="text/javascript"></script>
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
/*엑셀 다운로드 클릭 펑션 */
|
||||
@@ -55,73 +118,4 @@
|
||||
|
||||
|
||||
</script>
|
||||
여기다가 화면 만들기
|
||||
<!--탭키명 -->
|
||||
<div class="tab">
|
||||
<ul class="tabnav">
|
||||
<li><a href="#tab01">재고</a></li>
|
||||
<li><a href="#tab02">부족한재고</a></li>
|
||||
</ul>
|
||||
|
||||
<!--탭키 내용-->
|
||||
<div class="tabcontent">
|
||||
|
||||
<!--재고 탭 내용-->
|
||||
<div id="tab01">
|
||||
<div id="search" align="center">
|
||||
<form action="search">
|
||||
<select name="searchn">
|
||||
<option value="0">창고명</option>
|
||||
<option value="1">제품명</option>
|
||||
</select>
|
||||
<input type="text" name="search" maxlength="50"/>
|
||||
<input type="submit" class="btn btn-primary" value="검색" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!--재고 리스트 -->
|
||||
<c:if test="${count != 0 }">
|
||||
<table align="center">
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<th>제품명</th>
|
||||
<th>창고명</th>
|
||||
</tr>
|
||||
<c:forEach items="${list}" var="stock">
|
||||
<tr>
|
||||
<td><a href ="read/${stock.id}">${stock.id}</a></td>
|
||||
<td>${stock.product_name }</td>
|
||||
<td>${stock.warehouse_name }</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
|
||||
<!-- 엑셀 다운로드-->
|
||||
<div class="excelButton">
|
||||
<button id="excelButton" value="생성">생성</button>
|
||||
</div>
|
||||
<div id="page">
|
||||
<c:if test="${begin > pageNum }">
|
||||
<a href="list?p=${begin-1 }">[<]</a>
|
||||
</c:if>
|
||||
<c:forEach begin="${begin }" end="${end}" var="i">
|
||||
<a href="list?p=${i}">${i}</a>
|
||||
</c:forEach>
|
||||
<c:if test="${end < totalPages }">
|
||||
<a href="list?p=${end+1}">[>]</a>
|
||||
</c:if>
|
||||
</div>
|
||||
|
||||
</c:if>
|
||||
|
||||
</div>
|
||||
|
||||
<!--부족한재고 탭 내용-->
|
||||
<div id="tab02">
|
||||
tab2 content
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user