mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 12:13:24 +09:00
planin 작업 완료
This commit is contained in:
@@ -53,7 +53,8 @@ dependencies {
|
||||
|
||||
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop
|
||||
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '2.5.0'
|
||||
|
||||
implementation group: 'com.google.zxing', name: 'javase', version: '3.5.0'
|
||||
implementation group: 'com.google.zxing', name: 'core', version: '3.5.0'
|
||||
|
||||
}
|
||||
tasks.named('test') {
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.no1.wms.account.AccountDto;
|
||||
import com.no1.wms.utils.ConstantValues;
|
||||
import com.no1.wms.utils.Utils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -16,6 +19,8 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import com.no1.wms.product.ProductDto;
|
||||
import com.no1.wms.product.ProductService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
@Controller
|
||||
@@ -42,6 +47,17 @@ public class PlanInController {
|
||||
|
||||
//스톡서비스로 재고 리스트 출력 메서트 작성
|
||||
List<PlanInDto> list = planinservice.selectAll(searchn, search, startRow, perPage);
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
for( int i = 0 ; i < list.size(); ++i){
|
||||
PlanInDto obj = list.get(i);
|
||||
String name = obj.getProductDto().getName();
|
||||
if(map.containsKey(name)){
|
||||
map.put(name, map.get(name)+1);
|
||||
}else{
|
||||
map.put(name, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int begin = (page - 1) / pageNum * pageNum + 1;
|
||||
int end = begin + pageNum - 1;
|
||||
@@ -49,6 +65,7 @@ public class PlanInController {
|
||||
end = totalPages;
|
||||
}
|
||||
mav.addObject("list", list);
|
||||
mav.addObject("map", map);
|
||||
mav.addObject("end", end);
|
||||
mav.addObject("searchn", searchn);
|
||||
mav.addObject("search", search);
|
||||
@@ -67,7 +84,6 @@ public class PlanInController {
|
||||
System.out.println(list.get(0).toString());
|
||||
mav.addObject("list", list);
|
||||
mav.addObject("groupNum", dto.getGroupNumber());
|
||||
|
||||
mav.setViewName("planin/read");
|
||||
|
||||
return mav;
|
||||
@@ -77,19 +93,34 @@ public class PlanInController {
|
||||
public ModelAndView update(PlanInDto dto, ModelAndView mav){
|
||||
List<PlanInDto> list = planinservice.selectById(dto);
|
||||
mav.addObject("list", list);
|
||||
|
||||
mav.addObject("groupNumber", dto.getGroupNumber());
|
||||
mav.addObject("viewGroupNumber", list.get(0).getViewGroupNumber());
|
||||
mav.setViewName("/planin/update");
|
||||
|
||||
return mav;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public ModelAndView create(ModelAndView mav){
|
||||
mav.addObject("groupNumber",UUID.randomUUID().toString() );
|
||||
mav.setViewName("/planin/create");
|
||||
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 다운로드
|
||||
@GetMapping("/qr/{id}")
|
||||
public String qr(@PathVariable("id")String id)
|
||||
@ResponseBody
|
||||
public String qr(@PathVariable("id")String id, HttpServletResponse response)
|
||||
{
|
||||
List<PlanInDto> list = planinservice.selectByUrl(id);
|
||||
|
||||
Utils.makePlanInExcel(list, response);
|
||||
|
||||
|
||||
return "";
|
||||
|
||||
return "s";
|
||||
}
|
||||
|
||||
// 입고예정추가
|
||||
@@ -122,31 +153,66 @@ public class PlanInController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public ModelAndView delete(ModelAndView mav, PlanInDto dto)
|
||||
{
|
||||
|
||||
|
||||
planinservice.delete(dto);
|
||||
List<PlanInDto> list = planinservice.selectAll(0,"",0,10000 );
|
||||
|
||||
mav.addObject("list", list);
|
||||
mav.setViewName("planin/list");
|
||||
|
||||
return mav;
|
||||
}
|
||||
|
||||
@PostMapping("/planin_update_process")
|
||||
@ResponseBody
|
||||
public String updateProcess(@RequestBody List<Map<String, Object>> list, Gson gson, PlanInDto dto) throws JsonProcessingException, ParseException {
|
||||
public String updateProcess(@RequestBody List<Map<String, Object>> list, Gson gson, PlanInDto dto, HttpServletRequest request) throws ParseException {
|
||||
|
||||
if(list.isEmpty())
|
||||
return gson.toJson("f");
|
||||
|
||||
AccountDto aDto =(AccountDto)request.getSession().getAttribute("userData");
|
||||
|
||||
dto.setGroupNumber((String) list.get(0).get("groupNumber"));
|
||||
|
||||
Integer viewGroupNumber = null;
|
||||
try {
|
||||
viewGroupNumber = Integer.parseInt((String) list.get(0).get("viewGroupNumber"));
|
||||
}catch (NumberFormatException e){
|
||||
viewGroupNumber = null;
|
||||
}
|
||||
String uuid;
|
||||
planinservice.deleteById(dto);
|
||||
|
||||
|
||||
if(dto.getGroupNumber() == null){
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}else{
|
||||
uuid = dto.getGroupNumber();
|
||||
}
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
|
||||
for(int i = 0; i < list.size(); ++i){
|
||||
Map<String, Object> data = list.get(i);
|
||||
PlanInDto newDto = new PlanInDto();
|
||||
newDto.setGroupNumber(uuid);
|
||||
newDto.setGroupNumber((String) data.get("groupNumber"));
|
||||
newDto.setDate( format.parse((String) data.get("date")));
|
||||
newDto.setQuantity((Integer) data.get("quantity"));
|
||||
newDto.setQuantity(Integer.parseInt((String) data.get("quantity")));
|
||||
newDto.setProductId((String)data.get("productId"));
|
||||
newDto.setManagerId(aDto.getId());
|
||||
newDto.setWarehouseId("5d201e83-b102-11ee-935d-0242ac110006");
|
||||
newDto.setViewGroupNumber(viewGroupNumber);
|
||||
|
||||
newDto.setActivation(true);
|
||||
|
||||
planinservice.insert(newDto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return gson.toJson("s");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,9 +31,8 @@ public class PlanInDto {
|
||||
private String warehouseId;
|
||||
private String qrHash;
|
||||
private String url;
|
||||
private Boolean clear;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date vendorDate;
|
||||
@Builder.Default
|
||||
private Boolean clear = false;
|
||||
private String other;
|
||||
private Boolean activation;
|
||||
private Integer viewGroupNumber;
|
||||
|
||||
@@ -16,7 +16,11 @@ public interface PlanInMapper {
|
||||
|
||||
List<PlanInDto> selectById(PlanInDto dto);
|
||||
|
||||
List<PlanInDto> selectByUrl(String id);
|
||||
|
||||
int deleteById(PlanInDto dto);
|
||||
|
||||
void insert(PlanInDto dto);
|
||||
|
||||
int delete(PlanInDto dto);
|
||||
}
|
||||
|
||||
@@ -40,4 +40,16 @@ public class PlanInService {
|
||||
void insert(PlanInDto dto){
|
||||
mapper.insert(dto);
|
||||
}
|
||||
|
||||
int delete(PlanInDto dto){
|
||||
return mapper.delete(dto);
|
||||
}
|
||||
|
||||
List<PlanInDto> selectByUrl(String id) {
|
||||
|
||||
return mapper.selectByUrl(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,8 @@ package com.no1.wms.utils;
|
||||
|
||||
public class ConstantValues {
|
||||
public static final int PER_PAGE = 1000;
|
||||
|
||||
public static final String PNG_TYPE = "img/png";
|
||||
|
||||
public static final String EXCEL_TYPE= "ms-vnd/excel";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,175 @@
|
||||
package com.no1.wms.utils;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
import com.no1.wms.planin.PlanInDto;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Utils {
|
||||
public static byte[] makeQr(String url) {
|
||||
// QR 정보
|
||||
int width = 200;
|
||||
int height = 200;
|
||||
BitMatrix encode = null;
|
||||
try {
|
||||
// QR Code - BitMatrix: qr code 정보 생성
|
||||
encode = new MultiFormatWriter()
|
||||
.encode(url, BarcodeFormat.QR_CODE, width, height);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(encode == null)
|
||||
return null;
|
||||
|
||||
// QR Code - Image 생성. : 1회성으로 생성해야 하기 때문에
|
||||
// stream으로 Generate(1회성이 아니면 File로 작성 가능.)
|
||||
try {
|
||||
//output Stream
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
//Bitmatrix, file.format, outputStream
|
||||
MatrixToImageWriter.writeToStream(encode, "PNG", out);
|
||||
|
||||
return out.toByteArray();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("QR Code OutputStream 도중 Excpetion 발생, " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void download(String fileName, byte[] data, String contentType, HttpServletResponse response ) {
|
||||
|
||||
try {
|
||||
fileName = new String((fileName).getBytes("utf-8"), "iso-8859-1");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.setContentType(contentType);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
|
||||
|
||||
try(ServletOutputStream os = response.getOutputStream();) {
|
||||
os.write(data);
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void makePlanInExcel(List<PlanInDto> list, HttpServletResponse response){
|
||||
XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
|
||||
|
||||
int rowNum = 0;
|
||||
XSSFCellStyle cellStyle = null;
|
||||
cellStyle = xssfWorkbook.createCellStyle();
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
cellStyle.setFillBackgroundColor(IndexedColors.BLACK.getIndex());
|
||||
XSSFFont font = xssfWorkbook.createFont();
|
||||
font.setColor(IndexedColors.WHITE.getIndex());
|
||||
font.setBold(true);
|
||||
|
||||
cellStyle.setFont(font);
|
||||
XSSFSheet sheet = xssfWorkbook.createSheet("자료");
|
||||
Row topRow = sheet.createRow(0);
|
||||
Cell cell = null;
|
||||
cell = topRow.createCell(0);
|
||||
cell.setCellValue("카테고리");
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell = topRow.createCell(1);
|
||||
cell.setCellValue("제품명");
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell = topRow.createCell(2);
|
||||
cell.setCellValue("수량");
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell = topRow.createCell(3);
|
||||
cell.setCellValue("공급업체");
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell = topRow.createCell(4);
|
||||
cell.setCellValue("날짜");
|
||||
cell.setCellStyle(cellStyle);
|
||||
|
||||
cell = topRow.createCell(5);
|
||||
cell.setCellValue("QR");
|
||||
cell.setCellStyle(cellStyle);
|
||||
|
||||
|
||||
XSSFCreationHelper helper = xssfWorkbook.getCreationHelper();
|
||||
XSSFCellStyle dataCellStyle = xssfWorkbook.createCellStyle();
|
||||
dataCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
dataCellStyle.setDataFormat(helper.createDataFormat().getFormat("yy-MM-dd"));
|
||||
sheet.setColumnWidth(5,(short)6000);
|
||||
|
||||
for( int i = 0 ; i < list.size(); ++i){
|
||||
|
||||
XSSFDrawing drawing = sheet.createDrawingPatriarch();
|
||||
XSSFClientAnchor anchor = helper.createClientAnchor();
|
||||
PlanInDto dto = list.get(i);
|
||||
System.out.println(dto);
|
||||
Row row = sheet.createRow(i+1);
|
||||
int cellNum = 0;
|
||||
row.setHeight((short) 3000);
|
||||
|
||||
row.createCell(cellNum++).setCellValue(dto.getCaName());
|
||||
setColumnSize(sheet, 0, dto.getCaName());
|
||||
row.createCell(cellNum++).setCellValue(dto.getProductDto().getName());
|
||||
setColumnSize(sheet, 1, dto.getProductDto().getName());
|
||||
row.createCell(cellNum++).setCellValue(dto.getQuantity());
|
||||
setColumnSize(sheet, 2, dto.getQuantity().toString());
|
||||
row.createCell(cellNum++).setCellValue(dto.getVendorDto().getName());
|
||||
setColumnSize(sheet, 3, dto.getVendorDto().getName());
|
||||
|
||||
Cell dateCell = row.createCell(cellNum);
|
||||
dateCell.setCellValue(dto.getDate());
|
||||
dateCell.setCellStyle(dataCellStyle);
|
||||
|
||||
anchor.setCol1(5);
|
||||
anchor.setRow1(i+1);
|
||||
String url = "http://localhost:8080/qr/"+dto.getUrl();
|
||||
int picIdx = xssfWorkbook.addPicture(Utils.makeQr(url), XSSFWorkbook.PICTURE_TYPE_PNG);
|
||||
XSSFPicture pic = drawing.createPicture(anchor,picIdx );
|
||||
pic.resize();
|
||||
|
||||
}
|
||||
try(ByteArrayOutputStream baos = new ByteArrayOutputStream();){
|
||||
xssfWorkbook.write(baos);
|
||||
download("QR데이터.xlsx", baos.toByteArray(), ConstantValues.EXCEL_TYPE, response);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void setColumnSize(XSSFSheet sheet, int index, String value) {
|
||||
int defaultColumnWidth = 2048;
|
||||
int maxLength = 70;
|
||||
int characterWidth = 256;
|
||||
double lengthWeight = 1.14388;
|
||||
int len = Math.min(value.length(), maxLength);
|
||||
int adjust = (((int)(len * lengthWeight) )* characterWidth) + defaultColumnWidth;
|
||||
|
||||
int columnWidth = sheet.getColumnWidth(index);
|
||||
if (columnWidth > adjust) return;
|
||||
|
||||
try {
|
||||
sheet.setColumnWidth(index, adjust);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
<result column="qr_hash" property="qrHash"/>
|
||||
<result column="url" property="url"/>
|
||||
<result column="clear" property="clear"/>
|
||||
<result column="vendor_date" property="vendorDate" />
|
||||
<result column="other" property="other" />
|
||||
<result column="activation" property="activation" />
|
||||
<result column="view_group_number" property="viewGroupNumber" />
|
||||
@@ -37,7 +36,7 @@
|
||||
<select id="selectById" resultMap="planInResultMap" parameterType="planInDto">
|
||||
SELECT
|
||||
plan.group_number, plan.product_id, plan.quantity, plan.date, plan.manager_id,
|
||||
plan.warehouse_id, plan.qr_hash, plan.url, plan.clear, plan.vendor_date, plan.other, plan.activation, plan.view_group_number,
|
||||
plan.warehouse_id, plan.qr_hash, plan.url, plan.clear, plan.other, plan.activation, plan.view_group_number,
|
||||
product.id p_id, product.name p_name, acc.id acc_id, acc.name acc_name, vendor.id v_id, vendor.name v_name,
|
||||
warehouse.id w_id, warehouse.name w_name, product_category.kan_code p_kan, product_category.cls_Nm_4 ca_name
|
||||
from plan_In plan join account acc join vendor join warehouse join product join product_category
|
||||
@@ -45,10 +44,21 @@
|
||||
and plan.warehouse_id = warehouse.id and product.kan_code = product_category.kan_code
|
||||
where plan.group_number = #{groupNumber}
|
||||
</select>
|
||||
<select id="selectByUrl" resultMap="planInResultMap">
|
||||
SELECT
|
||||
plan.group_number, plan.product_id, plan.quantity, plan.date, plan.manager_id,
|
||||
plan.warehouse_id, plan.qr_hash, plan.url, plan.clear, plan.other, plan.activation, plan.view_group_number,
|
||||
product.id p_id, product.name p_name, acc.id acc_id, acc.name acc_name, vendor.id v_id, vendor.name v_name,
|
||||
warehouse.id w_id, warehouse.name w_name, product_category.kan_code p_kan, product_category.cls_Nm_4 ca_name
|
||||
from plan_In plan join account acc join vendor join warehouse join product join product_category
|
||||
on plan.product_id = product.id and product.vendor_id = vendor.id and plan.manager_id = acc.id
|
||||
and plan.warehouse_id = warehouse.id and product.kan_code = product_category.kan_code
|
||||
WHERE plan.url = #{id}
|
||||
</select>
|
||||
<select id="selectAll" resultMap="planInResultMap" parameterType="map">
|
||||
SELECT
|
||||
plan.group_number, plan.product_id, plan.quantity, plan.date, plan.manager_id,
|
||||
plan.warehouse_id, plan.qr_hash, plan.url, plan.clear, plan.vendor_date, plan.other, plan.activation, plan.view_group_number,
|
||||
plan.warehouse_id, plan.qr_hash, plan.url, plan.clear, plan.other, plan.activation, plan.view_group_number,
|
||||
product.id p_id, product.name p_name, acc.id acc_id, acc.name acc_name, vendor.id v_id, vendor.name v_name,
|
||||
warehouse.id w_id, warehouse.name w_name, product_category.kan_code p_kan, product_category.cls_Nm_4 ca_name
|
||||
from plan_In plan join account acc join vendor join warehouse join product join product_category
|
||||
@@ -60,7 +70,7 @@
|
||||
<when test="searchn == 0"> plan.activation = 1 and plan.group_number like concat('%',#{search},'%') </when>
|
||||
</choose>
|
||||
</where>
|
||||
order by plan.group_number desc limit #{start}, #{perPage}
|
||||
order by plan.view_group_number desc limit #{start}, #{perPage}
|
||||
|
||||
</select>
|
||||
<insert id="insert" parameterType="planInDto">
|
||||
@@ -68,17 +78,30 @@
|
||||
(
|
||||
group_number, product_id, quantity, date,
|
||||
manager_id, warehouse_id, qr_hash,
|
||||
url, clear, vendor_date, other, activation, view_group_number
|
||||
url, clear, other, activation, view_group_number
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
UUID(), #{productId}, #{quantity},
|
||||
VALUES (#{groupNumber}, #{productId}, #{quantity},
|
||||
#{date},
|
||||
#{managerId},#{warehouseId},#{qrHash},
|
||||
#{url},#{clear}, #{vendor_date},
|
||||
#{other},#{activation}, (select MAX(c.group_number)+1 as cnt
|
||||
from ( select group_number,MAX(group_number) from plan_In group by group_number ) as c)
|
||||
#{managerId}, #{warehouseId}, #{qrHash},
|
||||
#{groupNumber}, #{clear},
|
||||
#{other}, true,
|
||||
CASE
|
||||
WHEN #{viewGroupNumber} IS NOT NULL
|
||||
THEN #{viewGroupNumber}
|
||||
WHEN (SELECT count(p1.group_number)
|
||||
from plan_In p1
|
||||
WHERE p1.group_number = #{groupNumber} > 0)
|
||||
THEN (SELECT p2.view_group_number
|
||||
FROM plan_In p2
|
||||
WHERE p2.group_number = #{groupNumber} LIMIT 1)
|
||||
ELSE
|
||||
(select count(c.group_number) + 1 as cnt
|
||||
from (select p3.group_number, MAX(p3.group_number)
|
||||
from plan_In p3
|
||||
group by p3.group_number) as c)
|
||||
END
|
||||
)
|
||||
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -91,7 +114,6 @@
|
||||
qr_hash = #{qrHash},
|
||||
url = #{url},
|
||||
clear = #{clear},
|
||||
vendor_date = #{vendorDate},
|
||||
other = #{other},
|
||||
activation = #{activation},
|
||||
product_id = #{productId}
|
||||
@@ -101,9 +123,6 @@
|
||||
<update id="delete" parameterType="planInDto">
|
||||
update plan_In SET activation = false WHERE group_number = #{groupNumber}
|
||||
</update>
|
||||
<update id="deleteProduct" parameterType="planInDto">
|
||||
update plan_In SET activation = false WHERE group_number = #{groupNumber} and product_id = #{productId}
|
||||
</update>
|
||||
<select id="count" parameterType="map" resultType="java.lang.Integer">
|
||||
select count(*) from ( SELECT 1 from plan_In i join product p
|
||||
<where>
|
||||
@@ -115,6 +134,9 @@
|
||||
) t
|
||||
</select>
|
||||
<delete id="deleteById" parameterType="planInDto">
|
||||
delete from plan_In WHERE group_number = #{groupNumber}
|
||||
SET foreign_key_checks = 0;
|
||||
delete from plan_In WHERE group_number = #{groupNumber};
|
||||
SET foreign_key_checks = 1;
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
212
src/main/webapp/WEB-INF/views/planin/create.jsp
Normal file
212
src/main/webapp/WEB-INF/views/planin/create.jsp
Normal file
@@ -0,0 +1,212 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<script>
|
||||
let groupN = '${groupNumber}';
|
||||
|
||||
function goRead(){
|
||||
const $form = $("#form");
|
||||
|
||||
|
||||
$form.trigger("submit");
|
||||
}
|
||||
|
||||
let modalData = {};
|
||||
let $selectedTr;
|
||||
|
||||
function showSearchModal(title){
|
||||
$("#searchModalLabel").text(title);
|
||||
const data = { };
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/plan_in/planin_add', // 요청할 서버url
|
||||
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
$("#search_modal_body").html(result);
|
||||
searchModalBootStrap.show();
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
function showSearchModalEdit(title, target){
|
||||
$selectedTr = $($(target).parent('td').parent("tr"));
|
||||
$("#searchModalLabel").text(title);
|
||||
const data = { };
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/plan_in/planin_edit', // 요청할 서버url
|
||||
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
$("#search_modal_body").html(result);
|
||||
const tds = $selectedTr.find("td");
|
||||
|
||||
modalData.name = $(tds[0]).text();
|
||||
modalData.category = $(tds[1]).text();
|
||||
modalData.id = $selectedTr.data("productid");
|
||||
modalData.vendor = $(tds[3]).text();
|
||||
modalData.date = $(tds[4]).text();
|
||||
modalData.num = $(tds[2]).text();
|
||||
|
||||
editData();
|
||||
searchModalBootStrap.show();
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addToTable(data){
|
||||
const $addTr = $("#id_add_tr");
|
||||
|
||||
const $newTr = $($("#copy_target_tr")).clone();
|
||||
$newTr.addClass("group_tr");
|
||||
$newTr.removeAttr("id");
|
||||
|
||||
//데이터 세팅 부분
|
||||
$newTr.data("productid", data.id);
|
||||
const tds = $newTr.find("td");
|
||||
$(tds[0]).text(data.name);
|
||||
$(tds[1]).text(data.category);
|
||||
$(tds[2]).text(data.num);
|
||||
$(tds[3]).text(data.vendor);
|
||||
$(tds[4]).text(data.date);
|
||||
|
||||
|
||||
$addTr.detach().appendTo("#form");
|
||||
|
||||
$("#id_table_body").append($newTr);
|
||||
|
||||
$addTr.detach().appendTo("#id_table_body");
|
||||
}
|
||||
|
||||
function editToTable(data){
|
||||
|
||||
const $newTr = $selectedTr;
|
||||
|
||||
//데이터 세팅 부분
|
||||
$newTr.data("productid", data.id);
|
||||
const tds = $newTr.find("td");
|
||||
$(tds[0]).text(data.name);
|
||||
$(tds[1]).text(data.category);
|
||||
$(tds[2]).text(data.num);
|
||||
$(tds[3]).text(data.vendor);
|
||||
$(tds[4]).text(data.date);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function deleteTable(target){
|
||||
$($(target).parent('td').parent("tr")).remove();
|
||||
}
|
||||
|
||||
function goSave(){
|
||||
const list = [];
|
||||
|
||||
const $trs = $(".group_tr");
|
||||
|
||||
$trs.each(function(index, item){
|
||||
let data = {};
|
||||
const $tr = $(item);
|
||||
const tds = $tr.find("td");
|
||||
data.groupNumber = groupN;
|
||||
data.productId = $tr.data("productid");
|
||||
data.date = $(tds[4]).text();
|
||||
data.quantity = $(tds[2]).text();
|
||||
list.push(data);
|
||||
});
|
||||
|
||||
console.log(list);
|
||||
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/plan_in/planin_update_process', // 요청할 서버url
|
||||
data : JSON.stringify(list),
|
||||
dataType : 'json',
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
if(result === 's') {
|
||||
$("#groupId").val(groupN);
|
||||
goRead();
|
||||
}else{
|
||||
alert("에러가 발생하였습니다");
|
||||
}
|
||||
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
<h1>입고 예정 관리 생성</h1>
|
||||
</div>
|
||||
<div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 att">
|
||||
<button style="float: right;" class="btn btn-primary" type="submit" id="btn_create" onclick="goCreate() ">삭제 </button>
|
||||
</div>
|
||||
<div class="col-12 m-0">
|
||||
<table class="table" >
|
||||
<thead class="table-dark">
|
||||
<tr><th>제품 카테고리</th><th>제품명</th><th>수량</th><th>공급업체</th><th>날짜</th><th>수정/삭제</th></tr>
|
||||
</thead>
|
||||
<tbody id="id_table_body">
|
||||
<tr id="id_add_tr">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><button type="button" class="btn btn-warning" onclick="showSearchModal('입고 예정 추가')">추가</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<button class="btn-primary btn" onclick="goSave()">저장</button>
|
||||
<form method="get" class="d-inline" action="/plan_in/list">
|
||||
<button class="btn-primary btn" type="submit">취소</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "visually-hidden">
|
||||
<table>
|
||||
<tr id="copy_target_tr" data-groupn="" data-productid="">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning" onclick="showSearchModalEdit('입고 예정 추가', this)">수정</button>
|
||||
<button type="button" class="btn btn-danger" onclick="deleteTable(this)" >삭제</button>
|
||||
<td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<form id="form" action='/plan_in/read' method="post">
|
||||
<input name="groupNumber" id="groupId" hidden>
|
||||
<input name="productId" id="productId" hidden>
|
||||
</form>
|
||||
@@ -25,6 +25,13 @@
|
||||
$form.trigger("submit");
|
||||
}
|
||||
|
||||
function goCreate(){
|
||||
const $form = $("<form method='post' action='/plan_in/create'></form> ");
|
||||
$(".att").after($form);
|
||||
$form.trigger("submit");
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<script>
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
${dto.productDto.name}<br>
|
||||
</c:forEach>
|
||||
|
||||
function showSearchModal(title, val){
|
||||
$("#searchModalLabel").text(title);
|
||||
@@ -24,6 +21,30 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
$(function(){
|
||||
$("#link_id").on("click", function(){
|
||||
copy();
|
||||
});
|
||||
|
||||
})
|
||||
async function copy(){
|
||||
|
||||
try{
|
||||
let protocol = window.location.protocol+"//";
|
||||
let host = window.location.host;
|
||||
let text = $("#link_id").attr("href");
|
||||
let url = protocol+host+text;
|
||||
await navigator.clipboard.writeText(url);
|
||||
alert("클립보드에 엑셀 다운로드 주소 : \n"+url+"\n복사완료");
|
||||
// 클립보드에 write이 성공했을 때
|
||||
|
||||
}catch{
|
||||
|
||||
// 클립보드에 write이 실패했을 때
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
@@ -39,13 +60,17 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 att">
|
||||
qr : <a href = "/plan_in/qr/${groupNum}"> link </a>
|
||||
<button style="float: right;" class="btn btn-primary" type="submit" id="btn_create" onclick="goCreate() ">삭제 </button>
|
||||
다운 : <a class = "me-3" id="link_id" href = "/plan_in/qr/${groupNum}">엑셀 다운로드 </a>
|
||||
<button id="link_button" class="btn-primary btn" onClick="copy()" >다운로드 주소 복사</button>
|
||||
<form class="d-inline" method="post" action="/plan_in/delete">
|
||||
<input hidden name="groupNumber" value="${groupNum}">
|
||||
<button style="float: right;" class="btn btn-primary" type="submit" id="btn_create">삭제 </button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-12 m-0">
|
||||
<table class="table" >
|
||||
<thead class="table-dark">
|
||||
<tr><th>제품 카테고리</th><th>제품명</th><th>수량</th><th>공급업체</th><th>날짜</th><th>수정/삭제</th></tr>
|
||||
<tr><th>제품 카테고리</th><th>제품명</th><th>수량</th><th>공급업체</th><th>날짜</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<script>
|
||||
function goRead(){
|
||||
const $form = $("#form");
|
||||
|
||||
|
||||
$("#groupId").val('${groupNumber}');
|
||||
|
||||
$form.trigger("submit");
|
||||
}
|
||||
|
||||
let modalData = {};
|
||||
let $selectedTr;
|
||||
let viewGroupNumber = '${viewGroupNumber}';
|
||||
|
||||
function showSearchModal(title){
|
||||
$("#searchModalLabel").text(title);
|
||||
@@ -91,6 +101,10 @@
|
||||
|
||||
|
||||
function deleteTable(target){
|
||||
if($(".group_tr").length <= 1){
|
||||
alert("물품은 최소한 하나는 있어야 합니다");
|
||||
return;
|
||||
}
|
||||
$($(target).parent('td').parent("tr")).remove();
|
||||
}
|
||||
|
||||
@@ -107,9 +121,12 @@
|
||||
data.productId = $tr.data("productid");
|
||||
data.date = $(tds[4]).text();
|
||||
data.quantity = $(tds[2]).text();
|
||||
data.viewGroupNumber = viewGroupNumber;
|
||||
list.push(data);
|
||||
});
|
||||
|
||||
console.log(list);
|
||||
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/plan_in/planin_update_process', // 요청할 서버url
|
||||
@@ -117,7 +134,11 @@
|
||||
dataType : 'json',
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
console.log(result);
|
||||
if(result === 's') {
|
||||
goRead();
|
||||
}else{
|
||||
alert("에러가 발생하였습니다")
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
@@ -126,6 +147,10 @@
|
||||
|
||||
}
|
||||
|
||||
function goDelete(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@@ -142,9 +167,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 att">
|
||||
<button style="float: right;" class="btn btn-primary" type="submit" id="btn_create" onclick="goCreate() ">삭제 </button>
|
||||
</div>
|
||||
<div class="col-12 m-0">
|
||||
<table class="table" >
|
||||
<thead class="table-dark">
|
||||
|
||||
Reference in New Issue
Block a user