Kaynağa Gözat

상품목록 멀티검색 추가

eskim 5 yıl önce
ebeveyn
işleme
f5e4a153eb

+ 100 - 0
style24.admin/src/main/java/com/style24/admin/biz/service/TsaGoodsService.java

@@ -3,6 +3,7 @@ package com.style24.admin.biz.service;
 import java.util.Collection;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
@@ -33,6 +34,9 @@ public class TsaGoodsService {
 	@Autowired
 	private TscMessageByLocale message;
 
+	@Autowired
+	private Environment env;
+
 	@Autowired
 	private TsaGoodsDao goodsDao;
 
@@ -181,4 +185,100 @@ public class TsaGoodsService {
 	public Collection<Goods> getGoodsList(GoodsSearch goodsSearch) {
 		return goodsDao.getGoodsList(goodsSearch);
 	}
+
+	/**
+	 * 상품목록 - 기본정보 엑셀다운로드
+	 *
+	 * @param goodsSearch
+	 * @param excelFilenameWithPath - 경로를 포함한 엑셀파일명
+	 * @return
+	 * @author eskim
+	 * @since 2020. 10. 21
+	 */
+	public void getGoodsInfoExcelList(GoodsSearch goodsSearch, String excelFilenameWithPath) {
+
+//		if ("Y".equals(goodsSearch.getImageViewYn())) {
+//			// 헤더 title 설정
+//			String[] listTitles = {"이미지", "상품코드", "업체명", "브랜드명", "상품명", "품목", "판매가능재고", "상품상태", "스타일년도", "시즌",
+//				"정상가", "판매가", "임직원가", "할인율", "가격변경일", "ERP재고연동여부",
+//				"정상이월구분", "승인일시", "EC전송일시"};
+//
+//			// DB 처리 시 사용되는 파라미터명(셀명) 설정
+//			String[] cellNames = {"IMG_PATH1", "GOODS_CD", "SUPPLY_COMP_CD", "BRAND_GRP_NM", "GOODS_NM", "ITEMKIND_NM",
+//				"STOCK_QTY_SUM", "GOODS_STAT", "STYLE_YEAR", "SEASON_CD",  "LIST_PRICE", "CURR_PRICE",
+//				"STAFF_CURR_PRICE", "DC_RATE", "PRICE_UPD_DT", "ERP_STOCK_LINK_YN",
+//				 "FORMAL_GB", "APPR_UPD_DT", "ECMONITOR_REG_DT"};
+//
+//			String[] cellTypes = {GagaExcelConstants.CellType.IMAGE.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
+//				GagaExcelConstants.CellType.CHAR_RIGHT.name(),
+//				GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name()};
+//
+//			String targetPath = env.getProperty("upload.goods.view");
+//			Collection<GagaMap> dataList = goodsDao.getGoodsInfoExcelList(goodsSearch); // map형식으로 조회
+//			if (dataList != null && !dataList.isEmpty()) {
+//				for (GagaMap gagaMap : dataList) {
+//					if ("A".equals(gagaMap.get("IMG_TYPE").toString())) {
+//						if (!StringUtils.isEmpty(gagaMap.get("IMG_PATH6"))) {
+//							gagaMap.set("IMG_PATH1", targetPath + gagaMap.get("IMG_PATH6").toString().replace("/1000/", "/100/"));
+//
+//						} else {
+//							gagaMap.set("IMG_PATH1", targetPath + gagaMap.get("IMG_PATH1").toString().replace("/1000/", "/100/"));
+//						}
+//						gagaMap.set("IMG_PATH1", gagaMap.get("IMG_PATH1").toString());
+//					} else {
+//
+//					}
+//				}
+//			}
+//
+//			try {
+//				GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 정보", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
+//			} catch (Exception e) {
+//				throw new IllegalStateException(e);
+//			}
+//
+//		} else {
+//			// 헤더 title 설정
+//			String[] listTitles = {"상품코드", "업체명", "브랜드명", "상품명", "품목", "재고", "상품상태", "스타일년도", "시즌",  "정상가",
+//				"판매가", "할인율", "가격변경일", "ERP재고연동여부", "정상이월구분", "반품가능 여부", "교환가능 여부", "무료반품가능 여부",
+//				"무료교환 여부", "이미지 여부"};
+//
+//			// DB 처리 시 사용되는 파라미터명(셀명) 설정
+//			String[] cellNames = {"GOODS_CD", "SUPPLY_COMP_CD", "BRAND_ENM", "GOODS_NM", "ITEMKIND_NM",
+//				"STOCK_QTY_SUM", "GOODS_STAT", "STYLEyEAR", "SEASON_CD",  "LIST_PRICE", "CURR_PRICE",
+//				"DC_RATE", "PRICE_UPD_DT", "ERP_STOCK_LINK_YN", "ERP_PRICE_LINK_YN", "FORMAL_GB", "RETURNABLE_YN",
+//				"CHANGEABLE_YN", "RETURN_FEE_FREE_YN", "CHANGE_FEE_FREE_YN", "GOODS_IMAGE_YN"};
+//
+//			String[] cellTypes = {GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_RIGHT.name(),
+//				GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+//				GagaExcelConstants.CellType.CHAR_CENTER.name()};
+//
+//			Collection<GagaMap> dataList = goodsDao.getGoodsInfoExcelList(goodsSearch);
+//
+//			try {
+//				GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 정보", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
+//			} catch (Exception e) {
+//				throw new IllegalStateException(e);
+//			}
+//		}
+
+	}
+
 }

+ 53 - 10
style24.admin/src/main/java/com/style24/admin/biz/web/TsaGoodsController.java

@@ -2,7 +2,12 @@ package com.style24.admin.biz.web;
 
 import java.util.Collection;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -27,6 +32,8 @@ import lombok.extern.slf4j.Slf4j;
 
 import com.gagaframework.web.parameter.GagaMap;
 import com.gagaframework.web.rest.server.GagaResponse;
+import com.gagaframework.web.util.GagaDateUtil;
+import com.gagaframework.web.util.GagaFileUtil;
 
 /**
  * 상품관리 Controller
@@ -42,6 +49,9 @@ public class TsaGoodsController extends TsaBaseController {
 	@Autowired
 	private TscMessageByLocale message;
 
+	@Autowired
+	private Environment env;
+
 	@Autowired
 	private TsaGoodsService goodsService;
 
@@ -267,7 +277,7 @@ public class TsaGoodsController extends TsaBaseController {
 		// 시즌
 		mav.addObject("seasonList", rendererService.getAvailCommonCodeList("G006"));
 		// 년도
-		mav.addObject("styleYearList", rendererService.getAvailCommonCodeList("G006"));
+		//mav.addObject("styleYearList", rendererService.getAvailCommonCodeList("G006"));
 		// 연령대
 		mav.addObject("ageGrpCdList", rendererService.getAvailCommonCodeList("G023"));
 		// 사용여부
@@ -294,21 +304,18 @@ public class TsaGoodsController extends TsaBaseController {
 	@PostMapping("/list")
 	@ResponseBody
 	public GagaMap getGoodsList(@RequestBody GoodsSearch goodsSearch) {
-		// log.debug("[getGoodsList] goodsSearch=>{}", goodsSearch);
+		log.info("[getGoodsList] goodsSearch=>{}", goodsSearch);
 		GagaMap result = new GagaMap();
 
 		// 입점업체담당자는 업체코드 설정
-//		if ("B000".equals(TsaSession.getInfo().getRoleCd())) {
-//			goodsSearch.setSupplyCompCd(TsaSession.getInfo().getSupplyCompCd());
-//			goodsSearch.setMdId(TsaSession.getInfo().getUserId());
-//		}
-
+		if ("B000".equals(TsaSession.getInfo().getRoleCd())) {
+			goodsSearch.setSupplyCompCd(TsaSession.getInfo().getSupplyCompCd());
+			goodsSearch.setMdId(TsaSession.getInfo().getUserId());
+		}
 
 		// multi row 검색관련 처리
 		if (!StringUtils.isEmpty(goodsSearch.getCondition())) {
-//			TsitUtil tsitUtil = new TsitUtil();
-//			String condition = tsitUtil.replaceMultiSelectParamsArr(goodsSearch.getCondition());
-			//goodsSearch.setConditionList(condition.split(","));
+			goodsSearch.setConditionList(goodsSearch.getCondition().replaceAll("\r", "").split("\n"));
 
 			if ("searchExtendGoodsCd".equals(goodsSearch.getSearch())) {
 				goodsSearch.setSearchGb("EXTEND");
@@ -327,6 +334,42 @@ public class TsaGoodsController extends TsaBaseController {
 		return result;
 	}
 
+	/**
+	 * 상품목록 - 기본정보 엑셀다운로드
+	 *
+	 * @param goodsSearch
+	 * @return
+	 * @author eskim
+	 * @since 2020. 10. 21
+	 */
+	@GetMapping("/info/excel/list")
+	public ResponseEntity<InputStreamResource> downloadGoodsInfoExcelList(HttpServletRequest request, GoodsSearch goodsSearch) throws Exception {
+		String excelfileName = "상품_기본정보_" + GagaDateUtil.getTodayDateTime() + ".xlsx";
+		String excelFilenameWithPath = GagaFileUtil.getConcatenationPath(env.getProperty("download.path"), "excel", excelfileName);
+
+		// 입점업체담당자는 업체코드 설정
+		if ("B000".equals(TsaSession.getInfo().getRoleCd())) {
+			goodsSearch.setSupplyCompCd(TsaSession.getInfo().getSupplyCompCd());
+			goodsSearch.setMdId(TsaSession.getInfo().getUserId());
+		}
+		goodsSearch.setRegNo(TsaSession.getInfo().getUserNo()); // 엑셀조회시 로그인 사용자의 엑셀 상품조회시 사용
+
+		// multi row 검색관련 처리
+		if (!StringUtils.isEmpty(goodsSearch.getCondition())) {
+			goodsSearch.setConditionList(goodsSearch.getCondition().replaceAll("\r", "").split("\n"));
+
+			if ("searchExtendGoodsCd".equals(goodsSearch.getSearch())) {
+				goodsSearch.setSearchGb("EXTEND");
+			} else if ("searchMasterGoodsCd".equals(goodsSearch.getSearch())) {
+				goodsSearch.setSearchGb("MASTER");
+			}
+		}
+
+		// 대용량엑셀파일다운로드는 이런 식으로 ...
+		goodsService.getGoodsInfoExcelList(goodsSearch, excelFilenameWithPath);
+
+		return GagaFileUtil.writeFile(request, excelFilenameWithPath);
+	}
 	/**
 	 * 상품 대량 등록 화면
 	 *

+ 3 - 1
style24.admin/src/main/java/com/style24/admin/support/env/TsaConstants.java

@@ -2,7 +2,7 @@ package com.style24.admin.support.env;
 
 /**
  * 변경될 소지가 있는 변수 값을 정의
- * 
+ *
  * @author gagamel
  * @since 2020. 10. 5
  */
@@ -11,4 +11,6 @@ public class TsaConstants {
 	// 사이트코드
 	public static final String SITE_CD = "10";
 
+	public static final String EXCEL_FOOTER_TITLE = "Copyright(c) 2020 STYLE24, All rights reserved.";
+
 }

+ 2 - 0
style24.admin/src/main/java/com/style24/persistence/domain/GoodsSearch.java

@@ -50,6 +50,7 @@ public class GoodsSearch extends TsaBaseDomain {
 	private String stockQtySt;
 	private String stockQtyEd;
 	private String cateCd;
+	private String ageGrpCd;
 
 	private String regSuccYn;
 	private String searchGb;
@@ -94,4 +95,5 @@ public class GoodsSearch extends TsaBaseDomain {
 
 	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
 	private String[] conditionList;
+
 }

+ 21 - 17
style24.admin/src/main/java/com/style24/persistence/mybatis/shop/TsaGoods.xml

@@ -226,8 +226,8 @@
 		                           WHERE REG_NO = #{regId}
 		                           GROUP BY SEARCH_CD) T
 		                   ) SD
-		                   ON ( (G.GOODS_CD LIKE SD.SEARCH_CD||'%'
-		                        OR G.SUPPLY_GOODS_CD LIKE SD.SEARCH_CD||'%') 
+		                   ON ( (G.GOODS_CD LIKE CONCAT(SD.SEARCH_CD,'%')
+		                        OR G.SUPPLY_GOODS_CD LIKE CONCAT(SD.SEARCH_CD,'%')) 
 		                        <if test="mdId != null and mdId != ''">
 		                        AND G.BRAND_CD IN (
 		                                           SELECT DISTINCT BRAND_CD
@@ -334,8 +334,8 @@
 		                           WHERE REG_NO = #{regId}
 		                           GROUP BY SEARCH_CD) T
 		                   ) SD
-		                   ON ( (G.GOODS_CD LIKE SD.SEARCH_CD||'%'
-		                        OR G.SUPPLY_GOODS_CD LIKE SD.SEARCH_CD||'%') 
+		                   ON ( (G.GOODS_CD LIKE CONCAT(SD.SEARCH_CD,'%')
+		                        OR G.SUPPLY_GOODS_CD LIKE CONCAT(SD.SEARCH_CD,'%')) 
 		                        <if test="mdId != null and mdId != ''">
 		                        AND G.BRAND_CD IN (
 		                                           SELECT DISTINCT BRAND_CD
@@ -364,21 +364,21 @@
 		              <when test='search != null and search == "searchGoodsCd"'>
 		        AND (
 		              <foreach collection="conditionList" item="item" index="index" separator="or">
-		               REGEXP_LIKE(UPPER(G.GOODS_CD), UPPER(#{item}))
+		               UPPER(G.GOODS_CD) LIKE CONCAT('%',UPPER(#{item}),'%') 
 		              </foreach>
 		             )
 		              </when>
 		              <when test='search != null and search == "searchGoodsNum"'>
 		        AND (
 		              <foreach collection="conditionList" item="item" index="index" separator="or">
-		               REGEXP_LIKE(UPPER(G.GOODS_NUM), UPPER(#{item}))
+		               UPPER(G.GOODS_NUM) LIKE CONCAT('%',UPPER(#{item}),'%')
 		              </foreach>
 		             )
 		              </when>
 		              <when test='search != null and search == "searchSupplyGoodsCd"'>
 		        AND (
 		              <foreach collection="conditionList" item="item" index="index" separator="or">
-		               REGEXP_LIKE(UPPER(G.SUPPLY_GOODS_CD), UPPER(#{item}))
+		               UPPER(G.SUPPLY_GOODS_CD) LIKE CONCAT('%',UPPER(#{item}),'%')
 		              </foreach>
 		             )
 		              </when>
@@ -389,15 +389,15 @@
 		        AND 1 = 1
 		              </when>
 		              <otherwise>
-		        AND UPPER(G.REG_ID) LIKE UPPER('%' || #{condition} || '%')
+		        AND UPPER(G.REG_ID) LIKE CONCAT('%',UPPER(#{item}),'%')
 		              </otherwise>
 		            </choose>
 		        </if>
 		        <if test="goodsCd != null and goodsCd != ''">
-		        AND UPPER(G.GOODS_CD) LIKE UPPER('%' || #{goodsCd} || '%')
+		        AND UPPER(G.GOODS_CD) LIKE CONCAT('%',UPPER(#{goodsCd}),'%')
 		        </if>
 		         <if test="goodsNm != null and goodsNm != ''">
-		        AND UPPER(G.GOODS_NM) LIKE UPPER('%' || #{goodsNm} || '%')
+		        AND UPPER(G.GOODS_NM) LIKE CONCAT('%',UPPER(#{goodsNm}),'%')
 		        </if>
 		         <if test="goodsType != null and goodsType != ''">
 		        AND G.GOODS_TYPE = #{goodsType}
@@ -525,31 +525,31 @@
 		        </if>
 		        <if test='dateGbn != null and dateGbn == "P"'>
 		            <if test="stDate != null and stDate != ''">
-		        AND G.PRICE_UPD_DT >= TO_DATE(#{stDate}, 'YYYY-MM-DD')
+		        AND G.PRICE_UPD_DT >= DATE_FORMAT(#{stDate}, '%Y-%m-%d %H:%i:%S')
 		            </if>
 		            <if test="edDate != null and edDate != ''">
 		            <![CDATA[
-		        AND G.PRICE_UPD_DT <= TO_DATE(#{edDate}, 'YYYY-MM-DD')  + 0.99999
+		        AND G.PRICE_UPD_DT < DATE_FORMAT(DATE_ADD(#{edDate}, INTERVAL 1 DAY), '%Y-%m-%d %H:%i:%S')
 		            ]]>
 		            </if>
 		        </if>
 		        <if test='dateGbn != null and dateGbn == "R"'>
 		            <if test="stDate != null and stDate != ''">
-		        AND G.REG_DT >= TO_DATE(#{stDate}, 'YYYY-MM-DD')
+		        AND G.REG_DT >= DATE_FORMAT(#{stDate}, '%Y-%m-%d %H:%i:%S')
 		            </if>
 		            <if test="edDate != null and edDate != ''">
 		            <![CDATA[
-		        AND G.REG_DT <= TO_DATE(#{edDate}, 'YYYY-MM-DD')  + 0.99999
+		        AND G.REG_DT < DATE_FORMAT(DATE_ADD(#{edDate}, INTERVAL 1 DAY), '%Y-%m-%d %H:%i:%S')
 		            ]]>
 		            </if>
 		        </if>
-		         <if test='dateGbn != null and dateGbn == "S"'>
+		        <if test='dateGbn != null and dateGbn == "S"'>
 		            <if test="stDate != null and stDate != ''">
-		        AND G.APPR_UPD_DT >= TO_DATE(#{stDate}, 'YYYY-MM-DD')
+		        AND G.APPR_UPD_DT >= DATE_FORMAT(#{stDate}, '%Y-%m-%d %H:%i:%S')
 		            </if>
 		            <if test="edDate != null and edDate != ''">
 		            <![CDATA[
-		        AND G.APPR_UPD_DT <= TO_DATE(#{edDate}, 'YYYY-MM-DD')  + 0.99999
+		        AND G.APPR_UPD_DT < DATE_FORMAT(DATE_ADD(#{edDate}, INTERVAL 1 DAY), '%Y-%m-%d %H:%i:%S')
 		            ]]>
 		            </if>
 		        </if>
@@ -561,6 +561,9 @@
 		        AND ST.CURR_STOCK_QTY <= #{stockQtyEd}
 		        ]]>
 		        </if>
+		        <if test="ageGrpCd != null and ageGrpCd != ''">
+		        AND G.AGE_GRP_CD = #{ageGrpCd}
+		        </if>
 	</sql>
 	
 	<!-- 목록 페이징 정보 -->
@@ -576,4 +579,5 @@
 		</otherwise>
 		</choose>
 	</sql>
+	
 </mapper>

+ 1 - 1
style24.admin/src/main/webapp/WEB-INF/views/goods/GoodsListForm.html

@@ -555,7 +555,7 @@
 		var cnt = 0;
 
 		if( !gagajf.isNull($("#searchForm select[name=supplyCompCd]").val())
-				|| !gagajf.isNull($("#searchForm input[name=condition]").val())
+				|| !gagajf.isNull($("#searchForm textarea[name=condition]").val())
 				|| (!gagajf.isNull($("#searchForm input[name=stDate]").val()) && !gagajf.isNull($("#searchForm input[name=edDate]").val()))
 				|| !gagajf.isNull($("#searchForm select[name=brandGrpNm]").val())
 			){