mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 04:03:45 +09:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,23 +1,32 @@
|
||||
package com.no1.wms.category;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.no1.wms.excel.ExcelUtils;
|
||||
import com.no1.wms.excel.ExcelRequestManager;
|
||||
import com.no1.wms.excel.ExcelDownlodeUtils;
|
||||
|
||||
|
||||
|
||||
@@ -28,16 +37,15 @@ public class CategoryController {
|
||||
CategoryService categoryService;
|
||||
|
||||
@Autowired
|
||||
ExcelUtils excelUtils;
|
||||
ExcelDownlodeUtils excelDownlodeUtils;
|
||||
|
||||
//테스트
|
||||
@GetMapping("/category/test")
|
||||
public String testPage(Model m) {
|
||||
List<CategoryDto> dto = categoryService.selectAllCategory();
|
||||
m.addAttribute("dto", dto);
|
||||
public String testPage(Model m, HttpServletRequest request) {
|
||||
|
||||
|
||||
return "category/test";
|
||||
}
|
||||
};
|
||||
|
||||
// 카테고리 리스트 출력
|
||||
@GetMapping("/category/list")
|
||||
@@ -77,7 +85,7 @@ public class CategoryController {
|
||||
//List<CategoryDto> dto = categoryService.categoryList(page);
|
||||
//m.addAttribute("list", dto);
|
||||
return "category/list";
|
||||
}
|
||||
};
|
||||
|
||||
// 상세페이지
|
||||
@PostMapping("/category/read")
|
||||
@@ -86,13 +94,13 @@ public class CategoryController {
|
||||
CategoryDto dto = categoryService.selectByKanCode(kan_code);
|
||||
m.addAttribute("dto", dto);
|
||||
return "category/read";
|
||||
}
|
||||
};
|
||||
|
||||
// 생성 - 폼
|
||||
@PostMapping("/category/create")
|
||||
public String create() {
|
||||
return "category/create";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 생성 - Ajax
|
||||
@@ -105,7 +113,7 @@ public class CategoryController {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 수정 - 폼
|
||||
@PostMapping("/category/update")
|
||||
@@ -113,7 +121,7 @@ public class CategoryController {
|
||||
CategoryDto dto = categoryService.selectByKanCode(kan_code);
|
||||
m.addAttribute("dto", dto);
|
||||
return "category/update";
|
||||
}
|
||||
};
|
||||
// 수정 - Ajax
|
||||
|
||||
@PutMapping("/category/update_process")
|
||||
@@ -126,7 +134,7 @@ public class CategoryController {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 삭제
|
||||
@DeleteMapping("/category/delete")
|
||||
@@ -138,18 +146,18 @@ public class CategoryController {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 엑셀다운로드테스트
|
||||
@GetMapping("/category/download")
|
||||
public void downloadExcel(HttpServletResponse response) {
|
||||
@GetMapping("/category/downloadTest")
|
||||
public void downloadExcelTest(HttpServletResponse response) {
|
||||
List<CategoryDto> dto = categoryService.selectAllCategory();
|
||||
String excelFileName = "카테고리 테스트 파일";
|
||||
String sheetName = "카테고리";
|
||||
String[] columnName = {"KAN_CODE","대분류","중분류","소분류","세분류"};
|
||||
excelUtils.downloadCategoryExcelFile(excelFileName, response, sheetName, columnName, dto);
|
||||
excelDownlodeUtils.downloadCategoryExcelFile(excelFileName, response, sheetName, columnName, dto);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// KAN코드 중복확인 메서드
|
||||
@PostMapping("/category/checkKancode")
|
||||
@@ -157,7 +165,7 @@ public class CategoryController {
|
||||
public String chackKancode(String kan_code) {
|
||||
String checkkan = categoryService.kanCheck(kan_code);
|
||||
return checkkan;
|
||||
}
|
||||
};
|
||||
|
||||
//카테고리 검색 모달
|
||||
@GetMapping("/category/categorysearch")
|
||||
@@ -192,9 +200,69 @@ public class CategoryController {
|
||||
m.addAttribute("p" , page);
|
||||
|
||||
return "modal/categorysearch";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//서식 다운로드
|
||||
@GetMapping("/category/downlodeCategoryForm")
|
||||
public void downlodeCategoryForm (HttpServletResponse response) throws IOException{
|
||||
String categoryFormName = "카테고리 데이터 입력 서식.xlsx";
|
||||
excelDownlodeUtils.downlodeExcelForm(response, categoryFormName);
|
||||
};
|
||||
|
||||
|
||||
@PostMapping("/category/uplodeExcel")
|
||||
public String uploadExcel(@ModelAttribute("dto") CategoryDto dto , RedirectAttributes redirectAttributes,final MultipartHttpServletRequest multiRequest,
|
||||
HttpServletRequest request,ModelMap model) {
|
||||
|
||||
Map<String, Object> resMap = new HashMap<>();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
ExcelRequestManager em = new ExcelRequestManager();
|
||||
|
||||
// 멀티파트 요청 객체에서 파일 맵을 가져옴
|
||||
final Map<String, MultipartFile> files = multiRequest.getFileMap();
|
||||
//초기화
|
||||
List<HashMap<String,String>> apply =null;
|
||||
|
||||
//엑셀파일 가져와서 저장 및 읽기
|
||||
//변수는 멀티파트 요청 객체의 파일맵, 저장할 엑셀파일명 이름에 추가할 숫자(그냥 0으로 해도 됨)
|
||||
//마찬가지로 엑셀파일 명 이름에 추가할 문자열, uplode폴더에 들어갈 폴더명(카테고리같은 파트 이름으로 해주세요)
|
||||
//폴더가 없으면 자동생성되게 해뒀습니다.
|
||||
//마지막으로 HttpServletRequest
|
||||
apply = em.parseExcelSpringMultiPart(files, "테스트파일", 0, "", "category", request);
|
||||
|
||||
for (int i = 0; i < apply.size(); i++) {
|
||||
|
||||
dto.setKan_code(apply.get(i).get("cell_0"));
|
||||
dto.setCls_nm_1(apply.get(i).get("cell_1"));
|
||||
dto.setCls_nm_2(apply.get(i).get("cell_2"));
|
||||
dto.setCls_nm_3(apply.get(i).get("cell_3"));
|
||||
dto.setCls_nm_4(apply.get(i).get("cell_4"));
|
||||
dto.setActivation(true);
|
||||
|
||||
categoryService.createProcess(dto);
|
||||
|
||||
}
|
||||
|
||||
resMap.put("res", "ok");
|
||||
resMap.put("msg", "업로드 성공");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
resMap.put("res", "error");
|
||||
resMap.put("msg", "업로드 실패");
|
||||
}
|
||||
|
||||
redirectAttributes.addFlashAttribute("resMap", resMap);
|
||||
|
||||
return "redirect:/category/list";
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.no1.wms.category;
|
||||
import org.apache.ibatis.type.Alias;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -16,5 +17,6 @@ public class CategoryDto {
|
||||
private String cls_nm_2;
|
||||
private String cls_nm_3;
|
||||
private String cls_nm_4;
|
||||
private boolean activation;
|
||||
@Builder.Default
|
||||
private Boolean activation = true;
|
||||
}
|
||||
|
||||
17
src/main/java/com/no1/wms/excel/EgovWebUtil.java
Normal file
17
src/main/java/com/no1/wms/excel/EgovWebUtil.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.no1.wms.excel;
|
||||
|
||||
//../을 통해 부모디렉토리로 이동하는 방법을 막기 위한 보안
|
||||
public class EgovWebUtil {
|
||||
public static String filePathBlackList(String value) {
|
||||
String returnValue = value;
|
||||
if (returnValue == null || returnValue.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
|
||||
returnValue = returnValue.replaceAll("\\.\\./", "");
|
||||
returnValue = returnValue.replaceAll("\\.\\.\\\\", "");
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.no1.wms.excel;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
@@ -19,8 +24,12 @@ import com.no1.wms.category.CategoryDto;
|
||||
|
||||
|
||||
@Service
|
||||
public class ExcelUtils {
|
||||
public class ExcelDownlodeUtils {
|
||||
|
||||
|
||||
|
||||
|
||||
//마지막 List<CategoryDto> dto 이부분을 수정해서 만들어야함.
|
||||
public void downloadCategoryExcelFile(String excelFileName, HttpServletResponse response,
|
||||
String sheetName, String[] columnName, List<CategoryDto> dto) {
|
||||
String fileName = "";
|
||||
@@ -32,7 +41,7 @@ public class ExcelUtils {
|
||||
response.setContentType("ms-vnd/excel");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
|
||||
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
|
||||
Row row = null;
|
||||
@@ -45,6 +54,7 @@ public class ExcelUtils {
|
||||
cell.setCellValue(columnName[i]);
|
||||
}
|
||||
rowNum += 1;
|
||||
|
||||
//수정부분
|
||||
makeCategoryBody(dto,row,sheet,cell,rowNum);
|
||||
|
||||
@@ -77,5 +87,43 @@ public class ExcelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
//엑셀 폼 파일 다운로드
|
||||
//엑셀 폼은 직접 만들어서 src/main/webapp/excelfiles/excelform 이 경로의 폴더안에 넣으면 됩니다.
|
||||
//확장자는 .xlsx로 해주세요.
|
||||
//매개변수는 HttpServletResponse response와 파일명 String을 넣으면 되고 파일명은 한글도 가능합니다.
|
||||
public void downlodeExcelForm(HttpServletResponse response, String formName) throws IOException {
|
||||
String excelfilesDirectory = "src/main/webapp/excelfiles/excelform/";
|
||||
|
||||
|
||||
File file = new File(excelfilesDirectory+formName);
|
||||
|
||||
try( FileInputStream fis = new FileInputStream(file);
|
||||
BufferedInputStream bis = new BufferedInputStream(fis);
|
||||
OutputStream out = response.getOutputStream()){
|
||||
String encodedFilename = URLEncoder.encode(formName, "UTF-8").replaceAll("\\+", "%20");
|
||||
|
||||
response.addHeader("Content-Disposition", "attachment;filename=\""+encodedFilename+"\"");
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
// 응답 크기 명시
|
||||
response.setContentLength((int)file.length());
|
||||
int read = 0;
|
||||
while((read = bis.read()) != -1) {
|
||||
out.write(read);
|
||||
}
|
||||
|
||||
|
||||
}catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
110
src/main/java/com/no1/wms/excel/ExcelManagerXlsx.java
Normal file
110
src/main/java/com/no1/wms/excel/ExcelManagerXlsx.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package com.no1.wms.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class ExcelManagerXlsx {
|
||||
|
||||
private static ExcelManagerXlsx excelXlsxMng;
|
||||
|
||||
public ExcelManagerXlsx() {
|
||||
}
|
||||
|
||||
public static ExcelManagerXlsx getInstance() {
|
||||
if (excelXlsxMng == null) {
|
||||
excelXlsxMng = new ExcelManagerXlsx();
|
||||
}
|
||||
return excelXlsxMng;
|
||||
}
|
||||
|
||||
public List<HashMap<String, String>> getListXlsxRead(String excel) throws Exception {
|
||||
|
||||
List<HashMap<String, String>> list = new ArrayList<HashMap<String,String>>();
|
||||
File file = new File( excel );
|
||||
if( !file.exists() || !file.isFile() || !file.canRead() ) {
|
||||
throw new IOException( excel );
|
||||
}
|
||||
XSSFWorkbook wb = new XSSFWorkbook( new FileInputStream(file) );
|
||||
|
||||
//xls시 이용
|
||||
//HSSFWorkbook wb = new HSSFWorkbook ( new FileInputStream(file) );
|
||||
|
||||
int sheetIndex = 0;
|
||||
|
||||
try {
|
||||
// 모든 시트 순회
|
||||
for( int i=0; i<1; i++ ) {
|
||||
XSSFSheet sheet = wb.getSheetAt(sheetIndex);
|
||||
for( Row row : sheet ) {
|
||||
// 첫 번째 시트만 사용
|
||||
if(row.getRowNum() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HashMap<String, String> hMap = new HashMap<String, String>();
|
||||
String valueStr = "";
|
||||
|
||||
int cellLength = (int) row.getLastCellNum();///
|
||||
|
||||
for (int j = 0; j < row.getLastCellNum(); j++) {
|
||||
Cell cell = row.getCell(j);
|
||||
|
||||
if (cell == null || cell.getCellType() == CellType.BLANK) {
|
||||
valueStr = "";
|
||||
}else{
|
||||
switch(cell.getCellType()){
|
||||
case STRING :
|
||||
valueStr = cell.getStringCellValue();
|
||||
break;
|
||||
case NUMERIC : // 날짜 형식이든 숫자 형식이든 다 CELL_TYPE_NUMERIC으로 인식함.
|
||||
if(DateUtil.isCellDateFormatted(cell)){ // 날짜 유형의 데이터일 경우,
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREA);
|
||||
String formattedStr = dateFormat.format(cell.getDateCellValue());
|
||||
valueStr = formattedStr;
|
||||
break;
|
||||
}else{ //숫자 데이터일 경우,
|
||||
Double numericCellValue = cell.getNumericCellValue();
|
||||
if(Math.floor(numericCellValue) == numericCellValue){ // 소수점 이하를 버린 값이 원래의 값과 같다면,,
|
||||
valueStr = numericCellValue.intValue() + ""; // int형으로 소수점 이하 버리고 String으로 데이터 담는다.
|
||||
}else{
|
||||
valueStr = numericCellValue + "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BOOLEAN :
|
||||
valueStr = cell.getBooleanCellValue() + "";
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// 엑셀의 열 인덱스와 함께 값 매핑
|
||||
hMap.put("cell_"+j ,valueStr);
|
||||
|
||||
}
|
||||
// 결과 리스트에 추가
|
||||
list.add(hMap);
|
||||
}
|
||||
sheetIndex++;
|
||||
}
|
||||
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
86
src/main/java/com/no1/wms/excel/ExcelRequestManager.java
Normal file
86
src/main/java/com/no1/wms/excel/ExcelRequestManager.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.no1.wms.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public class ExcelRequestManager {
|
||||
|
||||
public List<HashMap<String, String>> parseExcelSpringMultiPart
|
||||
(Map<String, MultipartFile> files , String KeyStr, int fileKeyParam,String atchFileId ,String storePath,HttpServletRequest request) throws Exception{
|
||||
List<HashMap<String, String>> list = null;
|
||||
int fileKey = fileKeyParam;
|
||||
|
||||
String storePathString = "";
|
||||
String atchFileIdString = "";
|
||||
|
||||
String folder = request.getServletContext().getRealPath("/");
|
||||
|
||||
if ("".equals(storePath) || storePath == null) {
|
||||
storePathString = folder+"/excelfiles/upload/";
|
||||
} else {
|
||||
storePathString = folder+"/excelfiles/upload/"+storePath;
|
||||
}
|
||||
|
||||
if (!"".equals(atchFileId) || atchFileId != null) {
|
||||
atchFileIdString = atchFileId;
|
||||
}
|
||||
|
||||
File saveFolder = new File(EgovWebUtil.filePathBlackList(storePathString));
|
||||
|
||||
//폴더 없으면 생성
|
||||
if (!saveFolder.exists() || saveFolder.isFile()) {
|
||||
saveFolder.mkdirs();
|
||||
}
|
||||
|
||||
Iterator<Entry<String, MultipartFile>> itr = files.entrySet().iterator();
|
||||
MultipartFile file;
|
||||
String filePath = "";
|
||||
|
||||
while (itr.hasNext()) {
|
||||
//파일 이름을 가져오는데 파일이 여러개일 경우
|
||||
Entry<String, MultipartFile> entry = itr.next();
|
||||
|
||||
file = entry.getValue();
|
||||
String orginFileName = file.getOriginalFilename();
|
||||
|
||||
if ("".equals(orginFileName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//파일의 확장자
|
||||
int index = orginFileName.lastIndexOf(".");
|
||||
String fileExt = orginFileName.substring(index + 1);
|
||||
//파일의 이름 정하기 지정한 KeyStr값과 시간 값과 fileKey를 넣어서 만듬
|
||||
String newName = KeyStr + getTimeStamp() + fileKey;
|
||||
|
||||
if (!"".equals(orginFileName)) {
|
||||
filePath = storePathString + File.separator + newName+"."+fileExt;
|
||||
file.transferTo(new File(EgovWebUtil.filePathBlackList(filePath)));
|
||||
}
|
||||
list = ExcelManagerXlsx.getInstance().getListXlsxRead(filePath);
|
||||
|
||||
fileKey++;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static String getTimeStamp() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
Date currentDate = new Date(currentTimeMillis);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
String formattedTimeStamp = dateFormat.format(currentDate);
|
||||
return formattedTimeStamp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -166,4 +166,6 @@ public class PriceController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
import com.no1.wms.category.CategoryService;
|
||||
import com.no1.wms.price.PriceDto;
|
||||
import com.no1.wms.vendor.VendorDto;
|
||||
import com.no1.wms.vendor.VendorService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/product")
|
||||
@@ -26,6 +28,8 @@ public class ProductController {
|
||||
ProductService productService;
|
||||
@Autowired
|
||||
CategoryService categoryService;
|
||||
@Autowired
|
||||
VendorService service;
|
||||
|
||||
/*
|
||||
@GetMapping("list")
|
||||
@@ -141,7 +145,7 @@ public class ProductController {
|
||||
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView m, String name) {
|
||||
int count = categoryService.count(searchn, search);
|
||||
|
||||
int perPage = 10; // 한 페이지에 보일 글의 개수
|
||||
int perPage =9; // 한 페이지에 보일 글의 개수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<CategoryDto> dto = categoryService.categoryList2(searchn, search, startRow ,perPage);
|
||||
@@ -171,6 +175,44 @@ public class ProductController {
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/show_modal2")
|
||||
public ModelAndView vendorShowModal(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView m, String name) {
|
||||
|
||||
int count = service.count(searchn, search);
|
||||
|
||||
int perPage = 9; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
//스톡서비스로 재고 리스트 출력 메서트 작성
|
||||
List<VendorDto> dto = service.list(searchn, search, startRow ,perPage);
|
||||
|
||||
|
||||
m.addObject("vlist", dto);
|
||||
m.addObject("start", startRow + 1);
|
||||
|
||||
int pageNum = 5;//보여질 페이지 번호 수
|
||||
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.addObject("searchn", searchn);
|
||||
m.addObject("search", search);
|
||||
m.addObject("begin", begin);
|
||||
m.addObject("end", end);
|
||||
m.addObject("pageNum", pageNum);
|
||||
m.addObject("totalPages", totalPages);
|
||||
m.addObject("p" , page);
|
||||
m.setViewName(name);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,101 +1,223 @@
|
||||
package com.no1.wms.stock;
|
||||
|
||||
|
||||
import com.no1.wms.vendor.VendorDto;
|
||||
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 org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
@RequestMapping("/stock")
|
||||
public class StockController {
|
||||
|
||||
@Autowired
|
||||
StockService service;
|
||||
|
||||
// 재고 리스트 출력
|
||||
@GetMapping("stock/list")
|
||||
// 탭 1 재고 리스트 출력
|
||||
@GetMapping("/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;//보여질 페이지 번호 수
|
||||
List<Map<String, Object>> dto = service.list(searchn, search, startRow ,perPage);
|
||||
m.addAttribute("slist", dto);
|
||||
|
||||
m.addAttribute("start", startRow + 1);
|
||||
|
||||
int pageNum = 5;//보여질 페이지 번호 수
|
||||
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("searchn", searchn);
|
||||
m.addAttribute("search", search);
|
||||
m.addAttribute("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
m.addAttribute("totalPages", totalPages);
|
||||
m.addAttribute("p" , page);
|
||||
|
||||
|
||||
|
||||
return "stock/list";
|
||||
}
|
||||
|
||||
|
||||
// 탭 2 재고 리스트 출력
|
||||
@GetMapping("/list2")
|
||||
public String list2(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
@RequestParam(name = "p2", defaultValue = "1") int page, Model m) {
|
||||
int count = service.count(searchn, search);
|
||||
|
||||
int perPage = 10; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
//스톡서비스로 재고 리스트 출력 메서트 작성
|
||||
List<Map<String, Object>> dto = service.list(searchn, search, startRow ,perPage);
|
||||
m.addAttribute("slist2", dto);
|
||||
|
||||
m.addAttribute("start2", startRow + 1);
|
||||
|
||||
int pageNum = 5;//보여질 페이지 번호 수
|
||||
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("searchn2", searchn);
|
||||
m.addAttribute("search2", search);
|
||||
m.addAttribute("begin2", begin);
|
||||
m.addAttribute("end2", end);
|
||||
m.addAttribute("pageNum2", pageNum);
|
||||
m.addAttribute("totalPages2", totalPages);
|
||||
m.addAttribute("p2" , page);
|
||||
|
||||
|
||||
|
||||
return "stock/list";
|
||||
}
|
||||
|
||||
|
||||
// 재고 상세페이지
|
||||
@PostMapping("stock/read/{id}")
|
||||
public String read(@PathVariable String id, Model m) {
|
||||
@PostMapping("/read")
|
||||
public String read(@RequestParam String id, Model m) {
|
||||
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
||||
StockDto dto = service.stockOne(id);
|
||||
Map<String, Object> dto = service.stockOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "stock/read/";
|
||||
return "stock/read";
|
||||
}
|
||||
|
||||
|
||||
// 수정 - 폼
|
||||
@GetMapping("/stock/update/{id}")
|
||||
public String update(@PathVariable String id, Model m) {
|
||||
StockDto dto = service.stockOne(id);
|
||||
@PostMapping("/update")
|
||||
public String update(String id, Model m) {
|
||||
Map<String, Object> dto = service.stockOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "stock/update";
|
||||
}
|
||||
|
||||
|
||||
// 수정 프로세스
|
||||
@PutMapping("/board/update_process")
|
||||
@PutMapping("/update_process")
|
||||
@ResponseBody
|
||||
public String updateProcess(StockDto dto) {
|
||||
service.updateStock(dto);
|
||||
return "redirect:list";
|
||||
public boolean updateProcess(StockDto dto) {
|
||||
|
||||
int i = service.updateStock(dto);
|
||||
if (i == 1) {
|
||||
service.updateWarehouse(dto);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 생성 폼
|
||||
@GetMapping ("/stock/create")
|
||||
public String create()
|
||||
{
|
||||
@PostMapping("/create")
|
||||
public String create() {
|
||||
return "stock/create";
|
||||
}
|
||||
|
||||
|
||||
// 생성 프로세스
|
||||
@PostMapping("/stock/create_process")
|
||||
// 생성 - Ajax
|
||||
@PostMapping("/create_process")
|
||||
@ResponseBody
|
||||
public String createProcess(StockDto dto) {
|
||||
service.createStock(dto);
|
||||
return "redirect:list";// 글목록
|
||||
public boolean createProcess(StockDto dto) {
|
||||
int i = service.createStock(dto);
|
||||
if (i != 0) {
|
||||
service.updateWarehousePlus(dto);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 삭제
|
||||
@DeleteMapping("/stock/delete")
|
||||
@DeleteMapping("/delete")
|
||||
@ResponseBody
|
||||
public int delete(String id) {
|
||||
int i = service.deleteBoard(id);
|
||||
public int delete(StockDto dto) {
|
||||
System.out.println("데이터 :: " + dto);
|
||||
int i = service.deleteStock(dto);
|
||||
service.updateWarehouseDeleteStock(dto);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/show_modal")
|
||||
public ModelAndView showModal(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
@RequestParam(name = "p", defaultValue = "1") int page,
|
||||
@RequestParam String name, ModelAndView mav){
|
||||
|
||||
int perPage = 5; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<Map<String, Object>> list = null;
|
||||
int count = 0;
|
||||
|
||||
//테스트
|
||||
System.out.println("name : " + name);
|
||||
System.out.println("list : " + list);
|
||||
System.out.println("count : " + count);
|
||||
System.out.println("mav : " + mav);
|
||||
//테스트
|
||||
|
||||
// 모달 선택
|
||||
if(name.equals("product_category_company_search")){
|
||||
list = service.productSelect(searchn, search, startRow, perPage);
|
||||
count = service.productCount(searchn, search);
|
||||
}else if(name.equals("warehouse_capacity_currentCapacity")) {
|
||||
list = service.warehousesSelect(searchn, search, startRow, perPage);
|
||||
count = service.warehouseCount(searchn, search);
|
||||
}
|
||||
|
||||
mav.addObject("list", list);
|
||||
|
||||
mav.addObject("start", startRow + 1);
|
||||
|
||||
int pageNum = 5;//보여질 페이지 번호 수
|
||||
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;
|
||||
}
|
||||
mav.addObject("begin", begin);
|
||||
mav.addObject("end", end);
|
||||
mav.addObject("pageNum", pageNum);
|
||||
mav.addObject("totalPages", totalPages);
|
||||
mav.addObject("p" , page);
|
||||
|
||||
mav.setViewName(name);
|
||||
|
||||
//테스트
|
||||
System.out.println("name : " + name);
|
||||
System.out.println("list : " + list);
|
||||
System.out.println("count : " + count);
|
||||
System.out.println("mav : " + mav);
|
||||
//테스트
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
package com.no1.wms.stock;
|
||||
|
||||
import com.no1.wms.product.ProductDto;
|
||||
import com.no1.wms.warehouse.WarehouseDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StockDto {
|
||||
|
||||
private String id;
|
||||
private int warehouseId;
|
||||
private int productId;
|
||||
private String warehouseId;
|
||||
private String productId;
|
||||
private int quantity;
|
||||
private boolean activation;
|
||||
|
||||
private int quantityAdjustment;
|
||||
}
|
||||
|
||||
@@ -10,17 +10,37 @@ import java.util.Map;
|
||||
public interface StockMapper {
|
||||
|
||||
int count(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
List<Object> list(Map<String, Object> m);
|
||||
// List<StockDto> list(Map<String, Object> m);
|
||||
|
||||
List<Map<String, Object>> list(Map<String, Object> m);
|
||||
|
||||
|
||||
int count2(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
List<Map<String, Object>> list2(Map<String, Object> m);
|
||||
|
||||
|
||||
int updateStock(StockDto dto);
|
||||
|
||||
int updateWarehouse(StockDto dto);
|
||||
|
||||
int updateWarehousePlus(StockDto dto);
|
||||
|
||||
int updateWarehouseDeleteStock(StockDto dto);
|
||||
|
||||
int createStock(StockDto dto);
|
||||
|
||||
StockDto stockOne(String id);
|
||||
|
||||
int deleteStock(String id);
|
||||
Map<String, Object> stockOne(String id);
|
||||
|
||||
int deleteStock(StockDto dto);
|
||||
|
||||
List<Map<String, Object>> productSelect(Map<String, Object> m);
|
||||
|
||||
int productCount(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
List<Map<String, Object>> warehouseSelect(Map<String, Object> m);
|
||||
|
||||
int warehouseCount(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.no1.wms.stock;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -8,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class StockService {
|
||||
@Autowired
|
||||
StockMapper mapper;
|
||||
@@ -19,13 +21,11 @@ public class StockService {
|
||||
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){
|
||||
public List<Map<String, Object>> list(int searchn, String search, int start, int perPage){
|
||||
|
||||
System.out.println(searchn+search);
|
||||
|
||||
@@ -33,14 +33,43 @@ public class StockService {
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", start);
|
||||
m.put("perPage", 10);
|
||||
m.put("perPage", perPage);
|
||||
|
||||
return mapper.list(m);
|
||||
List<Map<String, Object>> result = mapper.list(m);
|
||||
log.debug("warehouseOne테스트 :: " + result);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public int count2(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);
|
||||
return mapper.count2(m);
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> list2(int searchn, String search, int start, int perPage){
|
||||
|
||||
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", perPage);
|
||||
|
||||
List<Map<String, Object>> result = mapper.list2(m);
|
||||
log.debug("warehouseOne테스트 :: " + result);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public StockDto stockOne(String id) {
|
||||
public Map<String, Object> stockOne(String id) {
|
||||
return mapper.stockOne(id);
|
||||
}
|
||||
|
||||
@@ -54,8 +83,65 @@ public class StockService {
|
||||
return mapper.updateStock(dto);
|
||||
}
|
||||
|
||||
|
||||
public int deleteBoard(String id) {
|
||||
return mapper.deleteStock(id);
|
||||
public int updateWarehouse(StockDto dto){
|
||||
return mapper.updateWarehouse(dto);
|
||||
}
|
||||
|
||||
public int updateWarehousePlus(StockDto dto){
|
||||
return mapper.updateWarehousePlus(dto);
|
||||
}
|
||||
|
||||
public int updateWarehouseDeleteStock(StockDto dto){
|
||||
return mapper.updateWarehouseDeleteStock(dto);
|
||||
}
|
||||
|
||||
public int deleteStock(StockDto dto) {
|
||||
return mapper.deleteStock(dto);
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> productSelect(int searchn, String search, int start, int perPage){
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn", searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", start);
|
||||
m.put("perPage", perPage);
|
||||
|
||||
List<Map<String, Object>> productresult = mapper.productSelect(m);
|
||||
|
||||
return productresult;
|
||||
}
|
||||
|
||||
public int productCount(int searchn, String search) {
|
||||
|
||||
|
||||
Map<String,Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
return mapper.productCount(m);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> warehousesSelect(int searchn, String search, int start, int perPage){
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn", searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", start);
|
||||
m.put("perPage", perPage);
|
||||
|
||||
List<Map<String, Object>> warehouseresult = mapper.warehouseSelect(m);
|
||||
|
||||
return warehouseresult;
|
||||
}
|
||||
|
||||
public int warehouseCount(int searchn, String search) {
|
||||
|
||||
|
||||
Map<String,Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
return mapper.warehouseCount(m);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
124
src/main/java/com/no1/wms/vendor/VendorController.java
vendored
Normal file
124
src/main/java/com/no1/wms/vendor/VendorController.java
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
package com.no1.wms.vendor;
|
||||
|
||||
import com.no1.wms.warehouse.WarehouseDto;
|
||||
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;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
public class VendorController {
|
||||
|
||||
@Autowired
|
||||
VendorService service;
|
||||
|
||||
// 재고 리스트 출력
|
||||
@GetMapping("vendor/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<VendorDto> dto = service.list(searchn, search, startRow ,perPage);
|
||||
|
||||
|
||||
m.addAttribute("vlist", dto);
|
||||
m.addAttribute("start", startRow + 1);
|
||||
|
||||
int pageNum = 5;//보여질 페이지 번호 수
|
||||
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("searchn", searchn);
|
||||
m.addAttribute("search", search);
|
||||
m.addAttribute("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
m.addAttribute("totalPages", totalPages);
|
||||
m.addAttribute("p" , page);
|
||||
|
||||
return "vendor/list";
|
||||
}
|
||||
|
||||
|
||||
// 재고 상세페이지
|
||||
@PostMapping("vendor/read")
|
||||
public String read(String id, Model m) {
|
||||
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
||||
|
||||
VendorDto One = service.vendorOne(id);
|
||||
System.out.println("one :: " + One);
|
||||
log.debug("One테스트 :: " + One);
|
||||
|
||||
m.addAttribute("One", One);
|
||||
|
||||
return "vendor/read";
|
||||
}
|
||||
|
||||
|
||||
// 수정 - 폼
|
||||
@PostMapping("/vendor/update")
|
||||
public String update(String id, Model m) {
|
||||
VendorDto dto = service.vendorOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "vendor/update";
|
||||
}
|
||||
|
||||
|
||||
// 수정 프로세스
|
||||
@PutMapping("/vendor/update_process")
|
||||
@ResponseBody
|
||||
public boolean updateProcess(VendorDto dto) {
|
||||
|
||||
int i = service.updateVendor(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 생성 폼
|
||||
@PostMapping("/vendor/create")
|
||||
public String create()
|
||||
{
|
||||
return "vendor/create";
|
||||
}
|
||||
|
||||
|
||||
// 생성 프로세스
|
||||
@PostMapping("/vendor/create_process")
|
||||
@ResponseBody
|
||||
public boolean createProcess(VendorDto dto) {
|
||||
int i = service.createVendor(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 삭제
|
||||
@DeleteMapping("/vendor/delete")
|
||||
@ResponseBody
|
||||
public int delete(String id) {
|
||||
int i = service.deleteVendor(id);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
54
src/main/java/com/no1/wms/vendor/VendorDto.java
vendored
54
src/main/java/com/no1/wms/vendor/VendorDto.java
vendored
@@ -1,27 +1,27 @@
|
||||
package com.no1.wms.vendor;
|
||||
|
||||
import org.apache.ibatis.type.Alias;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Alias("VendorDto")
|
||||
public class VendorDto {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String president_name;
|
||||
private String address;
|
||||
private String registration_number;
|
||||
private String email;
|
||||
private String president_telephone;
|
||||
private String vendor_manager;
|
||||
private String vendor_manager_telephone;
|
||||
private String main_product;
|
||||
private String manager_id;
|
||||
private boolean activation;
|
||||
}
|
||||
package com.no1.wms.vendor;
|
||||
|
||||
import org.apache.ibatis.type.Alias;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@Alias("VendorDto")
|
||||
public class VendorDto {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String president_name;
|
||||
private String address;
|
||||
private String registration_number;
|
||||
private String email;
|
||||
private String president_telephone;
|
||||
private String vendor_manager;
|
||||
private String vendor_manager_telephone;
|
||||
private String main_product;
|
||||
private String manager_id;
|
||||
private boolean activation;
|
||||
}
|
||||
|
||||
26
src/main/java/com/no1/wms/vendor/VendorMapper.java
vendored
Normal file
26
src/main/java/com/no1/wms/vendor/VendorMapper.java
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.no1.wms.vendor;
|
||||
|
||||
import com.no1.wms.warehouse.WarehouseDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface VendorMapper {
|
||||
|
||||
List<VendorDto> list(Map<String, Object> m);
|
||||
|
||||
int count(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
VendorDto vendorOne(String id);
|
||||
|
||||
int updateVendor(VendorDto dto);
|
||||
|
||||
int createVendor(VendorDto dto);
|
||||
|
||||
int deleteVendor(String id);
|
||||
|
||||
|
||||
}
|
||||
57
src/main/java/com/no1/wms/vendor/VendorService.java
vendored
Normal file
57
src/main/java/com/no1/wms/vendor/VendorService.java
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.no1.wms.vendor;
|
||||
|
||||
import com.no1.wms.warehouse.WarehouseDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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
|
||||
@Slf4j
|
||||
public class VendorService {
|
||||
@Autowired
|
||||
VendorMapper mapper;
|
||||
|
||||
public int count(int searchn, String search) {
|
||||
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn", searchn);
|
||||
m.put("search", search);
|
||||
return mapper.count(m);
|
||||
}
|
||||
|
||||
|
||||
public List<VendorDto> list(int searchn, String search, int start, int perPage) {
|
||||
|
||||
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", perPage);
|
||||
|
||||
return mapper.list(m);
|
||||
}
|
||||
|
||||
public VendorDto vendorOne(String id) {
|
||||
return mapper.vendorOne(id);
|
||||
}
|
||||
|
||||
public int updateVendor(VendorDto dto) {
|
||||
return mapper.updateVendor(dto);
|
||||
}
|
||||
|
||||
|
||||
public int createVendor(VendorDto dto) {
|
||||
return mapper.createVendor(dto);
|
||||
}
|
||||
|
||||
|
||||
public int deleteVendor(String id) {
|
||||
return mapper.deleteVendor(id);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,10 @@ public class WarehouseController {
|
||||
|
||||
m.addAttribute("wlist", dto);
|
||||
m.addAttribute("start", startRow + 1);
|
||||
|
||||
//테스트
|
||||
System.out.println("list" + dto);
|
||||
//테스트
|
||||
|
||||
int pageNum = 5;//보여질 페이지 번호 수
|
||||
int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수
|
||||
@@ -42,6 +46,8 @@ public class WarehouseController {
|
||||
if (end > totalPages) {
|
||||
end = totalPages;
|
||||
}
|
||||
m.addAttribute("searchn", searchn);
|
||||
m.addAttribute("search", search);
|
||||
m.addAttribute("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
@@ -60,19 +66,16 @@ public class WarehouseController {
|
||||
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
||||
|
||||
WarehouseDto One = service.One(id);
|
||||
System.out.println("one :: " + One);
|
||||
log.debug("Osne테스트 :: " + One);
|
||||
|
||||
m.addAttribute("One", One);
|
||||
|
||||
int warehouseOneCount = service.warehouseOneCount(searchn, search, id);
|
||||
|
||||
log.debug("warehouseOneCount테스트 :: " + warehouseOneCount);
|
||||
|
||||
|
||||
int perPage = 5; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
m.addAttribute("start", startRow + 1);
|
||||
|
||||
int warehouseOneCount = service.warehouseOneCount(searchn, search, id);
|
||||
List<Map<String, Object>> dto = service.warehouseOne(searchn, search, id, startRow, perPage);
|
||||
m.addAttribute("wlist", dto);
|
||||
System.out.println("list ::" + dto);
|
||||
@@ -86,6 +89,8 @@ public class WarehouseController {
|
||||
if (end > totalPages) {
|
||||
end = totalPages;
|
||||
}
|
||||
m.addAttribute("searchn", searchn);
|
||||
m.addAttribute("search", search);
|
||||
m.addAttribute("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
@@ -130,9 +135,13 @@ public class WarehouseController {
|
||||
// 생성 프로세스
|
||||
@PostMapping("/warehouse/create_process")
|
||||
@ResponseBody
|
||||
public String createProcess(WarehouseDto dto) {
|
||||
service.createWarehouse(dto);
|
||||
return "redirect:list";// 글목록
|
||||
public boolean createProcess(WarehouseDto dto) {
|
||||
int i = service.createWarehouse(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user