mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 12:13:33 +09:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -8,6 +8,7 @@ import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -186,10 +187,68 @@ public class ExcelDownlodeUtils {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void downloadStockExcelFile(String excelFileName, HttpServletResponse response,
|
||||
String sheetName, String[] columnName, List<Map<String, Object>> dto) {
|
||||
String fileName = "";
|
||||
try {
|
||||
fileName = new String((excelFileName + ".xlsx").getBytes("utf-8"), "iso-8859-1");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.setContentType("ms-vnd/excel");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
|
||||
Row row = null;
|
||||
Cell cell = null;
|
||||
int rowNum = 0;
|
||||
|
||||
row = sheet.createRow(rowNum);
|
||||
for( int i = 0; i <= columnName.length -1; i++ ) {
|
||||
cell = row.createCell(i);
|
||||
cell.setCellValue(columnName[i]);
|
||||
}
|
||||
rowNum += 1;
|
||||
|
||||
//수정부분
|
||||
makeStockBody(dto,row,sheet,cell,rowNum);
|
||||
|
||||
try {
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void makeStockBody(List<Map<String, Object>> listdto, Row row, Sheet sheet,
|
||||
Cell cell, int rowNum) {
|
||||
//
|
||||
for (int i = 0; i < listdto.size(); i++) {
|
||||
row = sheet.createRow(rowNum++);
|
||||
Map<String, Object> dto = listdto.get(i);
|
||||
cell = row.createCell(0);
|
||||
cell.setCellValue((String) dto.get("productName"));
|
||||
cell = row.createCell(1);
|
||||
cell.setCellValue((String) dto.get("cls_nm_4"));
|
||||
cell = row.createCell(2);
|
||||
cell.setCellValue((String) dto.get("warehouseName"));
|
||||
cell = row.createCell(3);
|
||||
cell.setCellValue((String) dto.get("quantity"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.no1.wms.in;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -10,6 +11,12 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.no1.wms.price.PriceDto;
|
||||
import com.no1.wms.product.ProductDto;
|
||||
import com.no1.wms.product.ProductService;
|
||||
import com.no1.wms.stock.StockService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/in")
|
||||
@@ -17,6 +24,10 @@ public class InController {
|
||||
|
||||
@Autowired
|
||||
InService inService;
|
||||
@Autowired
|
||||
ProductService productService;
|
||||
@Autowired
|
||||
StockService stockservice;
|
||||
|
||||
@GetMapping("/list")
|
||||
//@ResponseBody
|
||||
@@ -59,6 +70,112 @@ public class InController {
|
||||
return "in/create";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
@PostMapping("/create_process")
|
||||
@ResponseBody
|
||||
public boolean createProcess(PriceDto dto) {
|
||||
int i = inService.createProcess(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//모달화면
|
||||
@PostMapping("/show_modal_product")
|
||||
public ModelAndView productShowModal(@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 = productService.count(searchn, search);
|
||||
|
||||
int perPage = 10; // 한 페이지에 보일 글의 개수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<ProductDto> dto = productService.productList(searchn, search, startRow ,perPage);
|
||||
|
||||
m.addObject("list", 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;
|
||||
}
|
||||
|
||||
@PostMapping("/show_modal_warehouse")
|
||||
public ModelAndView warehouseShowModal(@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 = 9; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<Map<String, Object>> list = null;
|
||||
int count = 0;
|
||||
|
||||
list = stockservice.warehousesSelect(searchn, search, startRow, perPage);
|
||||
count = stockservice.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("searchn", searchn);
|
||||
mav.addObject("search", search);
|
||||
mav.addObject("begin", begin);
|
||||
mav.addObject("end", end);
|
||||
mav.addObject("pageNum", pageNum);
|
||||
mav.addObject("totalPages", totalPages);
|
||||
mav.addObject("p" , page);
|
||||
|
||||
mav.setViewName(name);
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PriceController {
|
||||
PriceService priceService;
|
||||
@Autowired
|
||||
ProductService productService;
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
public String list(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.no1.wms.stock;
|
||||
|
||||
|
||||
import com.no1.wms.excel.ExcelDownlodeUtils;
|
||||
import com.no1.wms.vendor.VendorDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -9,6 +10,8 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -19,6 +22,9 @@ public class StockController {
|
||||
|
||||
@Autowired
|
||||
StockService service;
|
||||
|
||||
@Autowired
|
||||
ExcelDownlodeUtils excelDownlodeUtils;
|
||||
|
||||
// 탭 1 재고 리스트 출력
|
||||
@GetMapping("/list")
|
||||
@@ -166,7 +172,7 @@ public class StockController {
|
||||
@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(name = "p", defaultValue = "1") int page, String product_id,
|
||||
@RequestParam String name, ModelAndView mav){
|
||||
|
||||
int perPage = 5; // 한 페이지에 보일 글의 갯수
|
||||
@@ -187,8 +193,8 @@ public class StockController {
|
||||
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);
|
||||
list = service.warehousesSelect(searchn, search, startRow, perPage ,product_id);
|
||||
count = service.warehouseCount(searchn, search ,product_id);
|
||||
}
|
||||
|
||||
mav.addObject("list", list);
|
||||
@@ -221,4 +227,26 @@ public class StockController {
|
||||
//테스트
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
// 리스트 다운로드
|
||||
@GetMapping("/stock/downloadExcelList")
|
||||
public void downlodeExcelList(HttpServletResponse response) {
|
||||
List<Map<String, Object>> dto = service.selectAll();
|
||||
String excelFileName = "재고 파일";
|
||||
String sheetName = "재고";
|
||||
String[] columnName = {"제품명","카테고리","창고","재고수"};
|
||||
excelDownlodeUtils.downloadStockExcelFile(excelFileName, response, sheetName, columnName, dto);
|
||||
|
||||
};
|
||||
|
||||
//서식 다운로드
|
||||
@GetMapping("/stock/downloadStockForm")
|
||||
public void downlodeStockForm (HttpServletResponse response) throws IOException {
|
||||
String stockFormName = "재고 데이터 입력 서식.xlsx";
|
||||
excelDownlodeUtils.downlodeExcelForm(response, stockFormName);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface StockMapper {
|
||||
List<Map<String, Object>> selectAll();
|
||||
|
||||
int count(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
|
||||
@@ -121,27 +121,33 @@ public class StockService {
|
||||
return mapper.productCount(m);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> warehousesSelect(int searchn, String search, int start, int perPage){
|
||||
public List<Map<String, Object>> warehousesSelect(int searchn, String search, int start, int perPage, String product_id){
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn", searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", start);
|
||||
m.put("perPage", perPage);
|
||||
m.put("product_id", product_id);
|
||||
|
||||
List<Map<String, Object>> warehouseresult = mapper.warehouseSelect(m);
|
||||
|
||||
return warehouseresult;
|
||||
}
|
||||
|
||||
public int warehouseCount(int searchn, String search) {
|
||||
public int warehouseCount(int searchn, String search, String product_id) {
|
||||
|
||||
|
||||
Map<String,Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
m.put("product_id", product_id);
|
||||
return mapper.warehouseCount(m);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> selectAll() {
|
||||
return mapper.selectAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,8 @@ public class VendorController {
|
||||
}
|
||||
|
||||
// 엑셀다운로드테스트
|
||||
@GetMapping("/vendor/downloadTest")
|
||||
public void downloadExcelTest(HttpServletResponse response) {
|
||||
@GetMapping("/vendor/downlodeExcelList")
|
||||
public void downlodeExcelList(HttpServletResponse response) {
|
||||
List<VendorDto> dto = service.selectAll();
|
||||
String excelFileName = "거래처 파일";
|
||||
String sheetName = "거래처";
|
||||
|
||||
Reference in New Issue
Block a user