- Add Docker Compose configurations for dev, prod, and standalone environments - Add database initialization scripts (init-db.sh, init-db-docker.sh) - Add enhanced start-docker-linux.sh with DB init support - Add comprehensive database initialization guide - Support for automatic dbexport.pgsql import on first run - Include safety checks for production environment
2026 lines
66 KiB
Java
2026 lines
66 KiB
Java
package com.pms.service;
|
|
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
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.SqlMapConfig;
|
|
import com.pms.common.bean.PersonBean;
|
|
import com.pms.common.service.BaseService;
|
|
import com.pms.common.utils.CommonUtils;
|
|
import com.pms.common.utils.Constants;
|
|
|
|
@Service
|
|
public class PartService extends BaseService{
|
|
|
|
|
|
@Autowired
|
|
CommonService commonService;
|
|
|
|
public Map setPartCommonCD(Map paramMap){
|
|
paramMap.put("PRODUCT_GROUP_CODE", Constants.PRODUCT_GROUP_CODE);
|
|
paramMap.put("MATERIAL_CODE", Constants.MATERIAL_CODE);
|
|
paramMap.put("SPEC_NO_CODE", Constants.SPEC_NO_CODE);
|
|
paramMap.put("DESIGN_APPLY_POINT_CODE", Constants.DESIGN_APPLY_POINT_CODE);
|
|
|
|
return paramMap;
|
|
}
|
|
|
|
/**
|
|
* BOM 구조 기본정보 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getBOMStructureStandardInfo(HttpServletRequest request,Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
|
|
|
setPartCommonCD(paramMap);
|
|
|
|
paramMap.put("bomObjId", objId);
|
|
|
|
String bomObjId = CommonUtils.checkNull(paramMap.get("bomObjId"));
|
|
|
|
HttpSession session = request.getSession();
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
|
|
//접속자
|
|
String userId = person.getUserId();
|
|
paramMap.put("writer", userId);
|
|
|
|
if("".equals(bomObjId)){
|
|
bomObjId = createBomStructureStandardInfo(paramMap);
|
|
}
|
|
resultMap = (HashMap)sqlSession.selectOne("partMng.getBOMStructureStandardInfoByObjId", bomObjId);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultMap);
|
|
}
|
|
|
|
/**
|
|
* BOM 구조 기본정보를 등록 후, 생성한 Object id를 반환한다.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public String createBomStructureStandardInfo(Map paramMap){
|
|
String result = "";
|
|
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
if(!"".equals(CommonUtils.checkNull(paramMap.get("bomObjId")))){
|
|
result = CommonUtils.checkNull(paramMap.get("bomObjId"));
|
|
}else{
|
|
result = CommonUtils.createObjId();
|
|
}
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("bomObjId", result);
|
|
sqlParamMap.put("oemObjId", CommonUtils.checkNull(paramMap.get("search_oemObjId")));
|
|
sqlParamMap.put("carObjId", CommonUtils.checkNull(paramMap.get("search_carObjId")));
|
|
sqlParamMap.put("productObjId", CommonUtils.checkNull(paramMap.get("search_productObjId")));
|
|
sqlParamMap.put("regionObjId", CommonUtils.checkNull(paramMap.get("search_regionObjId")));
|
|
sqlParamMap.put("writer", CommonUtils.checkNull(paramMap.get("writer")));
|
|
|
|
sqlSession.insert("partMng.createBOMReportStructureStandardInfo", sqlParamMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Part의 상세정보를 가져온다.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public HashMap getPartDetailInfo(HttpServletRequest request,Map paramMap){
|
|
HashMap resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultMap = sqlSession.selectOne("part.getPartInfoDetail", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* Part의 관리항목 목록을 가져온다
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getPartMngItemReceptList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("userId", CommonUtils.checkNull(person.getUserId()));
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("part.getPartMngItemList", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* Part의 관리항목 확인 시 DB에 내용 입력
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public void mergeCheckPartMngFile(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("userId", CommonUtils.checkNull(person.getUserId()));
|
|
paramMap.put("newObjId", CommonUtils.createObjId());
|
|
sqlSession.update("part.mergePartMngItemCheck", paramMap);
|
|
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Part에 연결된 SPEC 정보를 가져온다.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getConnectedSpecList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
ArrayList relSPECList = new ArrayList();
|
|
ArrayList connectedSPECList = new ArrayList();
|
|
|
|
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
relSPECList = (ArrayList)sqlSession.selectList("part.getPartRelSpecList", paramMap);
|
|
|
|
if(0 < relSPECList.size()){
|
|
for(int i=0;i<relSPECList.size();i++){
|
|
HashMap specMap = (HashMap)relSPECList.get(i);
|
|
String specObjId = CommonUtils.checkNull(specMap.get("SUB_OBJID"));
|
|
|
|
paramMap.put("specObjId",specObjId);
|
|
ArrayList specConnectedList = new ArrayList();
|
|
|
|
specConnectedList = (ArrayList)sqlSession.selectList("part.getSPECConnectedList", paramMap);
|
|
|
|
if(null != specConnectedList && 0 < specConnectedList.size()){
|
|
connectedSPECList.add(specConnectedList);
|
|
}
|
|
}
|
|
}
|
|
if(null == connectedSPECList || 0 == connectedSPECList.size()){
|
|
resultList = relSPECList;
|
|
}else{
|
|
resultList = connectedSPECList;
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* Part에 연결된 기변항목 정보를 가져온다.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public HashMap getConnectedChangeItemInfo(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
HashMap resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("part.getPartRelChangeItemList", paramMap);
|
|
|
|
if(0 < resultList.size()){
|
|
for(int i=0;i<resultList.size();i++){
|
|
HashMap tempMap = (HashMap)resultList.get(i);
|
|
|
|
String itemName = CommonUtils.checkNull(tempMap.get("ITEM_NAME"));
|
|
if(!"".equals(itemName)){
|
|
if(itemName.equals("changeGeometry")){
|
|
resultMap.put("changeGeometry", "checked");
|
|
}
|
|
if(itemName.equals("materialThickChange")){
|
|
resultMap.put("materialThickChange", "checked");
|
|
}
|
|
if(itemName.equals("cycleChange")){
|
|
resultMap.put("cycleChange", "checked");
|
|
}
|
|
if(itemName.equals("constructChange")){
|
|
resultMap.put("constructChange", "checked");
|
|
}
|
|
if(itemName.equals("weldingSpot")){
|
|
resultMap.put("weldingSpot", "checked");
|
|
}
|
|
if(itemName.equals("structurGlue")){
|
|
resultMap.put("structurGlue", "checked");
|
|
}
|
|
if(itemName.equals("first")){
|
|
resultMap.put("first", "checked");
|
|
}
|
|
if(itemName.equals("etc")){
|
|
resultMap.put("etc", "checked");
|
|
}
|
|
if(itemName.equals("none")){
|
|
resultMap.put("none", "checked");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* Part에 연결된 기변항목 정보를 가져온다.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public HashMap getPartProductItemListInfo(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
HashMap resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("part.getPartProductCategoryItemList", paramMap);
|
|
|
|
if(0 < resultList.size()){
|
|
for(int i=0;i<resultList.size();i++){
|
|
HashMap tempMap = (HashMap)resultList.get(i);
|
|
|
|
String itemName = CommonUtils.checkNull(tempMap.get("COMM_CODE"));
|
|
|
|
|
|
if(!"".equals(itemName)){
|
|
if(itemName.equals("PCA00100")){
|
|
resultMap.put("pro_c1", "checked");
|
|
}
|
|
if(itemName.equals("PCA00200")){
|
|
resultMap.put("pro_c2", "checked");
|
|
}
|
|
if(itemName.equals("PCA00300")){
|
|
resultMap.put("pro_c3", "checked");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
|
|
/**
|
|
* 파트정보를 저장한다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void mergePartInfo(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
String actionType = CommonUtils.checkNull(paramMap.get("actionType"));
|
|
String drawType = CommonUtils.checkNull(paramMap.get("drawType"));
|
|
String mngType = CommonUtils.checkNull(paramMap.get("mngType"));
|
|
String status = CommonUtils.checkNull(paramMap.get("status"));
|
|
String cavity = CommonUtils.checkNull(paramMap.get("cavity"));
|
|
String remarks = CommonUtils.checkNull(paramMap.get("remarks"));
|
|
paramMap.put("cavity", cavity);
|
|
paramMap.put("remarks", remarks);
|
|
String writer = "";
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
writer = CommonUtils.checkNull(person.getUserId());
|
|
paramMap.put("writer", writer);
|
|
|
|
String thickness = CommonUtils.checkNull(paramMap.get("thickness"));
|
|
String weight = CommonUtils.checkNull(paramMap.get("weight"));
|
|
|
|
/*if(!"".equals(thickness) && !"-".equals(thickness)){
|
|
paramMap.put("thickness",String.format("%.2f", Double.parseDouble(thickness)));
|
|
}
|
|
|
|
if(!"".equals(weight) && !"-".equals(weight)){
|
|
paramMap.put("weight",String.format("%.2f", Double.parseDouble(weight)));
|
|
}*/
|
|
|
|
if("regist".equals(actionType)){
|
|
paramMap.put("status", "create");
|
|
paramMap.put("isLast", "0");
|
|
}
|
|
|
|
if("revision".equals(status)){
|
|
HashMap resultMap = new HashMap();
|
|
resultMap = sqlSession.selectOne("part.getPartInfoDetail", paramMap);
|
|
|
|
paramMap.put("partNo", CommonUtils.checkNull(resultMap.get("PART_NO")));
|
|
paramMap.put("oem", CommonUtils.checkNull(resultMap.get("OEM_OBJID")));
|
|
paramMap.put("car", CommonUtils.checkNull(resultMap.get("CAR_OBJID")));
|
|
paramMap.put("productFamily", CommonUtils.checkNull(resultMap.get("PRODUCT_GROUP_OBJID")));
|
|
paramMap.put("product", CommonUtils.checkNull(resultMap.get("PRODUCT_OBJID")));
|
|
}
|
|
|
|
//파트정보를 merge 한다.
|
|
sqlSession.update("part.mergePartInfo", paramMap);
|
|
|
|
//SPEC-Part간 연결을 해제한다.
|
|
sqlSession.delete("part.deletePartRelSpec", paramMap);
|
|
|
|
//추가된 SPEC의 목록을 가져와 연결한다.
|
|
String[] addedSpecList = request.getParameterValues("connectSpec");
|
|
if(null != addedSpecList && 0 < addedSpecList.length){
|
|
for(int i=0;i<addedSpecList.length;i++){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String masterObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
String specObjid = CommonUtils.checkNull(addedSpecList[i]);
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", masterObjid);
|
|
sqlParamMap.put("specObjid", specObjid);
|
|
sqlParamMap.put("writer", writer);
|
|
sqlSession.update("part.mergePartRelSpec", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
//기변항목-Part간 연결을 해제한다.
|
|
sqlSession.update("part.deletePartRelChangeItem", paramMap);
|
|
|
|
//생산구분-Part간 연결을 해제한다.
|
|
sqlSession.update("part.deletePartProductCategoryItem", paramMap);
|
|
|
|
//기변항목 목록을 가져와 연결한다.
|
|
String[] changeItems = request.getParameterValues("changeItem");
|
|
if(null != changeItems && 0 < changeItems.length){
|
|
for(int i=0;i<changeItems.length;i++){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String masterObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
String changeItemName = CommonUtils.checkNull(changeItems[i]);
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", masterObjid);
|
|
sqlParamMap.put("changeItem", changeItemName);
|
|
sqlParamMap.put("writer", writer);
|
|
//선택된 기변항목의 목록을 가져와 파트와 연결한다.
|
|
sqlSession.update("part.mergePartRelChangeItem", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
//생산구분 목록을 가져와 연결한다.
|
|
String[] pratCategorys = request.getParameterValues("pro_category");
|
|
if(null != pratCategorys && 0 < pratCategorys.length){
|
|
for(int i=0;i<pratCategorys.length;i++){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String masterObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
String pratCategorysName = CommonUtils.checkNull(pratCategorys[i]);
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", masterObjid);
|
|
sqlParamMap.put("changeItem", pratCategorysName);
|
|
sqlParamMap.put("parent_comm_code", "PCA10000");
|
|
|
|
//선택된 기변항목의 목록을 가져와 파트와 연결한다.
|
|
sqlSession.update("part.mergePartProductCategoryItem", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
//도면 구분 shownOn 선택 시
|
|
if("shownOn".equals(drawType)){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String targetObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
|
|
sqlParamMap.put("objid", targetObjid);
|
|
sqlParamMap.put("docType", "PART_2D");
|
|
sqlSession.delete("part.deletePartRelAttachFile", sqlParamMap);
|
|
sqlParamMap.put("docType", "PART_2D_PDF");
|
|
sqlSession.delete("part.deletePartRelAttachFile", sqlParamMap);
|
|
sqlParamMap.put("docType", "PART_CONVERSION");
|
|
sqlSession.delete("part.deletePartRelAttachFile", sqlParamMap);
|
|
sqlParamMap.put("docType", "PART_3D");
|
|
sqlSession.delete("part.deletePartRelAttachFile", sqlParamMap);
|
|
}
|
|
|
|
//관리항목 no 선택 시
|
|
if("unManagement".equals(mngType)){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String targetObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
|
|
sqlParamMap.put("objid", targetObjid);
|
|
sqlParamMap.put("docType", "PART_MNG_ITEM");
|
|
sqlSession.delete("part.deletePartRelAttachFile", sqlParamMap);
|
|
}
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 시작 파트정보를 저장한다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void mergeStartDevPartInfo(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
String actionType = CommonUtils.checkNull(paramMap.get("actionType"));
|
|
String drawType = CommonUtils.checkNull(paramMap.get("drawType"));
|
|
String mngType = CommonUtils.checkNull(paramMap.get("mngType"));
|
|
String status = CommonUtils.checkNull(paramMap.get("status"));
|
|
String writer = "";
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
writer = CommonUtils.checkNull(person.getUserId());
|
|
paramMap.put("writer", writer);
|
|
|
|
String thickness = CommonUtils.checkNull(paramMap.get("thickness"));
|
|
String weight = CommonUtils.checkNull(paramMap.get("weight"));
|
|
|
|
if(!"".equals(thickness) && !"-".equals(thickness)){
|
|
paramMap.put("thickness",String.format("%.2f", Double.parseDouble(thickness)));
|
|
}
|
|
|
|
if(!"".equals(weight) && !"-".equals(weight)){
|
|
paramMap.put("weight",String.format("%.2f", Double.parseDouble(weight)));
|
|
}
|
|
|
|
if("regist".equals(actionType)){
|
|
paramMap.put("status", "create");
|
|
paramMap.put("isLast", "0");
|
|
}
|
|
//파트정보를 merge 한다.
|
|
sqlSession.update("part.mergeStartPartInfo", paramMap);
|
|
|
|
//기변항목-Part간 연결을 해제한다.
|
|
sqlSession.update("part.deletePartRelChangeItem", paramMap);
|
|
|
|
//기변항목 목록을 가져와 연결한다.
|
|
String[] changeItems = request.getParameterValues("changeItem");
|
|
if(null != changeItems && 0 < changeItems.length){
|
|
for(int i=0;i<changeItems.length;i++){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String masterObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
String changeItemName = CommonUtils.checkNull(changeItems[i]);
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", masterObjid);
|
|
sqlParamMap.put("changeItem", changeItemName);
|
|
sqlParamMap.put("writer", writer);
|
|
//선택된 기변항목의 목록을 가져와 파트와 연결한다.
|
|
sqlSession.update("part.mergePartRelChangeItem", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* revision 파트정보를 저장한다.
|
|
* revision의 경우 Rev Code, 기변항목 만 저장한다.
|
|
* 첨부파일은 초기화되나 화면에서 첨부처리 진행
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void mergeRevisionPartInfo(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
String actionType = CommonUtils.checkNull(paramMap.get("actionType"));
|
|
String drawType = CommonUtils.checkNull(paramMap.get("drawType"));
|
|
String mngType = CommonUtils.checkNull(paramMap.get("mngType"));
|
|
String writer = "";
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
writer = CommonUtils.checkNull(person.getUserId());
|
|
paramMap.put("writer", writer);
|
|
paramMap.put("status", "revision");
|
|
paramMap.put("isLast", "0");
|
|
|
|
//파트정보를 merge 한다.
|
|
sqlSession.update("part.mergeRevisionPartInfo", paramMap);
|
|
|
|
//기변항목-Part간 연결을 해제한다.
|
|
sqlSession.update("part.deletePartRelChangeItem", paramMap);
|
|
|
|
//기변항목 목록을 가져와 연결한다.
|
|
String[] changeItems = request.getParameterValues("changeItem");
|
|
if(null != changeItems && 0 < changeItems.length){
|
|
for(int i=0;i<changeItems.length;i++){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String masterObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
String changeItemName = CommonUtils.checkNull(changeItems[i]);
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", masterObjid);
|
|
sqlParamMap.put("changeItem", changeItemName);
|
|
sqlParamMap.put("writer", writer);
|
|
//선택된 기변항목의 목록을 가져와 파트와 연결한다.
|
|
sqlSession.update("part.mergePartRelChangeItem", sqlParamMap);
|
|
}
|
|
}
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 템플릿을 통해 Part 정보를 입력한다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void mergeExcelUploadPart(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
String writer = "";
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
String[] partObjIds = request.getParameterValues("partObjId");
|
|
if(null != partObjIds && 0 < partObjIds.length){
|
|
for(int i=0;i<partObjIds.length;i++){
|
|
|
|
String partObjId = CommonUtils.checkNull(partObjIds[i]);
|
|
|
|
if(!"".equals(partObjId)){
|
|
String partNo = CommonUtils.checkNull(paramMap.get(partObjId+"_partNo"));
|
|
String rhPartNo = CommonUtils.checkNull(paramMap.get(partObjId+"_rhPartObjId"));
|
|
String partName = CommonUtils.checkNull(paramMap.get(partObjId+"_partName"));
|
|
String oem = CommonUtils.checkNull(paramMap.get(partObjId+"_oem"));
|
|
String car = CommonUtils.checkNull(paramMap.get(partObjId+"_car"));
|
|
String productGroup = CommonUtils.checkNull(paramMap.get(partObjId+"_productGroup"));
|
|
String product = CommonUtils.checkNull(paramMap.get(partObjId+"_product"));
|
|
String drawReleaseType = CommonUtils.checkNull(paramMap.get(partObjId+"_drawReleaseType"));
|
|
String partType = CommonUtils.checkNull(paramMap.get(partObjId+"_partType"));
|
|
String drawType = CommonUtils.checkNull(paramMap.get(partObjId+"_drawType"));
|
|
String drawingNo = CommonUtils.checkNull(paramMap.get(partObjId+"_drawingNoObjId"));
|
|
String material = CommonUtils.checkNull(paramMap.get(partObjId+"_material"));
|
|
String optionSpec = CommonUtils.checkNull(paramMap.get(partObjId+"_optionSpec"));
|
|
String materialType = CommonUtils.checkNull(paramMap.get(partObjId+"_materialType"));
|
|
String thickness = CommonUtils.checkNull(paramMap.get(partObjId+"_thickness"));
|
|
String weight = CommonUtils.checkNull(paramMap.get(partObjId+"_weight"));
|
|
String revCode = CommonUtils.checkNull(paramMap.get(partObjId+"_revCode"));
|
|
String applyPointType = CommonUtils.checkNull(paramMap.get(partObjId+"_applyPointType"));
|
|
|
|
//파트정보를 merge 한다.
|
|
HashMap partSqlParamMap = new HashMap();
|
|
partSqlParamMap.put("objid", partObjId);
|
|
partSqlParamMap.put("oem", oem);
|
|
partSqlParamMap.put("car", car);
|
|
partSqlParamMap.put("productFamily", productGroup);
|
|
partSqlParamMap.put("product", product);
|
|
partSqlParamMap.put("partNo", partNo);
|
|
partSqlParamMap.put("rhPartObjId", rhPartNo);
|
|
partSqlParamMap.put("partName", partName);
|
|
partSqlParamMap.put("drawReleaseType", drawReleaseType);
|
|
partSqlParamMap.put("partType", partType);
|
|
partSqlParamMap.put("revision", revCode);
|
|
partSqlParamMap.put("materialType", materialType);
|
|
partSqlParamMap.put("drawType", drawType);
|
|
partSqlParamMap.put("drawingNoObjId", drawingNo);
|
|
partSqlParamMap.put("material", material);
|
|
partSqlParamMap.put("optionSpec", optionSpec);
|
|
partSqlParamMap.put("thickness", thickness);
|
|
partSqlParamMap.put("weight", weight);
|
|
partSqlParamMap.put("applyPointType", applyPointType);
|
|
partSqlParamMap.put("isLast", "0");
|
|
partSqlParamMap.put("writer", writer);
|
|
partSqlParamMap.put("status", "create");
|
|
|
|
System.out.println("partSqlParamMap:"+partSqlParamMap);
|
|
|
|
//Part No, Rev, status가 동일한 데이터가 이미 있는 경우 Update 아니면 Insert한다.
|
|
sqlSession.update("part.mergeImportPartInfo", partSqlParamMap);
|
|
|
|
HashMap partInfoMap = new HashMap();
|
|
|
|
partInfoMap = sqlSession.selectOne("part.getImportTargetPartInfoDetail", partSqlParamMap);
|
|
|
|
String targetPartObjId = CommonUtils.checkNull(partInfoMap.get("OBJID"));
|
|
|
|
//동일 파트 No, 상태, Rev가 있는 경우 partObjId 변경
|
|
if(!"".equals(targetPartObjId)){
|
|
partObjId = targetPartObjId;
|
|
}
|
|
|
|
String[] changeItems = request.getParameterValues(partObjId+"_changeItem");
|
|
|
|
if(null != changeItems && 0 < changeItems.length){
|
|
for(int j=0;j<changeItems.length;j++){
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String changeItemName = CommonUtils.checkNull(changeItems[j]);
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", partObjId);
|
|
sqlParamMap.put("changeItem", changeItemName);
|
|
sqlParamMap.put("writer", writer);
|
|
//선택된 기변항목의 목록을 가져와 파트와 연결한다.
|
|
sqlSession.update("part.mergePartRelChangeItem", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
//추가된 SPEC의 목록을 가져와 연결한다.
|
|
// String[] addedSpecList = request.getParameterValues("connectSpec");
|
|
// if(null != addedSpecList && 0 < addedSpecList.length){
|
|
// for(int i=0;i<addedSpecList.length;i++){
|
|
// HashMap sqlParamMap = new HashMap();
|
|
// String relObjid = CommonUtils.createObjId();
|
|
// String masterObjid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
// String specObjid = CommonUtils.checkNull(addedSpecList[i]);
|
|
//
|
|
// sqlParamMap.put("relObjid", relObjid);
|
|
// sqlParamMap.put("objid", masterObjid);
|
|
// sqlParamMap.put("specObjid", specObjid);
|
|
// sqlParamMap.put("writer", writer);
|
|
// sqlSession.update("part.mergePartRelSpec", sqlParamMap);
|
|
// }
|
|
// }
|
|
|
|
/**
|
|
* importPopObjid로 업로드된 파일들의 파일명중
|
|
* 파트 No에 해당하는 파일을 DB 상에서 Part의 ObjectId로
|
|
* targetObjId를 변경해준다.
|
|
*/
|
|
HashMap fileParamMap = new HashMap();
|
|
fileParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("importPopObjid")));
|
|
fileParamMap.put("docType", "PART_IMPORT_ATTACH");
|
|
fileParamMap.put("realFileName", partNo.replaceAll("-", ""));
|
|
ArrayList relFileList = new ArrayList();
|
|
relFileList = (ArrayList)getPartFileList(request, fileParamMap);
|
|
|
|
if(null != relFileList && 0 < relFileList.size()){
|
|
for(int k=0;k<relFileList.size();k++){
|
|
HashMap fileMap = (HashMap)relFileList.get(k);
|
|
String fileExt = CommonUtils.checkNull(fileMap.get("UPPER_FILE_EXT"));
|
|
String fileObjId = CommonUtils.checkNull(fileMap.get("OBJID"));
|
|
|
|
HashMap changeFileMap = new HashMap();
|
|
changeFileMap.put("fileObjId", fileObjId);
|
|
changeFileMap.put("partObjId", partObjId);
|
|
//3D 도면
|
|
if("CATPART".equals(fileExt)){
|
|
changeFileMap.put("docType", Constants.FILE_DOC_TYPE_PART_3D_CODE);
|
|
changeFileMap.put("docTypeName", Constants.FILE_DOC_TYPE_PART_3D_NAME);
|
|
|
|
sqlSession.update("part.deletePartImportAttachFile", changeFileMap);
|
|
//2D 도면
|
|
}else if("CATDRAWING".equals(fileExt)){
|
|
changeFileMap.put("docType", Constants.FILE_DOC_TYPE_PART_2D_CODE);
|
|
changeFileMap.put("docTypeName", Constants.FILE_DOC_TYPE_PART_2D_NAME);
|
|
|
|
sqlSession.update("part.deletePartImportAttachFile", changeFileMap);
|
|
//PDF
|
|
}else if("PDF".equals(fileExt)){
|
|
changeFileMap.put("docType", Constants.FILE_DOC_TYPE_PART_2D_PDF_CODE);
|
|
changeFileMap.put("docTypeName", Constants.FILE_DOC_TYPE_PART_2D_PDF_NAME);
|
|
|
|
sqlSession.update("part.deletePartImportAttachFile", changeFileMap);
|
|
//형상
|
|
}else if("JPG".equals(fileExt) || "JPEG".equals(fileExt)){
|
|
changeFileMap.put("docType", Constants.FILE_DOC_TYPE_PART_SHAPE_CODE);
|
|
changeFileMap.put("docTypeName", Constants.FILE_DOC_TYPE_PART_SHAPE_NAME);
|
|
|
|
sqlSession.update("part.deletePartImportAttachFile", changeFileMap);
|
|
//ECD
|
|
}else if("PPT".equals(fileExt) || "PPTX".equals(fileExt) || "XLS".equals(fileExt) || "XLSX".equals(fileExt)){
|
|
changeFileMap.put("docType", Constants.FILE_DOC_TYPE_PART_ECD_CODE);
|
|
changeFileMap.put("docTypeName", Constants.FILE_DOC_TYPE_PART_ECD_NAME);
|
|
|
|
sqlSession.update("part.deletePartImportAttachFile", changeFileMap);
|
|
}
|
|
//docType이 있는 경우 첨부파일 영역의 targetObjId를 변경한다.
|
|
if(!"".equals(CommonUtils.checkNull(changeFileMap.get("docType")))){
|
|
sqlSession.update("part.updatePartImportAttachFile", changeFileMap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 파트 Import 시 첨부된 파일 목록을 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public ArrayList getPartFileList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = (ArrayList)sqlSession.selectList("part.getUploadFileList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 파트를 확정상태로 변경한다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public void changePartStatus(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
String partObjId = CommonUtils.checkNull(request.getParameter("partCheckBox"));
|
|
|
|
if(!"".equals(partObjId)){
|
|
HashMap sqlParamMap = new HashMap();
|
|
sqlParamMap.put("targetObjId", partObjId);
|
|
sqlParamMap.put("status","complete");
|
|
sqlParamMap.put("isLast", "0");
|
|
sqlSession.update("part.changeSamePartNoIsLast",sqlParamMap);
|
|
|
|
//확정대상 Part의 is_last를 1로 변경한다.
|
|
sqlParamMap.put("isLast", "1");
|
|
sqlSession.update("part.changePartStatus",sqlParamMap);
|
|
sqlSession.commit();
|
|
}
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 파트를 확정상태로 변경한다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public void changeMultiPartStatus(HttpServletRequest request,Map paramMap){
|
|
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("targetObjId", partObjid);
|
|
sqlParamMap.put("status", CommonUtils.checkNull(paramMap.get("status")));
|
|
//동일 Part No를 가진 Part의 is_last를 0으로 변경한다.
|
|
sqlParamMap.put("isLast", "0");
|
|
sqlSession.update("part.changeSamePartNoIsLast",sqlParamMap);
|
|
|
|
//확정대상 Part의 is_last를 1로 변경한다.
|
|
sqlParamMap.put("isLast", "1");
|
|
sqlSession.update("part.changePartStatus",sqlParamMap);
|
|
}
|
|
sqlSession.commit();
|
|
}
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 파트를 확정상태로 변경한다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public void deletePart(HttpServletRequest request,Map paramMap){
|
|
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.delete("part.deletePart",sqlParamMap);
|
|
sqlSession.delete("part.deletePartRelChangeItem",sqlParamMap);
|
|
sqlSession.delete("part.deletePartRelSpec",sqlParamMap);
|
|
sqlSession.delete("part.deletePartProductCategoryItem",sqlParamMap);
|
|
}
|
|
sqlSession.commit();
|
|
}
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 파트 IS_LAST 변경
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void changePartIsLast(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
String objid = CommonUtils.checkNull(request.getParameter("objid"));
|
|
|
|
HashMap sqlParamMap = new HashMap();
|
|
|
|
sqlParamMap.put("targetObjId", objid);
|
|
sqlParamMap.put("status", CommonUtils.checkNull(paramMap.get("status")));
|
|
|
|
//동일 Part No를 가진 Part의 is_last를 0으로 변경한다.
|
|
sqlParamMap.put("isLast", "0");
|
|
sqlSession.update("part.changeSamePartNoIsLast",sqlParamMap);
|
|
|
|
//확정대상 Part의 is_last를 1로 변경한다.
|
|
sqlParamMap.put("isLast", "1");
|
|
sqlSession.update("part.changePartStatus",sqlParamMap);
|
|
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 파트목록을 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getPartList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
String[] partNoArr = CommonUtils.checkNull(paramMap.get("search_partNo")).split(" ");
|
|
|
|
if(partNoArr.length > 1){
|
|
paramMap.put("multiSearch", "Y");
|
|
paramMap.put("partNoArr", partNoArr);
|
|
}
|
|
|
|
String[] drawingNoArr = CommonUtils.checkNull(paramMap.get("search_drawingNo")).split(" ");
|
|
|
|
if(drawingNoArr.length > 1){
|
|
paramMap.put("multiSearchDrawingNo", "Y");
|
|
paramMap.put("drawingNoArr", drawingNoArr);
|
|
}
|
|
|
|
String[] thicknessArr = CommonUtils.checkNull(paramMap.get("search_thickness")).split(" ");
|
|
|
|
if(thicknessArr.length > 1){
|
|
paramMap.put("multiSearchThickness", "Y");
|
|
paramMap.put("thicknessArr", thicknessArr);
|
|
}
|
|
|
|
System.out.println("=========================");
|
|
System.out.println("paramMap : "+paramMap);
|
|
System.out.println("=========================");
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("part.getPartList",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 파트의 Revision 목록을 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getPartRevisionList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
String[] partNoArr = CommonUtils.checkNull(paramMap.get("search_partNo")).split(" ");
|
|
|
|
if(partNoArr.length > 1){
|
|
paramMap.put("multiSearch", "Y");
|
|
paramMap.put("partNoArr", partNoArr);
|
|
}
|
|
|
|
String[] drawingNoArr = CommonUtils.checkNull(paramMap.get("search_drawingNo")).split(" ");
|
|
|
|
if(drawingNoArr.length > 1){
|
|
paramMap.put("multiSearchDrawingNo", "Y");
|
|
paramMap.put("drawingNoArr", drawingNoArr);
|
|
}
|
|
|
|
String[] thicknessArr = CommonUtils.checkNull(paramMap.get("search_thickness")).split(" ");
|
|
|
|
if(thicknessArr.length > 1){
|
|
paramMap.put("multiSearchThickness", "Y");
|
|
paramMap.put("thicknessArr", thicknessArr);
|
|
}
|
|
|
|
System.out.println("=========================");
|
|
System.out.println("paramMap : "+paramMap);
|
|
System.out.println("=========================");
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("part.getPartRevisionList",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 파트중복여부를 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getDuplicatePartList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
resultList = (ArrayList)sqlSession.selectList("part.getDuplicatePartList",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* RH P/No, 도면 정보를 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getReferencePartList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
resultList = (ArrayList)sqlSession.selectList("part.getImportTargetPartInfoDetail",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 연결가능한 파트목록을 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getConnectablePartList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
resultList = (ArrayList)sqlSession.selectList("part.getConnectablePartList",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* IS_LAST 지정할 파트 목록을 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getIsLastPartList(HttpServletRequest request,Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
resultList = (ArrayList)sqlSession.selectList("part.getChangePartIsLast",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 업로드된 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"));
|
|
|
|
FileInputStream fis = new FileInputStream(path+"\\"+fileName);
|
|
XSSFWorkbook workBook = new XSSFWorkbook(fis);
|
|
XSSFSheet sheet = workBook.getSheetAt(0);
|
|
|
|
int rows = sheet.getPhysicalNumberOfRows();
|
|
for(int rowIndex= 2 ; rowIndex < rows ; rowIndex++){
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
if(null != row){
|
|
|
|
HashMap partMap = new HashMap();
|
|
|
|
for(int columnIndex = 0 ; columnIndex < 28 ; columnIndex++){
|
|
XSSFCell cell = row.getCell(columnIndex);
|
|
//데이버 유형별 get date
|
|
String cellValue = "";
|
|
|
|
if(null == cell){
|
|
cellValue = "";
|
|
}else{
|
|
switch(cell.getCellType()){
|
|
case XSSFCell.CELL_TYPE_FORMULA:
|
|
cellValue = cell.getCellFormula();
|
|
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_FORMULA:"+cellValue);
|
|
break;
|
|
case XSSFCell.CELL_TYPE_NUMERIC:
|
|
|
|
if(15 == 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("search_partNo", 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);
|
|
}
|
|
//품명
|
|
if(1 == columnIndex){
|
|
partMap.put("partName", cellValue);
|
|
}
|
|
//RH Part No
|
|
if(2 == columnIndex){
|
|
partMap.put("rhPartNo", cellValue);
|
|
}
|
|
|
|
//RH Part No Rev
|
|
if(3 == columnIndex){
|
|
partMap.put("rhPartNoRev", cellValue);
|
|
|
|
ArrayList referencePartList = new ArrayList();
|
|
HashMap rhPartParamMap = new HashMap();
|
|
|
|
String rhPartNo = CommonUtils.checkNull(partMap.get("rhPartNo"));
|
|
|
|
if(!"".equals(rhPartNo) && !"".equals(CommonUtils.checkNull(cellValue)) && !"-".equals(rhPartNo) && !"-".equals(CommonUtils.checkNull(cellValue))){
|
|
rhPartParamMap.put("partNo", rhPartNo);
|
|
rhPartParamMap.put("revision", cellValue);
|
|
referencePartList = (ArrayList)getReferencePartList(request, rhPartParamMap);
|
|
|
|
if(1 == referencePartList.size()){
|
|
HashMap rhPartMap = new HashMap();
|
|
rhPartMap = (HashMap)referencePartList.get(0);
|
|
|
|
String rhPartObjId = CommonUtils.checkNull(rhPartMap.get("OBJID"));
|
|
partMap.put("rhPartObjId", rhPartObjId);
|
|
}else if(1 < referencePartList.size()){
|
|
//파트와 Rev에 해당하는 파트가 다수 존재
|
|
partMap.put("rhPartNoValidate", "duplicatePart");
|
|
}else{
|
|
//파트와 Rev에 해당하는 파트 없음
|
|
partMap.put("rhPartNoValidate", "empty");
|
|
}
|
|
}else{
|
|
if(!"-".equals(rhPartNo) && !"-".equals(CommonUtils.checkNull(cellValue))){
|
|
partMap.put("rhPartNoValidate", "empty");
|
|
}
|
|
}
|
|
}
|
|
//고객사
|
|
if(4 == columnIndex){
|
|
partMap.put("oemName", cellValue);
|
|
}
|
|
//차종
|
|
if(5 == columnIndex){
|
|
partMap.put("carName", cellValue);
|
|
}
|
|
//제품군
|
|
if(6 == columnIndex){
|
|
partMap.put("productGroupName", cellValue);
|
|
}
|
|
//제품
|
|
if(7 == columnIndex){
|
|
partMap.put("productName", cellValue);
|
|
}
|
|
//revision code
|
|
if(8 == columnIndex){
|
|
if("".equals(cellValue)){
|
|
cellValue = "REL";
|
|
}
|
|
partMap.put("rev", cellValue);
|
|
}
|
|
//출도구분
|
|
if(9 == columnIndex){
|
|
partMap.put("drawReleaseType", cellValue);
|
|
}
|
|
//부품구분
|
|
if(10 == columnIndex){
|
|
partMap.put("partType", cellValue);
|
|
}
|
|
//도면구분
|
|
if(11 == columnIndex){
|
|
partMap.put("drawType", cellValue);
|
|
}
|
|
//도면번호
|
|
if(12 == columnIndex){
|
|
partMap.put("drawingNo", cellValue);
|
|
}
|
|
//도면번호 Rev
|
|
if(13 == columnIndex){
|
|
partMap.put("drawingNoRev", cellValue);
|
|
|
|
ArrayList referencePartList = new ArrayList();
|
|
HashMap drawingNoParamMap = new HashMap();
|
|
|
|
String drawingNo = CommonUtils.checkNull(partMap.get("drawingNo"));
|
|
|
|
if(!"".equals(drawingNo) && !"".equals(CommonUtils.checkNull(cellValue)) && !"-".equals(drawingNo) && !"-".equals(CommonUtils.checkNull(cellValue))){
|
|
drawingNoParamMap.put("partNo", drawingNo);
|
|
drawingNoParamMap.put("revision", cellValue);
|
|
referencePartList = (ArrayList)getReferencePartList(request, drawingNoParamMap);
|
|
|
|
if(1 == referencePartList.size()){
|
|
HashMap drawingNoMap = new HashMap();
|
|
drawingNoMap = (HashMap)referencePartList.get(0);
|
|
String drawingNoObjId = CommonUtils.checkNull(drawingNoMap.get("OBJID"));
|
|
partMap.put("drawingNoObjId", drawingNoObjId);
|
|
}else if(1 < referencePartList.size()){
|
|
//파트와 Rev에 해당하는 파트가 다수 존재
|
|
partMap.put("drawingNoValidate", "duplicatePart");
|
|
}else{
|
|
//파트와 Rev에 해당하는 파트 없음
|
|
partMap.put("drawingNoValidate", "empty");
|
|
}
|
|
}else{
|
|
if(!"-".equals(drawingNo) && !"-".equals(CommonUtils.checkNull(cellValue))){
|
|
partMap.put("drawingNoValidate", "empty");
|
|
}
|
|
}
|
|
}
|
|
|
|
//재질
|
|
if(14 == columnIndex){
|
|
partMap.put("material", cellValue);
|
|
}
|
|
//사양
|
|
if(15 == columnIndex){
|
|
partMap.put("optionSpec", cellValue);
|
|
}
|
|
//자제유형
|
|
if(16 == columnIndex){
|
|
partMap.put("materialType", cellValue);
|
|
}
|
|
//두께
|
|
if(17 == columnIndex){
|
|
if(!"".equals(cellValue) && !"-".equals(cellValue)){
|
|
cellValue = String.format("%.2f", Double.parseDouble(cellValue));
|
|
}
|
|
partMap.put("thickness", cellValue);
|
|
}
|
|
//weight
|
|
if(18 == columnIndex){
|
|
partMap.put("weight", cellValue);
|
|
}
|
|
//설계적용시점
|
|
if(19 == columnIndex){
|
|
partMap.put("applyPointType", cellValue);
|
|
}
|
|
//설계적용일 제외
|
|
|
|
//기변항목(형상변경)
|
|
if(20 == columnIndex){
|
|
partMap.put("changeGeometry", cellValue);
|
|
}
|
|
//기변항목(재질/두께변경)
|
|
if(21 == columnIndex){
|
|
partMap.put("materialThickChange", cellValue);
|
|
}
|
|
//기변항목(주기변경)
|
|
if(22 == columnIndex){
|
|
partMap.put("cycleChange", cellValue);
|
|
}
|
|
//기변항목(구성변경)
|
|
if(23 == columnIndex){
|
|
partMap.put("constructChange", cellValue);
|
|
}
|
|
//기변항목(용접점)
|
|
if(24 == columnIndex){
|
|
partMap.put("weldingSpot", cellValue);
|
|
}
|
|
//기변항목(구조용접착제)
|
|
if(25 == columnIndex){
|
|
partMap.put("structurGlue", cellValue);
|
|
}
|
|
//기변항목(초도)
|
|
if(26 == columnIndex){
|
|
partMap.put("first", cellValue);
|
|
}
|
|
//기변항목(기타)
|
|
if(27 == columnIndex){
|
|
partMap.put("etc", cellValue);
|
|
partMap.put("objId", CommonUtils.createObjId());
|
|
resultList.add(partMap);
|
|
|
|
System.out.println("partMap:"+partMap);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 원본 Part 정보를 통해 Revision Part를 생성한다.
|
|
* PART_INFO상의 정보 이외에 유지 필요한 정보 확인필요.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public void createRevisionPart(HttpServletRequest request,Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
String oldObjId = CommonUtils.checkNull(paramMap.get("objid"));
|
|
String newObjId = CommonUtils.createObjId();
|
|
|
|
paramMap.put("newObjId", newObjId);
|
|
paramMap.put("oldObjId", oldObjId);
|
|
paramMap.put("status", "revision");
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
paramMap.put("writer", writer);
|
|
|
|
//PART_INFO상의 데이터 입력
|
|
sqlSession.insert("part.createPartRevision",paramMap);
|
|
|
|
paramMap.put("objid",oldObjId);
|
|
|
|
//Part의 SPEC 연결관계 select 하여 생성된 Revision Part와 연결한다.
|
|
ArrayList connectedSPECList = (ArrayList)getConnectedSpecList(request, paramMap);
|
|
if(null != connectedSPECList && 0 < connectedSPECList.size()){
|
|
for(int i=0;i<connectedSPECList.size();i++){
|
|
|
|
HashMap connectedSPECMap = (HashMap)connectedSPECList.get(i);
|
|
|
|
HashMap sqlParamMap = new HashMap();
|
|
String relObjid = CommonUtils.createObjId();
|
|
String masterObjid = CommonUtils.checkNull(newObjId);
|
|
String specObjid = CommonUtils.checkNull(connectedSPECMap.get("SUB_OBJID"));
|
|
|
|
sqlParamMap.put("relObjid", relObjid);
|
|
sqlParamMap.put("objid", masterObjid);
|
|
sqlParamMap.put("specObjid", specObjid);
|
|
sqlParamMap.put("writer", writer);
|
|
sqlSession.update("part.mergePartRelSpec", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
|
|
//기존 Part에 연결되어 있던 형상정보를 Revision되는 Part에 복사(파일 복사, 데이터 복사)하여준다.(개발중)
|
|
HashMap fileParamMap = new HashMap();
|
|
fileParamMap.put("targetObjId", oldObjId);
|
|
fileParamMap.put("docType", Constants.FILE_DOC_TYPE_PART_SHAPE_CODE);
|
|
|
|
ArrayList fileList = new ArrayList();
|
|
|
|
//Part에 연결된 형상파일 정보 목록을 가져온다.
|
|
fileList = commonService.getFileList(fileParamMap);
|
|
|
|
//연결된 파일 정보가 있을 경우
|
|
if(null != fileList && 0 < fileList.size()){
|
|
|
|
for(int i=0;i<fileList.size();i++){
|
|
|
|
HashMap fileMap = (HashMap)fileList.get(i);
|
|
|
|
String realFileName = CommonUtils.checkNull(fileMap.get("REAL_FILE_NAME"));
|
|
String savedFileName = CommonUtils.checkNull(fileMap.get("SAVED_FILE_NAME"));
|
|
String docType = CommonUtils.checkNull(fileMap.get("DOC_TYPE"));
|
|
String docTypeName = CommonUtils.checkNull(fileMap.get("DOC_TYPE_NAME"));
|
|
String filePath = CommonUtils.checkNull(fileMap.get("FILE_PATH"));
|
|
|
|
FileInputStream fis = new FileInputStream(filePath+File.separator+savedFileName);
|
|
FileOutputStream fos = null;
|
|
|
|
String fName = realFileName;
|
|
String fExt = "";
|
|
|
|
int fileIdx = -1;
|
|
if ((fileIdx = fName.lastIndexOf(".")) != -1) {
|
|
fExt = fName.substring(fileIdx); // only file extension
|
|
fName = fName.substring(0, fileIdx); // except file extension
|
|
}
|
|
|
|
String copyFileName = Constants.FILE_STORAGE+File.separator+fName.replaceAll(" ", "") + "_" +System.currentTimeMillis()+""+ fExt;
|
|
|
|
fos = new FileOutputStream(copyFileName);
|
|
|
|
int j = 0;
|
|
while((j=fis.read())!=-1){
|
|
fos.write(j);
|
|
}
|
|
fis.close();
|
|
fos.close();
|
|
|
|
String fileObjId = CommonUtils.createObjId();
|
|
String fileSize = "0";
|
|
|
|
File f = new File(CommonUtils.checkNull(fileMap.get("savedFullFileName")));
|
|
if(f.exists()){
|
|
fileSize = CommonUtils.checkNull(f.length());
|
|
}
|
|
|
|
Map copyFileParamMap = new HashMap();
|
|
copyFileParamMap.put("objId", fileObjId);
|
|
copyFileParamMap.put("targetObjId", newObjId);
|
|
copyFileParamMap.put("savedFileName", savedFileName);
|
|
copyFileParamMap.put("realFileName", realFileName);
|
|
copyFileParamMap.put("docType", docType);
|
|
copyFileParamMap.put("docTypeName", docTypeName);
|
|
copyFileParamMap.put("fileSize", fileSize);
|
|
copyFileParamMap.put("fileExt", fExt.replaceAll("\\.", ""));
|
|
copyFileParamMap.put("filePath", Constants.FILE_STORAGE);
|
|
copyFileParamMap.put("writer", writer);
|
|
|
|
sqlSession.insert("common.insertUploadFileInfo", copyFileParamMap);
|
|
}
|
|
}
|
|
|
|
paramMap.put("objid",newObjId);
|
|
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**************************************************************************/
|
|
|
|
/**
|
|
* 구조등록 좌측 BOM트리목록을 받아온다.
|
|
* @param standardBOMInfo
|
|
* @return
|
|
*/
|
|
public List getBOMPartTreeList(Map standardBOMInfo){
|
|
List<Map<String,Object>> resultList = new ArrayList();
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
System.out.println("standardBOMInfo : "+standardBOMInfo);
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("bomReportObjId", CommonUtils.checkNull(standardBOMInfo.get("OBJID")));
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("part.getBOMTreeList", sqlParamMap);
|
|
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
}
|
|
|
|
/**
|
|
* BOM구조 연결.
|
|
* @param paramMap
|
|
* @param partList
|
|
* @return
|
|
*/
|
|
public boolean relatePartInfo(Map paramMap, List<String> partList){
|
|
boolean result = false;
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("bomReportObjId", CommonUtils.checkNull(paramMap.get("objId")));
|
|
sqlParamMap.put("parentPartNo", CommonUtils.checkNull(paramMap.get("leftPartNo")));
|
|
sqlParamMap.put("parentObjId", CommonUtils.checkNull(paramMap.get("leftPartObjId")));
|
|
sqlParamMap.put("qty", 1);
|
|
sqlParamMap.put("regionObjId", CommonUtils.checkNull(paramMap.get("regionObjId")));
|
|
|
|
for(String partNo : partList){
|
|
sqlParamMap.put("partNo", partNo);
|
|
sqlParamMap.put("partObjId", CommonUtils.createObjId());
|
|
|
|
sqlSession.insert("part.relatePartInfo", sqlParamMap);
|
|
}
|
|
result = true;
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* BOM 구조 개별삭제(하위정보 포함)
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public boolean deletePartRelateInfo(Map paramMap){
|
|
boolean result = false;
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
System.out.println("deletePartRelateInfo.paramMap >> "+paramMap);
|
|
|
|
sqlSession.delete("part.deletePartRelateInfo", paramMap);
|
|
result = true;
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* BOM Dummy Data 삭제
|
|
* @param paramMap
|
|
*/
|
|
public void deleteDummyBOMData(Map paramMap){
|
|
System.out.println("deleteDummyBOMData()..");
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
System.out.println("paramMap >> "+paramMap);
|
|
sqlSession.delete("part.deleteDummyAfterDeletePartRelatedInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 구조등록메뉴의 목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getBOMStandardStructureList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
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("part.getBOMStandardStructureListCnt", 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 = sqlSession.selectList("part.getBOMStandardStructureList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 최상위 레벨에 같은 Part No가 있는지 체크.
|
|
* @param paramMap
|
|
* @param rightCheckedArr
|
|
* @return
|
|
*/
|
|
public boolean hasSameTopPartNo(Map paramMap, List<String> rightCheckedArr){
|
|
boolean result = false;
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
paramMap.put("rightCheckedArr", rightCheckedArr);
|
|
System.out.println("paramMap : "+paramMap);
|
|
Map map = sqlSession.selectOne("part.getSameTopPartNoCnt", paramMap);
|
|
if(map != null && !map.isEmpty()){
|
|
int cnt = Integer.parseInt(CommonUtils.checkNull(map.get("CNT"), "0"));
|
|
System.out.println("cnt : "+cnt);
|
|
if(cnt > 0) result = true;
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 구조정보의 qty 변경.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public boolean structureQtySave(Map paramMap){
|
|
boolean result = false;
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
int cnt = sqlSession.update("part.structureQtySave", paramMap);
|
|
if(cnt > 0) result = true;
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 업로드된 Excel File을 통해 데이터를 Parsing 한다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList parsingStructureExcelFile(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"));
|
|
|
|
FileInputStream fis = new FileInputStream(path+"\\"+fileName);
|
|
XSSFWorkbook workBook = new XSSFWorkbook(fis);
|
|
XSSFSheet sheet = workBook.getSheetAt(0);
|
|
|
|
int rows = sheet.getPhysicalNumberOfRows();
|
|
for(int rowIndex= 2 ; rowIndex < rows ; rowIndex++){
|
|
XSSFRow row = sheet.getRow(rowIndex);
|
|
if(null != row){
|
|
|
|
HashMap partMap = new HashMap();
|
|
|
|
for(int columnIndex = 0 ; columnIndex < 3 ; columnIndex++){
|
|
XSSFCell cell = row.getCell(columnIndex);
|
|
//데이버 유형별 get date
|
|
String cellValue = "";
|
|
|
|
if(null == cell){
|
|
cellValue = "";
|
|
}else{
|
|
switch(cell.getCellType()){
|
|
case XSSFCell.CELL_TYPE_FORMULA:
|
|
cellValue = cell.getCellFormula();
|
|
System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_FORMULA:"+cellValue);
|
|
break;
|
|
case XSSFCell.CELL_TYPE_NUMERIC:
|
|
cellValue = (int)cell.getNumericCellValue()+"";
|
|
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 = "";
|
|
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;
|
|
}
|
|
}
|
|
|
|
//Parent Part No
|
|
if(0 == columnIndex){
|
|
partMap.put("no", rowIndex-1);
|
|
partMap.put("parentPartNo", cellValue);
|
|
}
|
|
//Part No
|
|
if(1 == columnIndex){
|
|
partMap.put("partNo", cellValue);
|
|
}
|
|
//Quantity
|
|
if(2 == columnIndex){
|
|
partMap.put("qty", cellValue);
|
|
}
|
|
}
|
|
String parentPartNo = CommonUtils.checkNull(partMap.get("parentPartNo"));
|
|
String partNo = CommonUtils.checkNull(partMap.get("partNo"));
|
|
String qty = CommonUtils.checkNull(partMap.get("qty"));
|
|
|
|
if("".equals(parentPartNo) && "false".equals(partNo) && "false".equals(qty)) break;
|
|
|
|
partMap.put("objId", CommonUtils.createObjId());
|
|
resultList.add(partMap);
|
|
}
|
|
}
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* Excel Parsing된 list를 받아, 해당 Data를 DB에 입력한다.
|
|
* @param paramMap
|
|
* @return DB에 등록된 targetObjId의 Part목록
|
|
*/
|
|
public List insertStructureTempExcelImportData(Map paramMap, ArrayList<HashMap> dataList){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
for(Map map : dataList){
|
|
String no = CommonUtils.checkNull(map.get("no"));
|
|
String parentObjId = CommonUtils.checkNull(map.get("parentObjId"));
|
|
String parentPartNo = CommonUtils.checkNull(map.get("parentPartNo"));
|
|
String objId = CommonUtils.checkNull(map.get("objId"));
|
|
String partNo = CommonUtils.checkNull(map.get("partNo"));
|
|
String qty = CommonUtils.checkNull(map.get("qty"));
|
|
String msg = CommonUtils.checkNull(map.get("msg"));
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
sqlParamMap.put("no", no);
|
|
sqlParamMap.put("parentObjId", parentObjId);
|
|
sqlParamMap.put("parentPartNo", parentPartNo);
|
|
sqlParamMap.put("objId", objId);
|
|
sqlParamMap.put("partNo", partNo);
|
|
sqlParamMap.put("qty", CommonUtils.checkNull(qty, "1"));
|
|
sqlParamMap.put("msg", msg);
|
|
|
|
sqlSession.insert("part.insertStructureTempExcelImportData", sqlParamMap);
|
|
// //0.1초 지연
|
|
// TimeUnit.MILLISECONDS.sleep(100);
|
|
//// Thread.sleep(100);
|
|
}
|
|
|
|
resultList = sqlSession.selectList("part.selectStructureTempExcelImportData", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 구조등록 Excel Import Data 임시 Row Data 삭제
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public boolean initializeStructureTempExcelImportData(Map paramMap){
|
|
boolean result= false;
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
int cnt = sqlSession.delete("part.initializeStructureTempExcelImportData", paramMap);
|
|
if(cnt > 0) result = true;
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 해당 part가 확정인지 확인.
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public boolean isPartComplete(Map paramMap){
|
|
boolean result = false;
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
Map map = sqlSession.selectOne("part.isPartComplete", paramMap);
|
|
if(map != null && !map.isEmpty()){
|
|
int cnt = Integer.parseInt(CommonUtils.checkNull(map.get("CNT")));
|
|
if(cnt > 0) result = true;
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 구조정보 엑셀 업로드 저장
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public String saveStructureExcelImportData(HttpServletRequest request, Map paramMap){
|
|
String result = "";
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
System.out.println("saveStructureExcelImportData()");
|
|
System.out.println("paramMap >> "+paramMap);
|
|
|
|
try{
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("writer", CommonUtils.checkNull(person.getUserId()));
|
|
|
|
String targetObjId = CommonUtils.checkNull(paramMap.get("targetObjId"));
|
|
|
|
String carTypeObjId = CommonUtils.checkNull(paramMap.get("search_carObjId"));
|
|
String productGroupObjId = CommonUtils.checkNull(paramMap.get("search_productGroupObjId"));
|
|
String productObjId = CommonUtils.checkNull(paramMap.get("search_productObjId"));
|
|
String regionObjId = CommonUtils.checkNull(paramMap.get("search_regionObjId"));
|
|
|
|
//1. 차종, 제품, 사양별 등록된 정보가 있는지 확인해서 없다면 새로 입력하고, 등록된 정보가 있다면 해당 정보를 비운 후, 저장한다.
|
|
String bomObjId = CommonUtils.checkNull(sqlSession.selectOne("part.getBOMStructureStandardObjId", paramMap));
|
|
System.out.println("bomObjId1 : "+bomObjId);
|
|
if("".equals(bomObjId)){
|
|
paramMap.put("bomObjId", targetObjId);
|
|
bomObjId = createBomStructureStandardInfo(paramMap);
|
|
System.out.println("bomObjId2 : "+bomObjId);
|
|
}else{
|
|
paramMap.put("bomObjId", bomObjId);
|
|
}
|
|
|
|
//2. targetObjId를 통해 이미 등록된 PART_BOM_QTY 테이블 초기화
|
|
sqlSession.delete("part.deleteStructureInfo", paramMap);
|
|
|
|
//3. targetObjId를 통해 PART_BOM_QTY 테이블 insert
|
|
int cnt = sqlSession.insert("part.saveStructureExcelImportData", paramMap);
|
|
|
|
if(cnt > 0) result = "저장되었습니다.";
|
|
|
|
}catch(Exception e){
|
|
result = "저장에 실패하였습니다.";
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 정전개 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getStructureAscendingList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
if(paramMap != null && !paramMap.isEmpty())
|
|
resultList = sqlSession.selectList("part.selectStructureAscendingList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 역전개 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getStructureDescendingList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
try{
|
|
if(paramMap != null && !paramMap.isEmpty()){
|
|
String partNo = CommonUtils.checkNull(paramMap.get("search_partNo"));
|
|
String partName = CommonUtils.checkNull(paramMap.get("search_partName"));
|
|
if(!"".equals(partNo) || !"".equals(partName)){
|
|
paramMap.put("isStartDevPart", "1");
|
|
resultList = sqlSession.selectList("part.selectStructureDescendingList", paramMap);
|
|
}
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* partNo를 통해 is_last = 1, upper(status) = 'COMPLETE' 상태인 Part의 Object ID를 반환한다.
|
|
* @param partNo
|
|
* @return
|
|
*/
|
|
public String getPartInfoObjId(String partNo){
|
|
String result = "";
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
result = sqlSession.selectOne("part.getPartInfoObjIdByPartNo", partNo);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**************************************************************************/
|
|
|
|
}
|