Files
wace_plm/src/com/pms/service/ProductMgmtService.java
hjjeong ea5c6d53a7 fix: 엑셀 파일 경로 구분자를 File.separator로 변경 (Linux 환경 FileNotFoundException 수정)
Windows 백슬래시(\) 하드코딩으로 Linux 환경에서 파일을 찾지 못하는 버그 수정
- 11개 파일, 15군데 path+"\\"+fileName → path + File.separator + fileName
- File import 누락된 4개 파일에 import 추가

Made-with: Cursor
2026-03-03 13:41:21 +09:00

1245 lines
37 KiB
Java

package com.pms.service;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.ibatis.session.SqlSession;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pms.common.JsonUtil;
import com.pms.common.Message;
import com.pms.common.SqlMapConfig;
import com.pms.common.bean.PersonBean;
import com.pms.common.utils.CommonUtils;
import com.pms.common.utils.Constants;
@Service
public class ProductMgmtService {
CommonService commonService = null;
@Autowired
ProductionMngService productionMngService;
@Autowired
public void setCommonService(CommonService commonService){
this.commonService = commonService;
}
/**
* 제품마스터 목록 조회
* @param paramMap
* @return
*/
public List getProductMgntList(HttpServletRequest request,Map paramMap){
List<Map<String,Object>> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
Map pageMap = (HashMap)sqlSession.selectOne("product.productMgmtListCnt", paramMap);
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
paramMap.put("PAGE_END", CommonUtils.checkNull(pageMap.get("PAGE_END")));
paramMap.put("PAGE_START", CommonUtils.checkNull(pageMap.get("PAGE_START")));
resultList = (ArrayList)sqlSession.selectList("product.productMgmtList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.toUpperCaseMapKey(resultList);
}
/**
* 제품마스터 상세조회
* @param paramMap
* @return
*/
public Map getProductMgntInfo(Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultMap = sqlSession.selectOne("product.getproductMgmtInfo", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.toUpperCaseMapKey(resultMap);
}
/**
* 제품마스터 제원
* @param paramMap
* @return
*/
public List SpecificationList(HttpServletRequest request, Map paramMap){
List resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = sqlSession.selectList("product.specificationList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.toUpperCaseMapKey(resultList);
}
/** 제품마스터 저장
* @param request
* @param paramMap
* @return
*/
public Map saveproductMgmtInfo(HttpServletRequest request, Map paramMap){
Map resultMap = new HashMap();
Map resultList = null;
Map tempMap = null;
SqlSession sqlSession = null;
String code_id = null;
String First_cd = null;
String Mid_cd = null;
String final_cd = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
//0000069
resultList = sqlSession.selectOne("product.getproductspecList", paramMap);
//
//standardWBSTaskList = getStandardWBSTask(sqlSession, request, paramMap);
if(resultList==null){
List standardSpecList = new ArrayList();
standardSpecList = (ArrayList)sqlSession.selectList("product.standardSpecList", paramMap);
if(standardSpecList.size() > 0 ){
for(int i=0;i<standardSpecList.size();i++){
Map SpecMap = CommonUtils.keyChangeUpperMap((HashMap)standardSpecList.get(i));
Map sqlMap = new HashMap();
sqlMap.put("objid", CommonUtils.createObjId());
sqlMap.put("target_objid", (String)paramMap.get("objId"));
sqlMap.put("spec_text", (String)SpecMap.get("CODE_NAME"));
sqlMap.put("writer", person.getUserId());
sqlMap.put("order_no", (String)SpecMap.get("RNUM"));
sqlSession.update("product.insertProductSpec", sqlMap);
}
}
}
paramMap.put("writer", person.getUserId());
String filepath = Constants.FILE_STORAGE+"\\PART_DATA\\"+(String)paramMap.get("product_code");
//폴더생성
File storage = new File(filepath);
if(!storage.exists()) storage.mkdirs();
code_id = (String)paramMap.get("product_category");
paramMap.put("code_id", code_id);
tempMap = sqlSession.selectOne("product.getCodeExt_val", paramMap);
First_cd = (String)tempMap.get("ext_val");
code_id = (String)paramMap.get("product_type");
paramMap.put("code_id", code_id);
tempMap = sqlSession.selectOne("product.getCodeExt_val", paramMap);
Mid_cd = (String)tempMap.get("ext_val");
final_cd = First_cd + "_" + Mid_cd + "_" + (String)paramMap.get("product_name_code");
paramMap.put("product_code", final_cd);
System.out.println("final_cd :: " + final_cd);
int cnt = sqlSession.update("product.mergeproductMgmtInfo", paramMap);
paramMap.put("priceobjid", CommonUtils.createObjId());
cnt = sqlSession.insert("product.insertProductPriceHistory", paramMap);
if(cnt > 0){
resultMap.put("result", true);
resultMap.put("msg", Message.SAVE_SUCCESS);
}
sqlSession.commit();
}catch(Exception e){
sqlSession.rollback();
resultMap.put("result", false);
resultMap.put("msg", Message.SAVE_FAILED);
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultMap;
}
/** 제품마스터 저장 전 중복여부를 확인한다.
* @param request
* @param paramMap
* @return
*/
public Map checkDuplicateProductMgmt(HttpServletRequest request, Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
resultMap = sqlSession.selectOne("product.checkDuplicateProductMgmt", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultMap;
}
/**
* 제품마스터 물리적 삭제
* @param request
* @param paramMap
* @return
*/
public Map productDelete(HttpServletRequest request,Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
try{
String partCheckBoxList[] = request.getParameter("productobjid").split(",");
if(null != partCheckBoxList && 0 < partCheckBoxList.length){
for(int i=0;i<partCheckBoxList.length;i++){
String Objid = CommonUtils.checkNull(partCheckBoxList[i]);
HashMap sqlParamMap = new HashMap();
sqlParamMap.put("objId", Objid);
//등뢱된 BOM 삭제
//sqlSession.delete("product.productMasterPartBomDelete",sqlParamMap);
//등록된 PART삭제
//sqlSession.delete("product.productMasterPartDelete",sqlParamMap);
//UPG DETAIL 삭제
//sqlSession.delete("product.productMasterUpgdetailDelete",sqlParamMap);
//UPG MASTER 삭제
//sqlSession.delete("product.productMasterUpgmasterDelete",sqlParamMap);
//제품마스터 삭제
sqlSession.delete("product.productDelete",sqlParamMap);
}
sqlSession.commit();
resultMap.put("result", true);
resultMap.put("msg", Message.DELETE_SUCCESS);
}
}catch(Exception e){
resultMap.put("result", false);
resultMap.put("msg", Message.DELETE_FAILED);
sqlSession.rollback();
throw e;
}finally{
sqlSession.close();
}
return resultMap;
}
/**
* UPG 및 PART등록정보 삭제
* @param request
* @param paramMap
* @return
*/
public Map productUpgListDelete(HttpServletRequest request,Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
String materCheckBoxList[] = request.getParameter("master_objid").split(",");
String detailCheckBoxList[] = request.getParameter("detail_objid").split(",");
try{
System.out.println("materCheckBoxList.length --->"+materCheckBoxList.length);
System.out.println("detailCheckBoxList.length --->"+detailCheckBoxList.length);
if(null != materCheckBoxList && 0 < materCheckBoxList.length){
for(int i=0;i<materCheckBoxList.length;i++){
String Objid = CommonUtils.checkNull(materCheckBoxList[i]);
HashMap sqlParamMap = new HashMap();
sqlParamMap.put("objId", Objid);
if(!"".equals(Objid)){
productUpgDelete(request,sqlParamMap);
}
}
resultMap.put("result", true);
resultMap.put("msg", Message.DELETE_SUCCESS);
}
if(null != detailCheckBoxList && 0 < detailCheckBoxList.length){
for(int i=0;i<detailCheckBoxList.length;i++){
String upg_name = CommonUtils.checkNull(detailCheckBoxList[i]);
String rootobjid = CommonUtils.checkNull(paramMap.get("rootObjid"));
HashMap sqlParamMap = new HashMap();
sqlParamMap.put("upg_name", upg_name);
sqlParamMap.put("rootobjid", rootobjid);
if(!"".equals(upg_name)){
//UPG DETAIL 삭제
sqlSession.update("product.productUpgVcupdate",sqlParamMap);
}
}
sqlSession.commit();
resultMap.put("result", true);
resultMap.put("msg", Message.DELETE_SUCCESS);
}
}catch(Exception e){
resultMap.put("result", false);
resultMap.put("msg", Message.DELETE_FAILED);
sqlSession.rollback();
throw e;
}finally{
sqlSession.close();
}
return resultMap;
}
/**
* UPG 및 PART등록정보 삭제
* @param request
* @param paramMap
* @return
*/
public Map productUpgDelete(HttpServletRequest request,Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
try{
//등뢱된 BOM 삭제
sqlSession.delete("product.productPartBomDelete",paramMap);
//등록된 PART삭제
sqlSession.delete("product.productPartDelete",paramMap);
//UPG DETAIL 삭제
sqlSession.delete("product.productUpgdetailDelete",paramMap);
//UPG MASTER 삭제
sqlSession.delete("product.productUpgmasterDelete",paramMap);
sqlSession.commit();
resultMap.put("result", true);
resultMap.put("msg", Message.DELETE_SUCCESS);
}catch(Exception e){
resultMap.put("result", false);
resultMap.put("msg", Message.DELETE_FAILED);
sqlSession.rollback();
throw e;
}finally{
sqlSession.close();
}
return resultMap;
}
/**
* 제품 활성화 상태로 변경
* @param request
* @param paramMap
* @return
*/
public Map changeMultiPartStatus(HttpServletRequest request,Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
try{
String partCheckBoxList[] = request.getParameterValues("partCheckBox");
if(null != partCheckBoxList && 0 < partCheckBoxList.length){
for(int i=0;i<partCheckBoxList.length;i++){
String partObjid = CommonUtils.checkNull(partCheckBoxList[i]);
HashMap sqlParamMap = new HashMap();
sqlParamMap.put("objId", partObjid);
sqlSession.update("product.changeMultiPartStatus",sqlParamMap);
}
sqlSession.commit();
resultMap.put("result", true);
resultMap.put("msg", Message.SAVE_SUCCESS);
}
}catch(Exception e){
resultMap.put("result", false);
resultMap.put("msg", Message.SAVE_FAILED);
sqlSession.rollback();
throw e;
}finally{
sqlSession.close();
}
return resultMap;
}
/**
* 업로드된 Excel File을 통해 데이터를 Parsing 한다.
* @param request
* @param paramMap
* @return
*/
public ArrayList parsingExcelFile(HttpServletRequest request,Map paramMap)throws Exception{
ArrayList resultList = new ArrayList();
ArrayList fileList = commonService.getFileList(paramMap);
if(null != fileList && 1 == fileList.size()){
HashMap fileMap = (HashMap)fileList.get(0);
String path = CommonUtils.checkNull(fileMap.get("FILE_PATH"));
String fileName = CommonUtils.checkNull(fileMap.get("SAVED_FILE_NAME"));
System.out.println("fileName ---------------->"+fileName);
System.out.println("fileName ---------------->"+fileName);
System.out.println("fileName ---------------->"+fileName);
FileInputStream fis = new FileInputStream(path + File.separator + fileName);
XSSFWorkbook workBook = new XSSFWorkbook(fis);
FormulaEvaluator formulaEval = workBook.getCreationHelper().createFormulaEvaluator();
XSSFSheet sheet = workBook.getSheetAt(0);
// 데이터 포멧터
DataFormatter formatter = new DataFormatter();
int rows = sheet.getPhysicalNumberOfRows();
for(int rowIndex= 1 ; rowIndex < rows ; rowIndex++){
XSSFRow row = sheet.getRow(rowIndex);
if(null != row){
HashMap partMap = new HashMap();
for(int columnIndex = 0 ; columnIndex < 21 ; columnIndex++){
XSSFCell cell = row.getCell(columnIndex);
//데이버 유형별 get date
String cellValue = "";
if(null == cell){
cellValue = "";
}else{
switch(cell.getCellType()){
case XSSFCell.CELL_TYPE_FORMULA:
CellValue evaluate = formulaEval.evaluate(cell);
if(15 == columnIndex){
System.out.println("****************************");
cellValue = Integer.toString((int)cell.getNumericCellValue());
System.out.println("cellValue1:"+cellValue);
}else{
cellValue = evaluate.formatAsString();
if(!"#N/A".equals(cellValue)){
cellValue = cell.getStringCellValue();
}
}
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_FORMULA_____:"+cellValue);
break;
case XSSFCell.CELL_TYPE_NUMERIC:
cellValue = formatter.formatCellValue(cell);
/* if(7 == columnIndex){
cellValue = cell.getNumericCellValue()+"";
//cellValue = String.format("%.2f", Double.parseDouble(cellValue));
System.out.println("cellValue1:"+cellValue);
}else{
cellValue = cell.getNumericCellValue()+"";
System.out.println("cellValue2:"+cellValue);
}*/
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_NUMERIC:"+cellValue);
break;
case XSSFCell.CELL_TYPE_STRING:
cellValue = cell.getStringCellValue()+"";
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_STRING:"+cellValue);
break;
case XSSFCell.CELL_TYPE_BLANK:
cellValue = cell.getBooleanCellValue()+"";
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_BLANK:"+cellValue);
break;
case XSSFCell.CELL_TYPE_ERROR:
cellValue = cell.getErrorCellValue()+"";
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_ERROR:"+cellValue);
break;
}
}
if("false".equals(cellValue)){
cellValue = "";
}
//품번
/*if(0 == columnIndex){
int duplicateCnt = 0;
if(null != cellValue){
paramMap.put("PART_NAME", cellValue);
paramMap.put("targetObjId", "");
ArrayList duplicateList = new ArrayList();
duplicateList = (ArrayList)getDuplicatePartList(request, paramMap);
if(0 < duplicateList.size()){
for(int i=0;i<duplicateList.size();i++){
HashMap duplicateMap = (HashMap)duplicateList.get(i);
String status = CommonUtils.checkNull(duplicateMap.get("STATUS"));
*//**
* 상태가 complete인 것이 있는 경우 Revision을 통해 등록해야하며
* Revision의 경우 Revision code등 일부 정보를 제외하고 수정 할 수 없다.
*//*
if(status.equals("complete") || status.equals("revision")){
duplicateCnt++;
}
}
}
}
partMap.put("partDuplicate", duplicateCnt);
partMap.put("partNo", cellValue);
}*/
//0고객발주Code
if(0 == columnIndex){
if("".equals(cellValue)){
break;
}
partMap.put("ORDER_NO", cellValue);
}
//1고객제품번호
if(1 == columnIndex){
partMap.put("PRODUCT_NO", cellValue);
}
//2DHIS제품번호
if(2 == columnIndex){
partMap.put("DHISPRODUCT_NO", cellValue);
}
//3 SPEC
if(3 == columnIndex){
partMap.put("SPEC", cellValue);
}
//4 WEIGHT
if(4 == columnIndex){
partMap.put("WEIGHT", cellValue);
}
//5 고객명
if(5 == columnIndex){
if("LSE".equals(cellValue)){
cellValue ="CUST_CD01";
}else if("현대".equals(cellValue)){
cellValue ="CUST_CD02";
}else if("재룡".equals(cellValue)){
cellValue ="CUST_CD03";
}else if("ABB".equals(cellValue)){
cellValue ="CUST_CD04";
}else if("기타".equals(cellValue)){
cellValue ="CUST_CD05";
}
partMap.put("CUSTOMER_CD", cellValue);
}
//6수주제품
if(6 == columnIndex){
if("ODM".equals(cellValue)){
cellValue ="ITEM_CD01";
}else if("저압코일".equals(cellValue)){
cellValue ="ITEM_CD02";
}else if("고압코일".equals(cellValue)){
cellValue ="ITEM_CD03";
}else if("코어아세이".equals(cellValue)){
cellValue ="ITEM_CD04";
}else if("완제품".equals(cellValue)){
cellValue ="ITEM_CD05";
}
partMap.put("ITEM_CD", cellValue);
}
//7상수
if(7 == columnIndex){
if("단상".equals(cellValue)){
cellValue ="PHASE_CD01";
}else if("3상".equals(cellValue)){
cellValue ="PHASE_CD02";
}else if("사양불명확".equals(cellValue)){
cellValue ="PHASE_CD03";
}
partMap.put("PHASE_CD", cellValue);
}
//8주파수
if(8 == columnIndex){
if("50 Hz".equals(cellValue)){
cellValue ="FRE_CD01";
}else if("60 Hz".equals(cellValue)){
cellValue ="FRE_CD02";
}else if("사양불명확".equals(cellValue)){
cellValue ="FRE_CD03";
}
partMap.put("FREQUENCY_CD", cellValue);
}
//9
if(9 == columnIndex){
partMap.put("CAPACITY", cellValue);
}
//10
if(10 == columnIndex){
if("1.1 Kv".equals(cellValue)){
cellValue ="PD_CD1000";
}else if("3.6 Kv".equals(cellValue)){
cellValue ="PD_CD1001";
}else if("7.2 Kv".equals(cellValue)){
cellValue ="PD_CD1002";
}else if("12.0 Kv".equals(cellValue)){
cellValue ="PD_CD1003";
}else if("17.5 Kv".equals(cellValue)){
cellValue ="PD_CD1004";
}else if("24.0 Kv".equals(cellValue)){
cellValue ="PD_CD1005";
}else if("36.0 Kv".equals(cellValue)){
cellValue ="PD_CD1006";
}
partMap.put("CODE1", cellValue);
}
//11 2차전압
if(11 == columnIndex){
partMap.put("SEC_VOLT", cellValue);
}
//12 결선
if(12 == columnIndex){
if("Dyn1".equals(cellValue)){
cellValue ="PD_CD2000";
}else if("Dyn5".equals(cellValue)){
cellValue ="PD_CD2001";
}else if("Dyn11".equals(cellValue)){
cellValue ="PD_CD2002";
}else if("Dd0".equals(cellValue)){
cellValue ="PD_CD2003";
}else if("YNd1".equals(cellValue)){
cellValue ="PD_CD2004";
}else if("YNyn0".equals(cellValue)){
cellValue ="PD_CD2005";
}else if("사양불명확".equals(cellValue)){
cellValue ="PD_CD2007";
}
partMap.put("CODE2", cellValue);
}
//임피던스
if(13 == columnIndex){
partMap.put("IMPEDANCE", cellValue);
}
//도체
if(14 == columnIndex){
if("AL_Single".equals(cellValue)){
cellValue ="PD_CD3000";
}else if("AL_Double".equals(cellValue)){
cellValue ="PD_CD3001";
}else if("CU_Single".equals(cellValue)){
cellValue ="PD_CD3002";
}else if("CU_Double".equals(cellValue)){
cellValue ="PD_CD3003";
}
partMap.put("CODE3", cellValue);
}
//디지털온도계(코드)
if(15 == columnIndex){
if("P-100C".equals(cellValue)){
cellValue ="PD_CD4000";
}else if("P-300C".equals(cellValue)){
cellValue ="PD_CD4001";
}else if("없음".equals(cellValue)){
cellValue ="PD_CD4002";
}
partMap.put("CODE4", cellValue);
}
//냉각팬(코드)
if(16 == columnIndex){
if("AC-150B, 4개".equals(cellValue)){
cellValue ="PD_CD5000";
}else if("AC-150B, 6개".equals(cellValue)){
cellValue ="PD_CD5001";
}else if("DICS-9504, 4개".equals(cellValue)){
cellValue ="PD_CD5002";
}else if("DICS-9504, 6개".equals(cellValue)){
cellValue ="PD_CD5003";
}else if("DISD-133, 6개".equals(cellValue)){
cellValue ="PD_CD5004";
}else if("없음".equals(cellValue)){
cellValue ="PD_CD5005";
}
partMap.put("CODE5", cellValue);
}
//외함(코드)
if(17 == columnIndex){
if("".equals(cellValue)){
cellValue ="PD_CD6000";
}else if("".equals(cellValue)){
cellValue ="PD_CD6001";
}
partMap.put("CODE6", cellValue);
}
//효율(코드)
if(18 == columnIndex){
if("표준소비".equals(cellValue)){
cellValue ="PD_CD7000";
}else if("최저소비".equals(cellValue)){
cellValue ="PD_CD7001";
}else if("사양불명확".equals(cellValue)){
cellValue ="PD_CD7002";
}
partMap.put("CODE7", cellValue);
}
//절연등급(코드)
if(19 == columnIndex){
if("B Class".equals(cellValue)){
cellValue ="PD_CD8000";
}else if("F Class".equals(cellValue)){
cellValue ="PD_CD8001";
}else if("H Class".equals(cellValue)){
cellValue ="PD_CD8002";
}else if("H사양불명확".equals(cellValue)){
cellValue ="PD_CD8003";
}
partMap.put("CODE8", cellValue);
}
//상태
if(20 == columnIndex){
if("활성화".equals(cellValue)){
cellValue ="STS_CD1";
}else if("비활성화".equals(cellValue)){
cellValue ="STS_CD2";
}
partMap.put("STATUS_CD", cellValue);
resultList.add(partMap);
System.out.println("partMap:"+partMap);
break;
}
}
}
}
}
return resultList;
}
public void productApplySave(HttpServletRequest request,Map paramMap){
SqlSession sqlSession = null;
try{
List<Map<String, Object>> gridDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("jqGrid")));
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
byte[] buf = new byte[1024];
for(int i=0; i<gridDataList.size(); i++){
Map insertMap = gridDataList.get(i);
Map fileMap = new HashMap();
String PRODUCT_OBJID = CommonUtils.createObjId();
insertMap.put("objId", PRODUCT_OBJID);
insertMap.put("order_no", CommonUtils.nullToEmpty((String)insertMap.get("ORDER_NO")));
insertMap.put("product_no", CommonUtils.nullToEmpty((String)insertMap.get("PRODUCT_NO")));
insertMap.put("dhisproduct_no", CommonUtils.nullToEmpty((String)insertMap.get("DHISPRODUCT_NO")));
insertMap.put("spec", CommonUtils.nullToEmpty((String)insertMap.get("SPEC")));
insertMap.put("customer_cd", CommonUtils.nullToEmpty((String)insertMap.get("CUSTOMER_CD")));
insertMap.put("item_cd", CommonUtils.nullToEmpty((String)insertMap.get("ITEM_CD")));
insertMap.put("phase_cd", CommonUtils.nullToEmpty((String)insertMap.get("PHASE_CD")));
insertMap.put("frequency_cd", CommonUtils.nullToEmpty((String)insertMap.get("FREQUENCY_CD")));
insertMap.put("capacity", CommonUtils.nullToEmpty((String)insertMap.get("CAPACITY")));
insertMap.put("sec_volt", CommonUtils.nullToEmpty((String)insertMap.get("SEC_VOLT")));
insertMap.put("impedance", CommonUtils.nullToEmpty((String)insertMap.get("IMPEDANCE")));
insertMap.put("code1", CommonUtils.nullToEmpty((String)insertMap.get("CODE1")));
insertMap.put("code2", CommonUtils.nullToEmpty((String)insertMap.get("CODE2")));
insertMap.put("code3", CommonUtils.nullToEmpty((String)insertMap.get("CODE3")));
insertMap.put("code4", CommonUtils.nullToEmpty((String)insertMap.get("CODE4")));
insertMap.put("code5", CommonUtils.nullToEmpty((String)insertMap.get("CODE5")));
insertMap.put("code6", CommonUtils.nullToEmpty((String)insertMap.get("CODE6")));
insertMap.put("code7", CommonUtils.nullToEmpty((String)insertMap.get("CODE7")));
insertMap.put("code8", CommonUtils.nullToEmpty((String)insertMap.get("CODE8")));
insertMap.put("status_cd", CommonUtils.nullToEmpty((String)insertMap.get("STATUS_CD")));
insertMap.put("userId", (String)paramMap.get("CONNECTUSERID"));
//제품마스터 저장
sqlSession.update("product.mergeproductMgmtInfo", insertMap);
}
sqlSession.commit();
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
}
public List ajxProductmgmtList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.productMgmtList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultList;
}
/**
* 제품 사양 목록 조회
* @param paramMap
* @return
*/
public List getProductMgntUpgList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
Map pageMap = (HashMap)sqlSession.selectOne("product.productMgmtUpgListCnt", paramMap);
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
paramMap.put("PAGE_END", CommonUtils.checkNull(pageMap.get("PAGE_END")));
paramMap.put("PAGE_START", CommonUtils.checkNull(pageMap.get("PAGE_START")));
resultList = (ArrayList)sqlSession.selectList("product.productMgmtUpgList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultList;
}
/**
* 제품사양 제품 양산코드 리스트
* @param paramMap
* @return
*/
public List getProductUpgCodeList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getProductUpgCodeList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
/**
* UPG 제품코드 리스트
* @param paramMap
* @return
*/
public List getProductUpgcommcodeList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getProductUpgcommcodeList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
/**
* upg matrix
* @param paramMap
* @return
*/
public List getUpgMatrixList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getUpgMatrixList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
/**
* upg matrix
* @param paramMap
* @return
*/
public List getUpgOneMatrixList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getUpgOneMatrixList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
/**
* UPg COde리스트 조회
* @param paramMap
* @return
*/
public List getProductUpgDetailList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getProductUpgDetailList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
/**
* UPG Commcode 리스트
* @param paramMap
* @return
*/
public List UpgCodeList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getUpgCodeList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
/**
* 제품 사양 상세조회
* @param paramMap
* @return
*/
public Map getProductMgntUpgInfo(Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultMap = sqlSession.selectOne("product.productMgmtUpgInfo", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperMap(resultMap);
}
/** 제품사양 저장
* @param request
* @param paramMap
* @return
*/
public Map saveproductMgmtUpgInfo(HttpServletRequest request, Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
String objId = CommonUtils.checkNull(paramMap.get("objId"));
if("".equals(objId)){
objId = CommonUtils.createObjId();
}
paramMap.put("objId", objId);
int cnt = sqlSession.update("product.saveproductMgmtUpgInfo", paramMap);
if(cnt > 0){
resultMap.put("result", true);
resultMap.put("msg", Message.SAVE_SUCCESS);
}
sqlSession.commit();
}catch(Exception e){
sqlSession.rollback();
resultMap.put("result", false);
resultMap.put("msg", Message.SAVE_FAILED);
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultMap;
}
/**
* 제품마스터 스펙 저장
* @param request
* @param paramMap
* @return
*/
public void SpecificationFormSave(HttpServletRequest request,Map paramMap){
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
try{
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
sqlSession.insert("product.updateSpecification",paramMap);
// String spec_text[] = request.getParameterValues("spec_text");
// String spec_value[] = request.getParameterValues("spec_value");
// String order_no[] = request.getParameterValues("order_no");
//
// sqlSession.delete("product.DeleteSpecification",paramMap);
//
//
//
// if(null != spec_text && 0 < spec_text.length){
// for(int i=0;i<spec_text.length;i++){
// HashMap sqlParamMap = new HashMap();
// sqlParamMap.put("objId", CommonUtils.createObjId());
// sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
// sqlParamMap.put("writer", person.getUserId());
// sqlParamMap.put("spec_text", CommonUtils.checkNull(spec_text[i]));
// sqlParamMap.put("spec_value", CommonUtils.checkNull(spec_value[i]));
// sqlParamMap.put("order_no", CommonUtils.checkNull(order_no[i]));
// sqlSession.insert("product.insertSpecification",sqlParamMap);
// }
// sqlSession.commit();
// }
sqlSession.commit();
}catch(Exception e){
sqlSession.rollback();
throw e;
}finally{
sqlSession.close();
}
}
/**
* 제품사양 상세 정보 저장
* @param request
* @param paramMap
* @return
*/
public void saveproductMgmtUpg(HttpServletRequest request,Map paramMap){
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
try{
HashMap mastermap = new HashMap();
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
String objid = CommonUtils.nvl((String)paramMap.get("objId"),CommonUtils.createObjId());
String targetobjId = CommonUtils.checkNull(paramMap.get("targetobjId"));
String specname = CommonUtils.checkNull(paramMap.get("product_upg_name"));
String detailobjid[] = request.getParameterValues("detailobjid");
String upgname[] = request.getParameterValues("upgname");
String upgcode[] = request.getParameterValues("upgcode");
String vc[] = request.getParameterValues("vc");
String note[] = request.getParameterValues("note");
String product_objid[] = request.getParameterValues("product_objid");
mastermap.put("objId", objid);
mastermap.put("targetobjId", targetobjId);
mastermap.put("specname", specname);
mastermap.put("writer", person.getUserId());
sqlSession.insert("product.insertUpgMaster",mastermap);
if(null != upgname && 0 < upgname.length){
for(int i=0;i<upgname.length;i++){
HashMap sqlParamMap = new HashMap();
sqlParamMap.put("objId", CommonUtils.nvl((detailobjid[i]),CommonUtils.createObjId()));
sqlParamMap.put("targetobjId", CommonUtils.checkNull(objid));
sqlParamMap.put("upgname", CommonUtils.checkNull(upgname[i]));
sqlParamMap.put("upgcode", CommonUtils.checkNull(upgcode[i]));
sqlParamMap.put("vc", CommonUtils.checkNull(vc[i]));
sqlParamMap.put("note", CommonUtils.checkNull(note[i]));
sqlParamMap.put("product_objid", CommonUtils.nvl((product_objid[i]),targetobjId));
sqlSession.insert("product.insertUpgDetail",sqlParamMap);
}
sqlSession.commit();
}
}catch(Exception e){
sqlSession.rollback();
throw e;
}finally{
sqlSession.close();
}
}
/**
* UPG NO 조회
* @param paramMap
* @return
*/
public List getUpgNoList(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
resultList = (ArrayList)sqlSession.selectList("product.getUpgNoList", paramMap);
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return CommonUtils.keyChangeUpperList(resultList);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public List productPriceHistory(HttpServletRequest request,Map paramMap){
List<Map> resultList = new ArrayList();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
Map pageMap = (HashMap)sqlSession.selectOne("product.getproductPriceHistoryCnt", paramMap);
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
paramMap.put("PAGE_END", pageMap.get("PAGE_END"));
paramMap.put("PAGE_START", pageMap.get("PAGE_START"));
resultList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("product.getproductPriceHistory", paramMap));
}catch(Exception e){
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultList;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map deleteproductMngInfo(HttpServletRequest request, Map paramMap){
Map resultMap = new HashMap();
SqlSession sqlSession = null;
try{
sqlSession = SqlMapConfig.getInstance().getSqlSession();
System.out.println("paramMap : "+paramMap);
String[] objIds = request.getParameterValues("chk_objId");
int cnt = 0;
for(int i=0; i<objIds.length; i++){
paramMap.put("objId", objIds[i]);
cnt += sqlSession.update("product.deleteproductMngPriceInfo", paramMap);
}
if(cnt > 0){
resultMap.put("result", true);
resultMap.put("msg", Message.DELETE_SUCCESS);
}
}catch(Exception e){
resultMap.put("result", false);
resultMap.put("msg", Message.DELETE_FAILED);
e.printStackTrace();
}finally{
sqlSession.close();
}
return resultMap;
}
}