5029 lines
169 KiB
Java
5029 lines
169 KiB
Java
package com.pms.service;
|
||
|
||
import java.io.BufferedReader;
|
||
import java.io.File;
|
||
import java.io.FileInputStream;
|
||
import java.io.InputStreamReader;
|
||
import java.sql.Clob;
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.HashSet;
|
||
import java.util.Iterator;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.Set;
|
||
import java.util.concurrent.atomic.AtomicInteger;
|
||
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpSession;
|
||
|
||
import org.apache.commons.lang3.StringUtils;
|
||
import org.apache.ibatis.session.SqlSession;
|
||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||
import org.apache.poi.ss.usermodel.Cell;
|
||
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.ss.usermodel.Row;
|
||
import org.apache.poi.ss.usermodel.Sheet;
|
||
import org.apache.poi.ss.usermodel.Workbook;
|
||
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.service.BaseService;
|
||
import com.pms.common.utils.CommonUtils;
|
||
import com.pms.common.utils.Constants;
|
||
import com.pms.common.utils.MailUtil;
|
||
|
||
@Service
|
||
public class PartMngService extends BaseService {
|
||
|
||
CommonService commonService = null;
|
||
|
||
@Autowired
|
||
ProjectService projectService;
|
||
|
||
@Autowired
|
||
ProductionMngService productionMngService;
|
||
|
||
@Autowired
|
||
public void setCommonService(CommonService commonService){
|
||
this.commonService = commonService;
|
||
}
|
||
|
||
public Map setPartMngCommonCD(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;
|
||
}
|
||
|
||
/**
|
||
* PART 조회및 배포
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List partMngTempList(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
setPartMngCommonCD(paramMap);
|
||
|
||
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("partMng.partMngTempListCnt", 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("partMng.partMngTempList", paramMap);
|
||
|
||
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
/**
|
||
* PART 조회및 배포
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getPartMngList(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("partMng.partMngListCnt", paramMap);
|
||
|
||
String isPagingYN = CommonUtils.checkNull(paramMap.get("isPagingYN"), "");
|
||
if(!"N".equals(isPagingYN)) {
|
||
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("partMng.partMngList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
/**
|
||
* 부서정보 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List searchDeptList(Map paramMap){
|
||
List resultList = new ArrayList();
|
||
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultList = sqlSession.selectList("projectConcept.searchDeptList", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 수주활동 제품별 협조부서 등록
|
||
* @param paramMap
|
||
* @param checkedDeptList
|
||
*/
|
||
public int saveProjectConceptProductDeptInfo(Map paramMap, List<String> checkedDeptList){
|
||
int resultCnt = 0;
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
if(checkedDeptList != null){
|
||
for(String deptCode : checkedDeptList){
|
||
String objId = CommonUtils.createObjId();
|
||
|
||
//set parameter
|
||
paramMap.put("deptCode", deptCode);
|
||
paramMap.put("objId", objId);
|
||
|
||
resultCnt += (int)sqlSession.update("projectConcept.mergeProjectConceptProductDeptInfo", paramMap);
|
||
}
|
||
}
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultCnt;
|
||
}
|
||
|
||
/**
|
||
* 수주활동 제품별 협조부서 목록 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getProjectConceptProductDeptList(Map paramMap){
|
||
List resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultList = sqlSession.selectList("projectConcept.getProjectConceptProductDeptList", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 주주현황 담당자 분기별 실적
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public ArrayList<HashMap> makeGoalList(Map paramMap){
|
||
ArrayList resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getmakeGoalList", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
/**
|
||
* 수주활동 제품 정보 저장
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map saveProjectConceptProductInfo(HttpServletRequest request, Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
HttpSession session = request.getSession();
|
||
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
|
||
System.out.println("paramMap : "+paramMap);
|
||
|
||
//접속자
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
paramMap.put("userId", userId);
|
||
int cnt = sqlSession.update("projectConcept.mergeProjectConceptProductInfo", paramMap);
|
||
|
||
//수주활동 제품별 협조부서별 자료회신요청일 수정.
|
||
Iterator it = paramMap.keySet().iterator();
|
||
while(it.hasNext()){
|
||
String key = (String)it.next();
|
||
if(key.startsWith("replyReqDate")){
|
||
if(key.contains("_")){
|
||
String deptCode = key.substring(key.indexOf("_")+1);
|
||
String replyReqDate = CommonUtils.checkNull(paramMap.get(key));
|
||
|
||
Map deptInfoParamMap = new HashMap();
|
||
deptInfoParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("objId")));
|
||
deptInfoParamMap.put("deptCode", deptCode);
|
||
deptInfoParamMap.put("replyReqDate", replyReqDate);
|
||
|
||
System.out.println("deptInfoParamMap : "+deptInfoParamMap);
|
||
|
||
sqlSession.update("projectConcept.updateProjectConceptProductDeptReplyReqDate", deptInfoParamMap);
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
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 paramMap
|
||
* @return
|
||
*/
|
||
public List getProjectConceptProductList_forProjectConcept(Map paramMap){
|
||
List resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
resultList = sqlSession.selectList("projectConcept.getProjectConceptProductList_forProjectConcept", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 수주활동 정보 저장
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map saveProjectConceptInfo(HttpServletRequest request, Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
||
paramMap.put("userId", person.getUserId());
|
||
|
||
System.out.println("paramMap : "+paramMap);
|
||
int cnt = sqlSession.update("projectConcept.mergeProjectConceptInfo", paramMap);
|
||
|
||
//기존에 등록된 milestone 정보 삭제
|
||
sqlSession.delete("projectConcept.deleteProjectConceptMilestoneInfo", paramMap);
|
||
|
||
//수주활동 Milestone별 날짜 저장
|
||
Iterator it = paramMap.keySet().iterator();
|
||
while(it.hasNext()){
|
||
String key = (String)it.next();
|
||
if(key.startsWith("milestoneDate")){
|
||
if(key.contains("_")){
|
||
String milestoneObjId = key.substring(key.indexOf("_")+1);
|
||
String milestoneDate = CommonUtils.checkNull(paramMap.get(key));
|
||
|
||
Map milestoneParamMap = new HashMap();
|
||
milestoneParamMap.put("objId", CommonUtils.createObjId());
|
||
milestoneParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("objId")));
|
||
milestoneParamMap.put("oemObjId", CommonUtils.checkNull(paramMap.get("oemObjId")));
|
||
milestoneParamMap.put("milestoneObjId", milestoneObjId);
|
||
milestoneParamMap.put("milestoneDate", milestoneDate);
|
||
|
||
System.out.println("milestoneParamMap : "+milestoneParamMap);
|
||
|
||
//milestone 정보 저장
|
||
sqlSession.update("projectConcept.mergeProjectConceptMilestoneInfo", milestoneParamMap);
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
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 savePartMngTempInfo(HttpServletRequest request, Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
Map resultList = null;
|
||
Map sqlMap = new HashMap();
|
||
Map specMap = new HashMap();
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
//PART TEMP 수정
|
||
int cnt = sqlSession.update("partMng.updatePartTempInfo", 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;
|
||
}
|
||
|
||
|
||
/** PART복제
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map savePartCopyInfo(HttpServletRequest request, Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
Map resultList = null;
|
||
Map sqlMap = new HashMap();
|
||
Map specMap = new HashMap();
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
//PART COPY
|
||
int cnt = sqlSession.insert("partMng.insertPartCopy", paramMap);
|
||
|
||
//도면 복제
|
||
cnt = sqlSession.insert("partMng.insertPartCopyFile", 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;
|
||
}
|
||
|
||
public List overlapPartMng(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
//part 중복확인
|
||
resultList = sqlSession.selectList("partMng.overlapPartMng", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 설계변경 PART조회 저장
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map savePartMngChangeList(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
||
paramMap.put("WRITER", person.getUserId());
|
||
|
||
System.out.println("paramMap : "+paramMap);
|
||
String OBJID = CommonUtils.checkNull(request.getParameter("OBJID"), CommonUtils.createObjId());
|
||
String OBJID_PRODUCT = CommonUtils.checkNull(request.getParameter("OBJID_PRODUCT"));
|
||
paramMap.put("OBJID", OBJID);
|
||
|
||
List<Map<String, Object>> dataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("dataListJson")));
|
||
//if(!"".equals(authGroupObjid) && 0 < tagetMemberList.length){ html table version
|
||
if(CommonUtils.isNotEmpty(dataList)){
|
||
for (Map<String, Object> data : dataList) {
|
||
//System.out.println(data);
|
||
//String targetMemberId = CommonUtils.checkNull(data.get("USER_ID"));
|
||
//data.putAll(paramMap);
|
||
//data.put("STATUS", "REGIST");
|
||
//data.put("OBJID_PARENT", OBJID);
|
||
//data.put("PRODUCT", OBJID_PRODUCT);
|
||
|
||
//설변파트 신규 등록
|
||
//QTY 수량 update(QTY_TEMP)
|
||
//X bom 상태 변경(설계변경중)
|
||
data.put("ACTION_TYPE", "changeDesign");
|
||
this.savePartMng(request, data);
|
||
|
||
//for (Map<String, Object> projectMap : projectList) {
|
||
//System.out.println(projectMap);
|
||
/*
|
||
String PROJECT_NO = (String)projectMap.get("PROJECT_NO");
|
||
data.put("PROJECT_NO", PROJECT_NO);
|
||
data.put("OBJID", CommonUtils.checkNull(data.get("OBJID_"+PROJECT_NO), CommonUtils.createObjId()));
|
||
data.put("VALUE", data.get("VALUE_"+PROJECT_NO));
|
||
System.out.println(data);
|
||
*/
|
||
//}
|
||
}
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
public Map savePartMng(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
HttpSession session = request.getSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
String personId = CommonUtils.checkNull(person.getUserId());
|
||
paramMap.put("WRITER",personId);
|
||
|
||
System.out.println("paramMap :: " + paramMap);
|
||
|
||
String ACTION_TYPE = CommonUtils.checkNull(paramMap.get("ACTION_TYPE"));
|
||
String REVISION = CommonUtils.checkNull(paramMap.get("REVISION"));
|
||
|
||
if("changeDesign".equals(ACTION_TYPE)){
|
||
|
||
//설계변경 외건은 전부 라스트 0으로 변경
|
||
//sqlSession.update("partMng.updateislast", paramMap);
|
||
|
||
if(REVISION.equals("RE")){
|
||
paramMap.put("REVISION", "A");
|
||
}else{
|
||
paramMap.put("REVISION", CommonUtils.getNextRevision(REVISION));
|
||
}
|
||
paramMap.put("STATUS", "changing"); //create/changing/release
|
||
paramMap.put("EO_DATE", "");
|
||
paramMap.put("EO_NO", "");
|
||
|
||
//part 저장
|
||
int cnt = sqlSession.update("partMng.mergePartMngchangeDesign", paramMap);
|
||
//sqlSession.update("partMng.mergePartMngHistory", paramMap); //231211 히스토리는 파트확정에서
|
||
|
||
if(cnt > 0){
|
||
//QTY 수량 update(QTY_TEMP)
|
||
paramMap.put("QTY_TEMP", paramMap.get("Q_QTY"));
|
||
paramMap.put("STATUS", "beforeEdit");
|
||
sqlSession.update("partMng.structureQtySave", paramMap);
|
||
|
||
//사용되는 BOM 설계변경중으로
|
||
//sqlSession.update("partMng.changeStatusBomReportByPartNo", paramMap); //231211 히스토리는 파트확정에서
|
||
}
|
||
|
||
resultMap.put("result", true);
|
||
resultMap.put("msg", Message.SAVE_SUCCESS);
|
||
}else{
|
||
|
||
// Map tempMap = sqlSession.selectOne("partMng.getPART_NOCnt", paramMap);
|
||
// if(tempMap != null && !tempMap.isEmpty()){
|
||
// int cnt = Integer.parseInt(CommonUtils.checkNull(tempMap.get("cnt"), "0"));
|
||
// System.out.println("cnt : "+cnt);
|
||
// if(cnt == 0 || "Edit".equals(ACTION_TYPE)){
|
||
//part 저장
|
||
sqlSession.update("partMng.mergePartMng", paramMap);
|
||
//sqlSession.update("partMng.mergePartMngHistory", paramMap);
|
||
resultMap.put("result", true);
|
||
resultMap.put("msg", Message.SAVE_SUCCESS);
|
||
// }else{
|
||
// resultMap.put("result", "DUPLICATE");
|
||
// resultMap.put("msg", Message.DUPLICATE_PART_NO);
|
||
//
|
||
// }
|
||
// }
|
||
|
||
}
|
||
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
resultMap.put("result", false);
|
||
resultMap.put("msg", Message.SAVE_FAILED);
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* PART 상세 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getPartMngInfo(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
setPartMngCommonCD(paramMap);
|
||
|
||
resultMap = sqlSession.selectOne("partMng.partMngInfo", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* PART Detail 수정 저장
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public int updatePartDetail(HttpServletRequest request, Map paramMap){
|
||
int result = 0;
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
try{
|
||
// 품목 정보 업데이트 (품명, 재료, 열처리경도, 열처리방법, 표면처리, 공급업체, 범주이름, 비고)
|
||
result = sqlSession.update("partMng.updatePartDetail", paramMap);
|
||
|
||
if(result > 0){
|
||
sqlSession.commit();
|
||
}else{
|
||
sqlSession.rollback();
|
||
}
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
sqlSession.rollback();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 파트 배포
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map partMngDeploy(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
|
||
//String partMngList[] = request.getParameterValues("OBJID");
|
||
//if(null != partMngList && 0 < partMngList.length){
|
||
|
||
List<Map<String, Object>> dataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("dataListJson")));
|
||
//if(!"".equals(authGroupObjid) && 0 < tagetMemberList.length){ html table version
|
||
if(CommonUtils.isNotEmpty(dataList)){
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
String userId = person.getUserId(); //접속자
|
||
|
||
//for(int i=0;i<partMngList.length;i++){
|
||
for (Map<String, Object> data : dataList) {
|
||
System.out.println("data:"+data);
|
||
//String objId = CommonUtils.checkNull(partMngList[i]);
|
||
//String objId = CommonUtils.checkNull(data.get("OBJID"));
|
||
HashMap sqlParamMap = new HashMap();
|
||
//sqlParamMap.put("OBJID", objId);
|
||
sqlParamMap.putAll(data);
|
||
|
||
//동일 Part No를 가진 Part의 is_last를 0으로 변경한다.
|
||
sqlSession.update("partMng.partMngIsLastInit",sqlParamMap);
|
||
|
||
//확정 후 이력 저장
|
||
sqlParamMap.put("WRITER", userId);
|
||
|
||
//확정대상 Part의 is_last를 1로 변경한다.
|
||
sqlSession.update("partMng.partMngDeploy",sqlParamMap);
|
||
|
||
sqlParamMap.put("PARENT_PART_OBJID", "");
|
||
sqlParamMap.put("PARENT_PART_NO", "");
|
||
sqlParamMap.put("PARENT_QTY_CHILD_OBJID", "");
|
||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(data.get("BOM_REPORT_OBJID")));
|
||
sqlParamMap.put("CHANGE_OPTION", CommonUtils.checkNull(data.get("CHANGE_OPTION")));
|
||
sqlParamMap.put("CHANGE_TYPE", CommonUtils.checkNull(data.get("CHANGE_TYPE")));
|
||
//sqlParamMap.put("HISTORY_STATUS", "deploy");
|
||
sqlParamMap.put("HIS_STATUS", "DEPLOY");
|
||
//System.out.println(sqlParamMap);
|
||
|
||
String REVISION = CommonUtils.checkNull(data.get("REVISION"));
|
||
if("RE".equals(REVISION)) { //파트 신규등록 배포건
|
||
sqlParamMap.put("CHANGE_TYPE", "0001602"); //신규파트생성
|
||
//sqlParamMap.put("CHANGE_OPTION", "0001626"); //파트추가
|
||
}
|
||
|
||
sqlSession.update("partMng.insertPartMngHistory",sqlParamMap); //배포되기전 히스토리 먼저 저장(올바른 상태값 위해)
|
||
// sqlSession.update("partMng.mergePartMngHistory", sqlParamMap); //231211 히스토리는 파트확정에서
|
||
|
||
//QTY 상태 변경
|
||
sqlParamMap.put("STATUS", "editing");
|
||
sqlSession.update("partMng.structureQtySave", sqlParamMap);
|
||
|
||
//사용되는 BOM 설계변경중으로
|
||
sqlSession.update("partMng.changeStatusBomReportByPartObjid", sqlParamMap);
|
||
|
||
//구매품표준 사용된 part가 1개일 경우만 업데이트
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
for(int i=1;i<6;i++){
|
||
//sqlParamMap.clear(); // 이전 루프의 파라미터를 지웁니다.
|
||
String codeKey = "CODE" + i;
|
||
String codeValue = CommonUtils.checkNull(data.get(codeKey));
|
||
System.out.println("codeValue:"+codeValue);
|
||
if (codeValue != null && !codeValue.isEmpty()) {
|
||
sqlParamMap.put("CODE_ID", codeValue);
|
||
resultList = sqlSession.selectList("procurStandMgmt.sameStdCodeList", sqlParamMap);
|
||
if(resultList.size() == 1){
|
||
//Map<String, Object> uniqueResult = resultList.get(0);
|
||
|
||
//CODE_NAME을 설정하는 부분
|
||
String codeName;
|
||
switch (i) {
|
||
case 1:
|
||
codeName = CommonUtils.checkNull(data.get("MAJOR_CATEGORY"));
|
||
break;
|
||
case 2:
|
||
codeName = CommonUtils.checkNull(data.get("SUB_CATEGORY"));
|
||
break;
|
||
case 3:
|
||
codeName = CommonUtils.checkNull(data.get("MAKER"));
|
||
break;
|
||
case 4:
|
||
codeName = CommonUtils.checkNull(data.get("PART_NAME"));
|
||
break;
|
||
case 5:
|
||
codeName = CommonUtils.checkNull(data.get("SPEC"));
|
||
break;
|
||
default:
|
||
codeName = "";
|
||
}
|
||
sqlParamMap.put("CODE_NAME", codeName);
|
||
System.out.println("codeValue:"+codeValue+"codeName:"+codeName);
|
||
sqlSession.update("procurStandMgmt.updateCodeName", 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;
|
||
}
|
||
|
||
/**
|
||
* 파트 삭제
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map partMngDelete(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
|
||
//String partMngList[] = request.getParameterValues("OBJID");
|
||
//if(null != partMngList && 0 < partMngList.length){
|
||
|
||
List<Map<String, Object>> dataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("dataListJson")));
|
||
//if(!"".equals(authGroupObjid) && 0 < tagetMemberList.length){ html table version
|
||
if(CommonUtils.isNotEmpty(dataList)){
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
String userId = person.getUserId();
|
||
|
||
//for(int i=0;i<partMngList.length;i++){
|
||
for (Map<String, Object> data : dataList) {
|
||
System.out.println("data:"+data);
|
||
//String objId = CommonUtils.checkNull(partMngList[i]);
|
||
HashMap sqlParamMap = new HashMap();
|
||
|
||
//sqlParamMap.put("OBJID", objId);
|
||
sqlParamMap.put("WRITER", userId);
|
||
sqlParamMap.put("HISTORY_STATUS", "delete");
|
||
//sqlSession.update("partMng.insertPartMngHistory",sqlParamMap);
|
||
|
||
//sqlSession.delete("partMng.partMngDelete",sqlParamMap);
|
||
sqlSession.delete("partMng.partMngDelete2",data);
|
||
|
||
// /설계변경중인 파트 삭제시 구조정보 상태 원복
|
||
if(CommonUtils.isNotBlank(data.get("CHILD_OBJID"))){
|
||
sqlSession.update("partMng.rollbackBomPartQtyStatus",data);
|
||
}
|
||
}
|
||
/*}*/
|
||
sqlSession.commit();
|
||
resultMap.put("result", true);
|
||
resultMap.put("msg", Message.DELETE_SUCCESS);
|
||
}else {
|
||
resultMap.put("result", false);
|
||
resultMap.put("msg", Message.DELETE_FAILED);
|
||
}
|
||
/*}*/
|
||
}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 deleteStructure(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
|
||
String checkArr[] = (CommonUtils.checkNull(paramMap.get("checkArr"))).split(",");
|
||
|
||
if(0 == checkArr.length){
|
||
checkArr[0] = CommonUtils.checkNull(paramMap.get("checkArr"));
|
||
}
|
||
|
||
if(null != checkArr && 0 < checkArr.length){
|
||
Map sqlParamMap = new HashMap();
|
||
|
||
sqlParamMap.put("checkArr",checkArr);
|
||
//연결된 PART삭제
|
||
sqlSession.delete("partMng.deleteBomQtyPart",sqlParamMap);
|
||
|
||
sqlSession.delete("partMng.deleteBomReport",sqlParamMap);
|
||
|
||
sqlSession.delete("partMng.deleteBomQty",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;
|
||
}
|
||
|
||
/**
|
||
* 선택된 구조등록을 배포한다.
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map deployStructure(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
Map bomMap = new HashMap();
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
//String checkArr = CommonUtils.checkNull(paramMap.get("OBJID")); //240326 list건 적용(동시봄)
|
||
String checkArr[] = (CommonUtils.checkNull(paramMap.get("OBJID"))).split(",");
|
||
/*String checkArr[] = (CommonUtils.checkNull(paramMap.get("checkArr"))).split(",");
|
||
|
||
if(0 == checkArr.length){
|
||
checkArr[0] = CommonUtils.checkNull(paramMap.get("checkArr"));
|
||
}*/
|
||
|
||
for (String objid : checkArr) {
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("checkArr", objid);
|
||
bomMap = sqlSession.selectOne("partMng.getBOMStandardStructureList", sqlParamMap);
|
||
System.out.println("bomMap::"+bomMap);
|
||
|
||
String REVISION = CommonUtils.checkNull(bomMap.get("revision"));
|
||
System.out.println("REVISION::"+REVISION);
|
||
if(REVISION.equals("")){
|
||
sqlParamMap.put("REVISION", "RE");
|
||
}else if(REVISION.equals("RE")){
|
||
sqlParamMap.put("REVISION", "1");
|
||
}else{
|
||
sqlParamMap.put("REVISION", Integer.toString(Integer.parseInt(REVISION)+1));
|
||
}
|
||
|
||
//접속자
|
||
HttpSession session = request.getSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
String userId = person.getUserId();
|
||
sqlParamMap.put("WRITER", userId);
|
||
|
||
//구조 배포
|
||
sqlSession.update("partMng.deployBomReport",sqlParamMap);
|
||
|
||
//PART 배포
|
||
sqlSession.update("partMng.deployPartInfo",sqlParamMap);
|
||
|
||
//설계변경 외건은 전부 라스트 0으로 변경
|
||
sqlSession.update("partMng.updateislastByBomPartQty", paramMap);
|
||
|
||
//여기를 할때 파트확정이 되어 있어야 한다.(241220)
|
||
sqlSession.update("partMng.deployBomPartQty",sqlParamMap); //231208추가
|
||
//sqlSession.update("partMng.deployBomPartQtyDelete",sqlParamMap); //231208추가(설변 삭제건 물리삭제)
|
||
|
||
//EO 정보 업데이트
|
||
sqlSession.update("partMng.deployPartEoDate",sqlParamMap);
|
||
|
||
sqlSession.update("partMng.deployPartHisStatus",sqlParamMap); //240520 추가
|
||
|
||
String contract_objid = CommonUtils.checkNull(bomMap.get("contract_objid"));
|
||
sqlParamMap.put("CONTRACT_OBJID", contract_objid);
|
||
|
||
//contract_objid 정보 업데이트 231227 기존 로직 주석처리
|
||
//sqlParamMap.put("CHANGE_TYPE", "0001602"); //신규파트생성
|
||
//sqlSession.update("partMng.deployPartContractObjid",sqlParamMap);
|
||
}
|
||
|
||
sqlSession.commit();
|
||
resultMap.put("result", true);
|
||
resultMap.put("msg", Message.DISTRIBUTE_SUCCESS);
|
||
|
||
}catch(Exception e){
|
||
resultMap.put("result", false);
|
||
resultMap.put("msg", Message.DISTRIBUTE_FAILED);
|
||
sqlSession.rollback();
|
||
throw e;
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* BOM 배포사유 저장.
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public boolean saveChangeDesignInfo(Map paramMap){
|
||
boolean result = false;
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
int cnt = sqlSession.update("partMng.saveChangeDesignInfo", paramMap);
|
||
if(cnt > 0) result = true;
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 구조 정보 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getStructureInfo(Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
resultMap = sqlSession.selectOne("partMng.getStructureInfo", paramMap);
|
||
if(resultMap == null) resultMap = new HashMap();
|
||
// 대문자로 변환
|
||
resultMap = CommonUtils.toUpperCaseMapKey(resultMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* 구조 상태 업데이트
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public boolean updateStructureStatus(HttpServletRequest request, Map paramMap){
|
||
boolean result = false;
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
//접속자
|
||
HttpSession session = request.getSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
String userId = person.getUserId();
|
||
paramMap.put("EDITER", userId);
|
||
|
||
try{
|
||
// BOM 상태 업데이트
|
||
int cnt = sqlSession.update("partMng.updateStructureStatus", paramMap);
|
||
|
||
// 상태가 Y로 변경되면 연결된 파트들을 확정(release)
|
||
String status = CommonUtils.checkNull(paramMap.get("status"));
|
||
if("Y".equals(status)){
|
||
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||
Map deployParam = new HashMap();
|
||
deployParam.put("checkArr", objId);
|
||
|
||
// BOM에 연결된 파트들의 상태를 create -> release로 변경
|
||
sqlSession.update("partMng.deployPartInfo", deployParam);
|
||
}
|
||
|
||
sqlSession.commit();
|
||
if(cnt > 0) result = true;
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 구조등록메뉴의 목록 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getBOMStandardStructureList(HttpServletRequest request, Map paramMap){
|
||
List<Map<String,Object>> 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("partMng.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("partMng.getBOMStandardStructureList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
/**
|
||
* BOM 리비전 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getBOMStructureRev(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
resultMap = (HashMap)sqlSession.selectOne("partMng.getBOMStructureRev", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* BOM 구조 기본정보 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getBOMStructureStandardInfo(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
String objId = CommonUtils.checkNull(paramMap.get("objId"),(String) paramMap.get("OBJID"));
|
||
System.out.println("objId ---------->"+objId);
|
||
System.out.println("objId ---------->"+objId);
|
||
System.out.println("paramMap ---------->"+paramMap);
|
||
if("".equals(objId)){
|
||
objId = createBomStructureStandardInfo(request,paramMap);
|
||
paramMap.put("OBJID",objId);
|
||
}else{
|
||
paramMap.put("OBJID",objId);
|
||
}
|
||
|
||
resultMap = (HashMap)sqlSession.selectOne("partMng.getBOMStructureStandardInfoByObjId", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||
}
|
||
|
||
/**
|
||
* BOM 구조 기본정보를 등록 후, 생성한 Object id를 반환한다.
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public String createBomStructureStandardInfo(HttpServletRequest request,Map paramMap){
|
||
String result = "";
|
||
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
HttpSession session = request.getSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
|
||
//접속자
|
||
String userId = person.getUserId();
|
||
|
||
result = CommonUtils.createObjId();
|
||
|
||
paramMap.put("OBJID", result);
|
||
paramMap.put("WRITER", userId);
|
||
|
||
sqlSession.insert("partMng.createBOMReportStructureStandardInfo", paramMap);
|
||
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
sqlSession.rollback();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 구조등록 좌측 BOM트리목록을 받아온다.
|
||
* @param standardBOMInfo
|
||
* @return
|
||
*/
|
||
public List getBOMPartTreeList(Map standardBOMInfo){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
List<Map<String,Object>> FinalList = 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")));
|
||
//sqlParamMap.put("search_type", "working"); //bom조회 working조건 231208
|
||
// actionType과 search_type 둘 다 체크 (우선순위: search_type > actionType)
|
||
String searchType = CommonUtils.checkNull(standardBOMInfo.get("search_type"));
|
||
if(searchType.isEmpty()) {
|
||
searchType = CommonUtils.checkNull(standardBOMInfo.get("actionType"));
|
||
}
|
||
sqlParamMap.put("search_type", searchType);
|
||
|
||
resultList = sqlSession.selectList("partMng.getBOMTreeList", sqlParamMap);
|
||
int maxLevel = 0;
|
||
if(null != resultList && 0 < resultList.size()){
|
||
for(int i=0;i<resultList.size();i++){
|
||
Map resultMap = new HashMap();
|
||
resultMap = (HashMap)resultList.get(i);
|
||
int resultLevel = Integer.parseInt(CommonUtils.checkNull(resultMap.get("level"),"0"));
|
||
|
||
if(maxLevel < resultLevel){
|
||
maxLevel = resultLevel;
|
||
}
|
||
}
|
||
for(int i=0;i<resultList.size();i++){
|
||
Map resultMap = new HashMap();
|
||
resultMap = (HashMap)resultList.get(i);
|
||
resultMap.put("MAX_LEVEL", maxLevel);
|
||
FinalList.add(resultMap);
|
||
}
|
||
}
|
||
}catch(Exception e){
|
||
throw e;
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(FinalList);
|
||
}
|
||
|
||
/**
|
||
* 최상위 레벨에 같은 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("partMng.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;
|
||
}
|
||
|
||
/**
|
||
* 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("partMng.deletePartRelateInfo", paramMap);
|
||
sqlSession.insert("partMng.changeStatusBomReport", paramMap);
|
||
result = true;
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* BOM 구조 개별삭제(하위정보 포함)
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public boolean deleteStatusPartRelateInfo(HttpServletRequest request, Map paramMap){
|
||
boolean result = false;
|
||
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
System.out.println("deleteStatusPartRelateInfo.paramMap >> "+paramMap);
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
Map sqlParamMap = new HashMap();
|
||
//sqlParamMap.putAll(paramMap);
|
||
sqlParamMap.put("WRITER", userId);
|
||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(paramMap.get("OBJID")));
|
||
sqlParamMap.put("OBJID", CommonUtils.checkNull(paramMap.get("OBJID")));
|
||
sqlParamMap.put("leftObjId", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||
//sqlParamMap.put("PARENT_OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||
|
||
sqlParamMap.put("CHILD_OBJID", paramMap.get("leftObjId"));
|
||
//sqlParamMap.put("OBJID_LEFT", CommonUtils.checkNull(paramMap.get("partObjId")));
|
||
sqlParamMap.put("CHANGE_TYPE", CommonUtils.checkNull(paramMap.get("CHANGE_TYPE")));
|
||
sqlParamMap.put("CHANGE_OPTION", CommonUtils.checkNull(paramMap.get("CHANGE_OPTION")));
|
||
sqlParamMap.put("PARENT_PART_OBJID", "");
|
||
sqlParamMap.put("PARENT_PART_NO", "");
|
||
sqlParamMap.put("PARENT_QTY_CHILD_OBJID", "");
|
||
sqlParamMap.put("HIS_STATUS", "DEL");
|
||
sqlSession.update("partMng.insertPartMngHistoryWhenDelPartRelation", sqlParamMap); //231211 히스토리 저장(파트 삭제)
|
||
|
||
//sqlParamMap.put("OBJID", paramMap.get("partObjId"));
|
||
//sqlParamMap.put("PARENT_PART_OBJID", CommonUtils.checkNull(paramMap.get("leftParentObjId")));
|
||
//sqlParamMap.put("PARENT_PART_NO", CommonUtils.checkNull(paramMap.get("leftParentPartNo")));
|
||
//sqlParamMap.put("PARENT_QTY_CHILD_OBJID", CommonUtils.checkNull(paramMap.get("leftParentObjId")));
|
||
//sqlSession.update("partMng.insertPartMngHistory", sqlParamMap); //231211 히스토리 저장(파트 삭제)
|
||
|
||
sqlSession.delete("partMng.deletePartRelateInfoHis", paramMap);//231211 히스토리 삭제(파트추가된 것)
|
||
|
||
sqlSession.update("partMng.deleteStatusPartRelateInfo", paramMap);//구조정보 삭제(논리)
|
||
|
||
sqlSession.insert("partMng.changeStatusBomReport", paramMap);
|
||
sqlSession.commit();
|
||
result = true;
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* BOM구조 연결.
|
||
* @param paramMap
|
||
* @param partList
|
||
* @return
|
||
*/
|
||
public boolean relatePartInfo(HttpServletRequest request, Map paramMap, List<String> partList){
|
||
boolean result = false;
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
Map resultMap = new HashMap();
|
||
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
try{
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(paramMap.get("BOM_REPORT_OBJID")));
|
||
sqlParamMap.put("PARENT_OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||
sqlParamMap.put("PARENT_PART_OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||
sqlParamMap.put("PARENT_PART_NO", CommonUtils.checkNull(paramMap.get("leftPartNoQty")));
|
||
sqlParamMap.put("PARENT_QTY_CHILD_OBJID", CommonUtils.checkNull(paramMap.get("leftPartChildObjId")));
|
||
sqlParamMap.put("QTY", 1);
|
||
sqlParamMap.put("QTY_TEMP", 1);
|
||
sqlParamMap.put("STATUS", "adding");
|
||
sqlParamMap.put("WRITER", userId);
|
||
//sqlParamMap.put("bomReportObjId", CommonUtils.checkNull(paramMap.get("OBJID")));
|
||
//sqlParamMap.put("OBJID", CommonUtils.checkNull(paramMap.get("OBJID")));
|
||
//sqlParamMap.put("LEVEL", 2);
|
||
|
||
//resultList = sqlSession.selectList("partMng.getBOMTreeList", sqlParamMap);
|
||
//resultList = CommonUtils.toUpperCaseMapKey(resultList);
|
||
//resultMap = (HashMap)sqlSession.selectOne("partMng.getBOMStructureStandardInfoByObjId", sqlParamMap);
|
||
//System.out.println("resultList ::"+resultList);
|
||
//System.out.println("partList ::"+partList);
|
||
//System.out.println("resultMap ::"+resultMap);
|
||
|
||
for(String partObjId : partList){
|
||
sqlParamMap.put("OBJID", CommonUtils.createObjId());
|
||
sqlParamMap.put("CHILD_OBJID", CommonUtils.createObjId());
|
||
sqlParamMap.put("PART_NO", partObjId);
|
||
//sqlParamMap.put("PART_OBJID", partObjId);
|
||
|
||
sqlSession.insert("partMng.relatePartInfo", sqlParamMap);
|
||
|
||
sqlParamMap.put("OBJID", CommonUtils.checkNull(partObjId));
|
||
//sqlParamMap.put("CHILD_OBJID", "");
|
||
sqlParamMap.put("OBJID_LEFT", CommonUtils.checkNull(paramMap.get("partObjId")));
|
||
sqlParamMap.put("CHANGE_TYPE", CommonUtils.checkNull(paramMap.get("CHANGE_TYPE")));
|
||
sqlParamMap.put("HIS_STATUS", "ADD");
|
||
sqlParamMap.put("CHANGE_OPTION", CommonUtils.checkNull(paramMap.get("CHANGE_OPTION")));
|
||
sqlSession.update("partMng.insertPartMngHistory",sqlParamMap); //231211 히스토리 저장(파트 추가)
|
||
}
|
||
sqlSession.insert("partMng.changeStatusBomReport", sqlParamMap);
|
||
|
||
/*if(null != resultList && 0 < resultList.size()){
|
||
for(int i=0;i<resultList.size();i++){
|
||
Map partParamMap = new HashMap();
|
||
partParamMap = (HashMap)resultList.get(i);
|
||
//설계변경 기존부모 part 라스트 0으로 변경
|
||
sqlSession.update("partMng.updateislast", partParamMap);
|
||
|
||
partParamMap.put("OBJID", CommonUtils.createObjId());
|
||
partParamMap.put("CONTRACT_OBJID", resultMap.get("contract_objid"));
|
||
partParamMap.put("IS_LAST", resultMap.get("contract_objid"));
|
||
|
||
System.out.println("partParamMap ::"+partParamMap);
|
||
String REVISION = CommonUtils.checkNull(partParamMap.get("REVISION"));
|
||
|
||
if(REVISION.equals("RE")){
|
||
partParamMap.put("REVISION", "A");
|
||
}else{
|
||
partParamMap.put("REVISION", CommonUtils.getNextRevision(REVISION));
|
||
}
|
||
partParamMap.put("PART_NAME", item.get("part_name"));
|
||
partParamMap.put("REVISION", item.get("revision"));
|
||
partParamMap.put("BOM_REPORT_OBJID", item.get("bom_report_objid"));
|
||
partParamMap.put("LEVEL", item.get("level"));
|
||
partParamMap.put("CHILD_OBJID", item.get("child_objid"));
|
||
partParamMap.put("LAST_PART_OBJID", item.get("last_part_objid"));
|
||
partParamMap.put("PARENT_PART_NO", item.get("parent_part_no"));
|
||
partParamMap.put("SEQ", item.get("seq"));
|
||
partParamMap.put("QTY", item.get("qty"));
|
||
partParamMap.put("PARENT_OBJID", item.get("parent_objid"));
|
||
partParamMap.put("PART_NO", item.get("part_no"));
|
||
partParamMap.put("SUB_PART_CNT", item.get("sub_part_cnt"));
|
||
|
||
//부모 part 복사 저장
|
||
sqlSession.update("partMng.mergePartMngchangeDesign", partParamMap);
|
||
sqlSession.update("partMng.mergePartMngHistory", partParamMap);
|
||
} */
|
||
result = true;
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 구조정보의 qty 변경.
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public boolean structureQtySave(HttpServletRequest request, Map paramMap){
|
||
boolean result = false;
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
//paramMap.put("QTY_TEMP", paramMap.get("Q_QTY"));
|
||
//paramMap.put("STATUS", "beforeEdit");
|
||
/*
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
paramMap.put("WRITER", userId);
|
||
*/
|
||
|
||
int cnt = sqlSession.update("partMng.structureQtySave", paramMap);
|
||
if(cnt > 0){
|
||
sqlSession.insert("partMng.changeStatusBomReport", paramMap);
|
||
|
||
//구조 먼저 연결(파트추가)한 히스토리에 수량 변경
|
||
sqlSession.update("partMng.structureQtySaveHis", paramMap);
|
||
//sqlSession.update("partMng.insertPartMngHistory",paramMap);
|
||
result = true;
|
||
sqlSession.commit();
|
||
}
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
sqlSession.rollback();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* BOM에 연결 할 파트 목록을 가져온다.
|
||
* 이미 연결된 파트는 제외한다.
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getToConnectPartMngList(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
setPartMngCommonCD(paramMap);
|
||
|
||
resultList = (ArrayList)sqlSession.selectList("partMng.getToConnectPartMngList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
/**
|
||
* PART 목록 총 개수 조회 (페이징용)
|
||
*/
|
||
public int getToConnectPartMngListCount(HttpServletRequest request, Map paramMap){
|
||
int totalCount = 0;
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
setPartMngCommonCD(paramMap);
|
||
|
||
totalCount = (Integer)sqlSession.selectOne("partMng.getToConnectPartMngListCount", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return totalCount;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 정전개 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getStructureAscendingMultiList(HttpServletRequest request,Map paramMap, List<Map<String,Object>> ListVC){
|
||
List<Map<String,Object>> spareList = new ArrayList();
|
||
List<Map<String,Object>> spareListVCqty = new ArrayList();
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
spareList = sqlSession.selectList("partMng.selectStructureAscendingMultiList", paramMap);
|
||
spareListVCqty = sqlSession.selectList("partMng.selectStructureAscendingMultiListVCqty", paramMap);
|
||
|
||
spareList = CommonUtils.toUpperCaseMapKey(spareList);
|
||
spareListVCqty = CommonUtils.toUpperCaseMapKey(spareListVCqty);
|
||
|
||
int maxLevel = 0;
|
||
|
||
if(null != spareList && 0 < spareList.size()){
|
||
for(int i=0;i<spareList.size();i++){
|
||
Map resultMap = new HashMap();
|
||
resultMap = (HashMap)spareList.get(i);
|
||
|
||
int resultLevel = Integer.parseInt(CommonUtils.checkNull(resultMap.get("LEV"),"0"));
|
||
|
||
if(maxLevel < resultLevel){
|
||
maxLevel = resultLevel;
|
||
}
|
||
}
|
||
|
||
for(int i=0;i<spareList.size();i++){
|
||
Map resultMap = new HashMap();
|
||
resultMap = (HashMap)spareList.get(i);
|
||
|
||
resultMap.put("MAX_LEVEL", maxLevel);
|
||
|
||
int level = Integer.parseInt(CommonUtils.checkNull(resultMap.get("LEV"),"0"));
|
||
|
||
|
||
for(int j=0;j<maxLevel;j++){
|
||
String levelSymbol = "";
|
||
|
||
if((j+1) == level){
|
||
levelSymbol = "*";
|
||
}else{
|
||
levelSymbol = "";
|
||
}
|
||
resultMap.put("LEV_"+Integer.toString((j+1)), levelSymbol);
|
||
}
|
||
|
||
String path = CommonUtils.checkNull(resultMap.get("PATH"),"");
|
||
|
||
for(int k=0;k<spareListVCqty.size();k++){ //gty값 목록
|
||
Map resultMapVCqty = (HashMap)spareListVCqty.get(k);
|
||
String pathVCqty = CommonUtils.checkNull(resultMapVCqty.get("PATH"),"");
|
||
String vc_nameVCqty = CommonUtils.checkNull(resultMapVCqty.get("VC"),"");
|
||
String qty = CommonUtils.checkNull(resultMapVCqty.get("QTY"),"");
|
||
|
||
for(int m=0;m<ListVC.size();m++){ //VC 컬럼 유동적 : 최대 5개 이내로 추후 성능문제시 수정
|
||
String vc_name = CommonUtils.checkNull(((HashMap)ListVC.get(m)).get("VC"),"");
|
||
|
||
if(path.equals(pathVCqty) && vc_name.equals(vc_nameVCqty)){ //path와 VC가 같으면
|
||
resultMap.put("VC_"+Integer.toString((m+1)), qty); //gty값 세팅
|
||
// TO-DO : 사용한 gty 행 remove : 불필요한 반복 제거
|
||
}
|
||
}
|
||
}
|
||
|
||
resultList.add(resultMap);
|
||
}
|
||
}
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
public List getStructureAscendingMultiListVC(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
try{
|
||
resultList = sqlSession.selectList("partMng.selectStructureAscendingMultiListVC", paramMap);
|
||
resultList = CommonUtils.toUpperCaseMapKey(resultList);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
|
||
/**
|
||
* 정전개 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getStructureAscendingList(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
System.out.println("paramMap :: " + paramMap);
|
||
resultList = sqlSession.selectList("partMng.selectStructureAscendingList", paramMap);
|
||
resultList = CommonUtils.toUpperCaseMapKey(resultList);
|
||
|
||
// 쿼리에서 이미 MAX_LEVEL을 제공하므로 추가 처리 불필요
|
||
// LEV_X 컬럼도 JSP에서 동적으로 처리하므로 생략
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 역전개 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getStructureDescendingList(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> 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)){
|
||
setPartMngCommonCD(paramMap);
|
||
resultList = sqlSession.selectList("partMng.selectStructureDescendingList", paramMap);
|
||
resultList = CommonUtils.toUpperCaseMapKey(resultList);
|
||
|
||
// 쿼리에서 이미 MAX_LEVEL을 제공하므로 추가 처리 불필요
|
||
System.out.println("resultList:"+resultList);
|
||
}
|
||
}
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
/** 영업활동삭제
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map delOrderMgmt(HttpServletRequest request, Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
Map sqlMap = new HashMap();
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
String Key = (String) paramMap.get("delKey");
|
||
String [] delKey = Key.split(",");
|
||
|
||
sqlMap.put("delObjKeyarr", delKey);
|
||
int cnt = sqlSession.delete("projectConcept.deleteOrdermgmt", sqlMap);
|
||
|
||
if(cnt > 0){
|
||
resultMap.put("result", true);
|
||
resultMap.put("msg", Message.DELETE_SUCCESS);
|
||
}
|
||
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
resultMap.put("result", false);
|
||
resultMap.put("msg", Message.DELETE_FAILED);
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
|
||
/**
|
||
* 수주활동 상세 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getProjectConceptInfo(Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultMap = sqlSession.selectOne("orderMgmt.getOrderMgmtInfo", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
|
||
/**
|
||
*영업정보 엑셀저장
|
||
* @param request
|
||
* @param paramMap
|
||
* @throws Exception
|
||
*/
|
||
public void UploadOrderMgmt(HttpServletRequest request,Map paramMap) throws Exception{
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
try{
|
||
|
||
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);
|
||
HashMap partMap = new HashMap();
|
||
int rows = sheet.getPhysicalNumberOfRows();
|
||
|
||
|
||
System.out.println("*****************************" +rows);
|
||
System.out.println("*****************************" +rows);
|
||
System.out.println("*****************************" +rows);
|
||
System.out.println("*****************************" +rows);
|
||
for(int rowIndex= 1 ; rowIndex < rows ; rowIndex++){
|
||
String column ="false";
|
||
XSSFRow row = sheet.getRow(rowIndex);
|
||
if(null != row && rowIndex <= 15){
|
||
|
||
for(int columnIndex = 0 ; columnIndex < 47 ; 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 = cell.getNumericCellValue()+"";
|
||
//cellValue = String.format("%.2f", Double.parseDouble(cellValue));
|
||
cellValue = String.format("%.0f", Double.parseDouble(cellValue));
|
||
System.out.println("cellValue1:"+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 = "";
|
||
}
|
||
|
||
//obj생성
|
||
String ObjId = CommonUtils.createObjId();
|
||
|
||
|
||
|
||
//수주번호
|
||
if(0 == columnIndex){
|
||
if("".equals(cellValue)){
|
||
column ="false";
|
||
}else{
|
||
column ="true";
|
||
partMap.put("obtain_no", cellValue);
|
||
}
|
||
|
||
}
|
||
|
||
//OBJID
|
||
partMap.put("ObjId", ObjId);
|
||
|
||
|
||
//프로젝트 넘버
|
||
if(1 == columnIndex){
|
||
partMap.put("project_no", cellValue);
|
||
}
|
||
//구분코드
|
||
if(2 == columnIndex){
|
||
partMap.put("region_high_cd",cellValue);
|
||
}
|
||
|
||
//국가코드
|
||
if(4 == columnIndex){
|
||
partMap.put("region_mid_cd",cellValue);
|
||
}
|
||
|
||
//지역코드
|
||
if(6 == columnIndex){
|
||
partMap.put("region_low_cd",cellValue);
|
||
}
|
||
|
||
//거래처코드
|
||
if(8 == columnIndex){
|
||
partMap.put("customer_cd",cellValue);
|
||
}
|
||
|
||
|
||
//사업자 등록번호
|
||
if(10 == columnIndex){
|
||
partMap.put("bus_lic_num",cellValue);
|
||
}
|
||
|
||
//담당자
|
||
if(11 == columnIndex){
|
||
partMap.put("customer_person",cellValue);
|
||
}
|
||
|
||
//연락처
|
||
if(12 == columnIndex){
|
||
partMap.put("customer_phone",cellValue);
|
||
}
|
||
|
||
//e-mail
|
||
if(13 == columnIndex){
|
||
partMap.put("customer_email",cellValue);
|
||
}
|
||
|
||
//부서(학과)
|
||
if(14 == columnIndex){
|
||
partMap.put("customer_div",cellValue);
|
||
}
|
||
|
||
//주소
|
||
if(15 == columnIndex){
|
||
partMap.put("customer_addr",cellValue);
|
||
}
|
||
|
||
//계약유형
|
||
if(16 == columnIndex){
|
||
partMap.put("c_type_cd",cellValue);
|
||
}
|
||
|
||
//계약기관
|
||
if(18 == columnIndex){
|
||
partMap.put("c_agency_cd",cellValue);
|
||
}
|
||
|
||
|
||
//계약구분
|
||
if(20 == columnIndex){
|
||
partMap.put("c_class_cd",cellValue);
|
||
}
|
||
|
||
|
||
//계약구분
|
||
if(22 == columnIndex){
|
||
partMap.put("spec_cd",cellValue);
|
||
}
|
||
|
||
|
||
//수주명
|
||
if(24 == columnIndex){
|
||
partMap.put("order_title",cellValue);
|
||
}
|
||
|
||
//담당자ID
|
||
if(25 == columnIndex){
|
||
partMap.put("writer",cellValue);
|
||
}
|
||
|
||
//접수일
|
||
if(26 == columnIndex){
|
||
partMap.put("regdate",cellValue);
|
||
}
|
||
|
||
//진행상황
|
||
if(27 == columnIndex){
|
||
partMap.put("status_cd",cellValue);
|
||
}
|
||
|
||
//계약결과
|
||
if(29 == columnIndex){
|
||
partMap.put("result_cd",cellValue);
|
||
}
|
||
|
||
//이탈원인
|
||
if(31 == columnIndex){
|
||
partMap.put("reason",cellValue);
|
||
}
|
||
|
||
//비고
|
||
if(32 == columnIndex){
|
||
partMap.put("content",cellValue);
|
||
}
|
||
|
||
//매출일자(매출예정)
|
||
if(33 == columnIndex){
|
||
partMap.put("sales_p_date",cellValue);
|
||
}
|
||
|
||
|
||
/* //소계(매출예정)
|
||
if(34 == columnIndex){
|
||
partMap.put("sub_p_sum",cellValue);
|
||
} */
|
||
|
||
|
||
//제품(매출예정)
|
||
if(34 == columnIndex){
|
||
partMap.put("dev_p_product",cellValue);
|
||
}
|
||
|
||
|
||
//상품(매출예정)
|
||
if(35 == columnIndex){
|
||
partMap.put("sale_p_product",cellValue);
|
||
}
|
||
|
||
//출고예정일
|
||
if(36 == columnIndex){
|
||
partMap.put("sch_date",cellValue);
|
||
}
|
||
|
||
|
||
/* //소계(제조원가)
|
||
if(38 == columnIndex){
|
||
partMap.put("sub_ps_sum",cellValue);
|
||
}*/
|
||
|
||
|
||
//제품(제조원가)
|
||
if(37 == columnIndex){
|
||
partMap.put("dev_ps_product",cellValue);
|
||
}
|
||
|
||
|
||
//상품(제조원가)
|
||
if(38 == columnIndex){
|
||
partMap.put("sale_ps_product",cellValue);
|
||
}
|
||
|
||
//매출일(매출실적)
|
||
if(39 == columnIndex){
|
||
partMap.put("sales_r_date",cellValue);
|
||
}
|
||
|
||
/*//소계(매출실적)
|
||
if(42 == columnIndex){
|
||
partMap.put("sub_r_sum",cellValue);
|
||
}*/
|
||
|
||
//제품(매출실적)
|
||
if(40 == columnIndex){
|
||
partMap.put("dev_r_product",cellValue);
|
||
}
|
||
|
||
//상품(매출실적)
|
||
if(41 == columnIndex){
|
||
partMap.put("sale_r_product",cellValue);
|
||
}
|
||
|
||
//수금일
|
||
if(42 == columnIndex){
|
||
partMap.put("recv_date",cellValue);
|
||
}
|
||
|
||
//달성율
|
||
if(43 == columnIndex){
|
||
partMap.put("achievement_rate",cellValue);
|
||
}
|
||
}
|
||
}
|
||
System.out.println("***********************"+column);
|
||
System.out.println("***********************"+column);
|
||
System.out.println("***********************"+column);
|
||
if("true".equals(column)){
|
||
sqlSession.insert("projectConcept.orderExcelupload", partMap);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
|
||
throw e;
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 수주활동 main 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
|
||
public List obtainmainStatusList(HttpServletRequest request,Map paramMap){
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.obtainmainStatusList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 계약현황 main 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
|
||
public List orderCntList(HttpServletRequest request,Map paramMap){
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.orderCntList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
/**
|
||
* 프로젝트 목록을 가져온다.
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getGoalList(HttpServletRequest request, Map paramMap){
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
List resultList = new ArrayList();
|
||
try{
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getmainchartList",paramMap);
|
||
}catch(Exception e){
|
||
throw e;
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 목표등록 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getgoalMgmtList(HttpServletRequest request,Map paramMap){
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
|
||
//접속자
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
paramMap.put("writer", userId);
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getgoalMgmtList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 목표등록 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getgoalMgmtTeamList(HttpServletRequest request,Map paramMap){
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
|
||
//접속자
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
paramMap.put("writer", userId);
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getgoalMgmtTeamList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
/** 목표등록 삭제
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map delgoalEnroll(HttpServletRequest request, Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
Map sqlMap = new HashMap();
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
String Key = (String) paramMap.get("delKey");
|
||
String [] delKey = Key.split(",");
|
||
|
||
sqlMap.put("delObjKeyarr", delKey);
|
||
int cnt = sqlSession.delete("projectConcept.delgoalEnroll", sqlMap);
|
||
|
||
if(cnt > 0){
|
||
resultMap.put("result", true);
|
||
resultMap.put("msg", Message.DELETE_SUCCESS);
|
||
}
|
||
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
resultMap.put("result", false);
|
||
resultMap.put("msg", Message.DELETE_FAILED);
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* 목표등록 합계
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getgoalMgmtAverage(HttpServletRequest request,Map paramMap){
|
||
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
|
||
//접속자
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
paramMap.put("writer", userId);
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getgoalMgmtAverage", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
/**
|
||
* 목표등록 합계
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getgoalMgmtTeamAverage(HttpServletRequest request,Map paramMap){
|
||
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
|
||
HttpSession session = request.getSession();
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getgoalMgmtTeamAverage", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
|
||
/**
|
||
* 영업현황 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
/**
|
||
* 수주관리 목록조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getOrderMgntSubList(HttpServletRequest request,Map paramMap){
|
||
List<Map> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultList = (ArrayList)sqlSession.selectList("projectConcept.getorderMgmtSubList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 수주활동의 Milestone 목록 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List getProjectConceptMilestoneList(Map paramMap){
|
||
List resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
if("edit".equals(CommonUtils.checkNull(paramMap.get("mode")))){
|
||
resultList = sqlSession.selectList("projectConcept.getProjectConceptMilestoneList", paramMap);
|
||
}else{
|
||
resultList = sqlSession.selectList("projectConcept.getProjectConceptMilestoneList2", paramMap);
|
||
}
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 수주활동 제품별 정보 조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getProjectConceptProductInfo(Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultMap = sqlSession.selectOne("projectConcept.getProjectConceptProductInfo", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
/**
|
||
* 수주활동 제품별 수주결과 수정
|
||
* @param paramMap
|
||
*/
|
||
public void updateProjectConceptProdBiddingResult(Map paramMap){
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
sqlSession.update("projectConcept.updateProjectConceptProdBiddingResult", paramMap);
|
||
|
||
//입찰결과 등록시 해당 값 완료로 변경
|
||
String biddingResult = CommonUtils.checkNull(paramMap.get("biddingResult"));
|
||
if(!"".equals(biddingResult)) paramMap.put("changeStatus", "complete");
|
||
else paramMap.put("changeStatus", "create");
|
||
|
||
sqlSession.update("projectConcept.updateProjectConceptStatusComplete", paramMap);
|
||
|
||
sqlSession.commit();
|
||
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 수주활동 메일 발송.
|
||
* 지정된 인원에게 메일을 발송한다.
|
||
* @param request
|
||
* @param paramMap
|
||
*/
|
||
public void sendMailProjectConceptInfo(HttpServletRequest request, Map paramMap){
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
String[] receivers = request.getParameterValues("chk");
|
||
System.out.println("paramMap : "+paramMap);
|
||
System.out.println("receivers.length : "+receivers.length);
|
||
|
||
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
||
Map userInfo = person.getLoginInfo();
|
||
|
||
//1. project concept의 입찰제품 정보 조회
|
||
Map info = sqlSession.selectOne("projectConcept.getProjectConceptInfo", paramMap);
|
||
|
||
//2. 해당 내용을 담은 htmlBody 생성
|
||
// String bodyContents = MailUtil.getHTMLContents("", info);
|
||
|
||
|
||
//mail body contents 구성
|
||
Map mailParamMap = new HashMap();
|
||
|
||
//제품정보조회
|
||
Map productInfo = sqlSession.selectOne("mail.getProjectConceptProductInfo", paramMap);
|
||
mailParamMap.putAll(productInfo);
|
||
|
||
//제품별 협조부서 목록조회
|
||
List<Map> productRelDeptList = sqlSession.selectList("mail.getProjectConceptProductRelDeptList", paramMap);
|
||
|
||
String subject = "["+CommonUtils.checkNull(productInfo.get("CAR_CODE"))+" ("+CommonUtils.checkNull(productInfo.get("CAR_NAME"))+")] "+Message.MAIL_SUBJECT_PROJECT_CONCEPT_REQ_FILE;
|
||
mailParamMap.put("SUBJECT", subject);
|
||
|
||
String deptList = "";
|
||
deptList += "<table border='1' class='table' style='width:450px;'>";
|
||
deptList += "<colgroup>";
|
||
deptList += "<col width='30%'>";
|
||
deptList += "<col width='*%'>";
|
||
deptList += "</colgroup>";
|
||
for(Map map : productRelDeptList){
|
||
String deptCode = CommonUtils.checkNull(map.get("DEPT_CODE"));
|
||
String deptName = CommonUtils.checkNull(map.get("DEPT_NAME"));
|
||
String replyReqDate = CommonUtils.checkNull(map.get("REPLY_REQ_DATE"));
|
||
|
||
deptList += "<tr>";
|
||
deptList += "<td>"+deptName+"</td>";
|
||
deptList += "<td>"+replyReqDate+"</td>";
|
||
deptList += "</tr>";
|
||
}
|
||
deptList += "</table>";
|
||
|
||
mailParamMap.put("DEPT_LIST", deptList);
|
||
|
||
String bodyContents = MailUtil.getHTMLContents("projectConceptMailTemplate", mailParamMap);
|
||
|
||
//3. 메일 발송 대상 조회
|
||
for(String receiver : receivers){
|
||
if(receiver.contains(":")){
|
||
String[] receiverSplit = receiver.split(":");
|
||
|
||
String receiverId = CommonUtils.checkNull(receiverSplit[0]);
|
||
String receiverEmail = CommonUtils.checkNull(receiverSplit[1]);
|
||
|
||
//4. 메일 발송
|
||
MailUtil.sendMail(CommonUtils.checkNull(productInfo.get("WRITER")), CommonUtils.checkNull(productInfo.get("WRITER_EMAIL")), receiverId, receiverEmail, null, subject, bodyContents, Constants.MAIL_TYPE_PROJECT_CONCEPT);
|
||
}
|
||
}
|
||
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 수주활동 QNA 메일 발송.
|
||
* 지정된 인원에게 메일을 발송한다.
|
||
* @param request
|
||
* @param paramMap
|
||
*/
|
||
public void sendMailProjectConceptQNAInfo(HttpServletRequest request, Map paramMap){
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
String[] receivers = request.getParameterValues("chk");
|
||
System.out.println("paramMap : "+paramMap);
|
||
System.out.println("receivers.length : "+receivers.length);
|
||
|
||
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
||
Map userInfo = person.getLoginInfo();
|
||
|
||
//1. project concept QNA 정보조회
|
||
Map info = sqlSession.selectOne("mail.getProjectConceptQNAInfo", paramMap);
|
||
|
||
//2. 해당 내용을 담은 htmlBody 생성
|
||
// String bodyContents = MailUtil.getHTMLContents("", info);
|
||
|
||
//mail body contents 구성
|
||
Map mailParamMap = new HashMap();
|
||
|
||
String subject = "["+CommonUtils.checkNull(info.get("CAR_CODE"))+" ("+CommonUtils.checkNull(info.get("CAR_NAME"))+")] "+Message.MAIL_SUBJECT_PROJECT_CONCEPT_QNA;
|
||
mailParamMap.put("SUBJECT", subject);
|
||
mailParamMap.putAll(info);
|
||
|
||
String bodyContents = MailUtil.getHTMLContents("projectConceptQNAMailTemplate", mailParamMap);
|
||
|
||
//3. 메일 발송 대상 조회
|
||
for(String receiver : receivers){
|
||
if(receiver.contains(":")){
|
||
String[] receiverSplit = receiver.split(":");
|
||
|
||
String receiverId = CommonUtils.checkNull(receiverSplit[0]);
|
||
String receiverEmail = CommonUtils.checkNull(receiverSplit[1]);
|
||
|
||
//4. 메일 발송
|
||
MailUtil.sendMail(CommonUtils.checkNull(info.get("WRITER")), CommonUtils.checkNull(info.get("WRITER_EMAIL")), receiverId, receiverEmail, null, subject, bodyContents, Constants.MAIL_TYPE_PROJECT_CONCEPT);
|
||
}
|
||
}
|
||
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 수주활동 제품별 확정.
|
||
* 모든 제품이 확정되었을경우 수주활동을 종료시킨다.
|
||
* @param request
|
||
* @param paramMap
|
||
*/
|
||
public void completeProjectConceptProductInfo(HttpServletRequest request, Map paramMap){
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
System.out.println("paramMap : "+paramMap);
|
||
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
//입찰품목 상태 complete으로 변경
|
||
sqlSession.update("projectConcept.completeProjectConceptProductInfo", paramMap);
|
||
|
||
//입찰품목의 상태가 create인 CNT 조회
|
||
Map cntMap = sqlSession.selectOne("projectConcept.getProjectConceptProductCreateCnt", paramMap);
|
||
System.out.println("cntMap : "+cntMap);
|
||
|
||
int cnt = Integer.parseInt(CommonUtils.checkNull(cntMap.get("CNT"), "0"));
|
||
System.out.println("cnt : "+cnt);
|
||
if(cnt == 0){
|
||
//수주활동 상태 complete으로 변경.
|
||
sqlSession.update("projectConcept.completeProjectConceptInfo", paramMap);
|
||
}
|
||
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 수주활동 중복 등록체크 (false : 중복있음, true : 중복없음)
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getProjectConceptDuplicateCnt(Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
Map map = sqlSession.selectOne("projectConcept.getProjectConceptDuplicateCnt", paramMap);
|
||
if(map != null){
|
||
int cnt = Integer.parseInt(CommonUtils.checkNull(map.get("CNT"), "0"));
|
||
if(cnt > 0){
|
||
resultMap.put("result", false);
|
||
}else{
|
||
resultMap.put("result", true);
|
||
}
|
||
|
||
}
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return resultMap;
|
||
}
|
||
|
||
/*jmpark end*/
|
||
/*************************************************************************************************************************/
|
||
|
||
|
||
|
||
/*************************************************************************************************************************/
|
||
/*edhwang start*/
|
||
|
||
/*edhwang end*/
|
||
/*************************************************************************************************************************/
|
||
|
||
|
||
/*************************************************************************************************************************/
|
||
/*dhchoi start*/
|
||
/**
|
||
* 수주활동 저장
|
||
* @param paramMap
|
||
*/
|
||
public void saveQnAProjectConcept(Map paramMap){
|
||
SqlSession sqlSession =null;
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
System.out.println(paramMap);
|
||
sqlSession.update("projectConcept.saveQnaProjectConceptInfo", paramMap);
|
||
}
|
||
|
||
/**
|
||
* QnaListPage 목록
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List qnaListPage(HttpServletRequest request,Map paramMap){
|
||
List 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("projectConcept.getQnaListCnt", 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("projectConcept.getQnaListPage", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* Qna 수정페이지
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getQnADetailInfo(Map paramMap){
|
||
HashMap resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
System.out.println("getQnADetailInfo"+paramMap);
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultMap = (HashMap)sqlSession.selectOne("projectConcept.getQnaInfo", paramMap);
|
||
if(null != resultMap){
|
||
resultMap.put("CONTENTS", CommonUtils.getClobToString((Clob)resultMap.get("CONTENTS")));
|
||
}
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return resultMap;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* BomExcelList 목록
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List BomExcelList(HttpServletRequest request,Map paramMap){
|
||
List resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultList = (ArrayList)sqlSession.selectList("partMng.getPartBomTempList", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
|
||
|
||
public String getCellValue(Row row, int columnIndex, DataFormatter formatter, AtomicInteger emptyColCnt){
|
||
Cell cell = row.getCell(columnIndex);
|
||
//데이버 유형별 get date
|
||
String cellValue = "";
|
||
//System.out.println("columnSeq:"+columnSeq + " " + "columnIndex:"+columnIndex);
|
||
|
||
if(null == cell){
|
||
cellValue = "";
|
||
}else{
|
||
switch(cell.getCellType()){
|
||
case Cell.CELL_TYPE_FORMULA:
|
||
cellValue = cell.getCellFormula();
|
||
break;
|
||
case Cell.CELL_TYPE_NUMERIC:
|
||
cellValue = formatter.formatCellValue(cell);
|
||
break;
|
||
case Cell.CELL_TYPE_STRING:
|
||
cellValue = cell.getStringCellValue()+"";
|
||
break;
|
||
case Cell.CELL_TYPE_BLANK:
|
||
cellValue = cell.getBooleanCellValue()+"";
|
||
break;
|
||
case Cell.CELL_TYPE_ERROR:
|
||
cellValue = cell.getErrorCellValue()+"";
|
||
break;
|
||
}
|
||
}
|
||
|
||
// System.out.println("=========================================================");
|
||
// System.out.println("columnIndex:"+columnIndex);
|
||
// System.out.println("cellValue:"+cellValue);
|
||
|
||
cellValue = CommonUtils.checkNull(cellValue);
|
||
cellValue = cellValue.trim();
|
||
if("false".equals(cellValue)){
|
||
cellValue = "";
|
||
}
|
||
|
||
if(StringUtils.isBlank(cellValue)) emptyColCnt.incrementAndGet(); //emptyColCnt++;
|
||
|
||
return cellValue;
|
||
}
|
||
|
||
public void setErrMapByExcel(String resultColumn, ArrayList resultList, Map partMap, boolean addList, String msg, String cellValue){
|
||
String note = CommonUtils.checkNull((String)partMap.get(resultColumn));
|
||
partMap.put(resultColumn, CommonUtils.isNotBlank(note)? (note+", \n"+msg) : msg); //\n </br>
|
||
if(addList) {
|
||
//resultList.add(partMap);
|
||
}
|
||
}
|
||
|
||
|
||
//파트 엑셀업로드 파싱
|
||
public ArrayList partParsingExcelFile(HttpServletRequest request,Map paramMap)throws Exception{
|
||
|
||
ArrayList resultList = new ArrayList();
|
||
ArrayList fileList = commonService.getFileList(paramMap);
|
||
//ArrayList fileList = commonService.getFileListDecrypt(paramMap, true); //파수 drm 복호화
|
||
|
||
//프로젝트에 해당하는 사양 목록을 가져온다.
|
||
//List specRegionList = (ArrayList)setSpecRegionLRColumn(request, paramMap);
|
||
//System.out.println("specRegionList:"+specRegionList);
|
||
// int specRegionSize = specRegionList != null ? specRegionList.size() : 0;
|
||
// int specRegionIdx = 0;
|
||
// int totalCellSize = 38; //+specRegionSize
|
||
// int totalCellSize = specRegionSize+42;
|
||
// System.out.println("totalCellSize:"+totalCellSize);
|
||
|
||
boolean logging = false; // true/false
|
||
String resultColumn = "NOTE";
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
if(null != fileList && 1 == fileList.size() ){//&& 0 < specRegionList.size() 240118 사양조건 제거
|
||
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);
|
||
//FormulaEvaluator formulaEval = workBook.getCreationHelper().createFormulaEvaluator();
|
||
//XSSFSheet sheet = workBook.getSheetAt(0);
|
||
|
||
Workbook workBook = null;
|
||
if (fileName.endsWith(".xls") || fileName.endsWith(".XLS")) {
|
||
workBook = new HSSFWorkbook(fis);
|
||
} else if (fileName.endsWith(".xlsx") || fileName.endsWith(".XLSX")) {
|
||
workBook = new XSSFWorkbook(fis);
|
||
}
|
||
Sheet sheet = workBook.getSheetAt(0);
|
||
|
||
// 데이터 포멧터
|
||
DataFormatter formatter = new DataFormatter();
|
||
int rows = sheet.getPhysicalNumberOfRows();
|
||
System.out.println("rows:"+rows);
|
||
|
||
int emptyRowCnt = 0;
|
||
//int emptyColCnt = 0;
|
||
//Integer emptyColCnt = 0;
|
||
AtomicInteger emptyColCnt = new AtomicInteger(0);
|
||
Map partNoUniqueMap = new HashMap();
|
||
//Map<String, String> partNoMap = new HashMap<String, String>();
|
||
for(int rowIndex=2 ; rowIndex < rows ; rowIndex++){
|
||
//XSSFRow row = sheet.getRow(rowIndex);
|
||
Row row = sheet.getRow(rowIndex);
|
||
if(null != row){
|
||
int columnIndex = 0;
|
||
//emptyColCnt = 0;
|
||
emptyColCnt.set(0);
|
||
Map partMap = new HashMap();
|
||
// partMap.put("OEM_OBJID",OEM_OBJID );
|
||
// partMap.put("CAR_OBJID",CAR_OBJID );
|
||
// partMap.put("PRODUCT_GROUP_OBJID",PRODUCT_GROUP_OBJID );
|
||
// partMap.put("PRODUCT_OBJID",PRODUCT_OBJID );
|
||
|
||
/*
|
||
for(int columnIndex = 0 ; columnIndex < totalCellSize ; columnIndex++){
|
||
//columnSeq++;
|
||
XSSFCell cell = row.getCell(columnIndex++);
|
||
//데이버 유형별 get date
|
||
String cellValue = "";
|
||
//System.out.println("columnSeq:"+columnSeq + " " + "columnIndex:"+columnIndex);
|
||
if(null == cell){
|
||
cellValue = "";
|
||
}else{
|
||
switch(cell.getCellType()){
|
||
case XSSFCell.CELL_TYPE_FORMULA:
|
||
cellValue = cell.getCellFormula();
|
||
break;
|
||
case XSSFCell.CELL_TYPE_NUMERIC:
|
||
cellValue = formatter.formatCellValue(cell);
|
||
break;
|
||
case XSSFCell.CELL_TYPE_STRING:
|
||
cellValue = cell.getStringCellValue()+"";
|
||
break;
|
||
case XSSFCell.CELL_TYPE_BLANK:
|
||
cellValue = cell.getBooleanCellValue()+"";
|
||
break;
|
||
case XSSFCell.CELL_TYPE_ERROR:
|
||
cellValue = cell.getErrorCellValue()+"";
|
||
break;
|
||
}
|
||
}
|
||
System.out.println("=========================================================");
|
||
System.out.println("columnIndex:"+columnIndex);
|
||
System.out.println("cellValue:"+cellValue);
|
||
cellValue = cellValue.trim();
|
||
if("false".equals(cellValue)){
|
||
cellValue = "";
|
||
}
|
||
*/
|
||
|
||
Map sqlParamMap = new HashMap();
|
||
Map sqlResultMap = new HashMap();
|
||
|
||
//품번중복검사
|
||
String cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
partMap.put("PART_NO", cellValue);
|
||
// if(StringUtils.isBlank(cellValue)) emptyColCnt++;
|
||
|
||
// if(0 == columnIndex){
|
||
//partMap.put("OBJID", CommonUtils.createObjId());
|
||
if(StringUtils.isBlank(cellValue)){
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 품번 "+cellValue, cellValue);
|
||
}else {
|
||
sqlParamMap.put("PART_NO", cellValue); //240122 PART_NO 조건 수정
|
||
//sqlResultMap = getLastPartMngInfo22(request, sqlParamMap);
|
||
List<Map<String,Object>> partList = sqlSession.selectList("partMng.overlapPartMng2", sqlParamMap);
|
||
//String PART_OBJID = "";
|
||
if(null != partList && !partList.isEmpty()){
|
||
sqlResultMap = partList.get(0);
|
||
if(null != sqlResultMap){
|
||
// PART_OBJID = CommonUtils.checkNull(sqlResultMap.get("OBJID"));
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "품번중복", cellValue);
|
||
}else{
|
||
//PART_OBJID = CommonUtils.createObjId();
|
||
if(partNoUniqueMap.containsKey(cellValue)) {
|
||
//partMap.put("NOTE", "모품번이 존재하지 않는 파트입니다.");
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "품번중복", cellValue);
|
||
}else {
|
||
partNoUniqueMap.put("PART_NO", cellValue);
|
||
}
|
||
}
|
||
}else {
|
||
if(partNoUniqueMap.containsKey(cellValue)) {
|
||
//partMap.put("NOTE", "모품번이 존재하지 않는 파트입니다.");
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "품번중복", cellValue);
|
||
}else {
|
||
partNoUniqueMap.put("PART_NO", cellValue);
|
||
}
|
||
}
|
||
}
|
||
// }
|
||
|
||
//품명
|
||
cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
// if(StringUtils.isBlank(cellValue)) emptyColCnt++;
|
||
partMap.put("PART_NAME", cellValue);
|
||
if(CommonUtils.isBlank(cellValue)){
|
||
//partMap.put("NOTE", "자품번 필수 입력");
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 품명", cellValue);
|
||
//continue;
|
||
}else{
|
||
}
|
||
|
||
//수량(QTY)
|
||
// cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
// partMap.put("QTY", "1");
|
||
//재료
|
||
partMap.put("MATERIAL", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//열처리경도
|
||
partMap.put("HEAT_TREATMENT_HARDNESS", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//열처리방법
|
||
partMap.put("HEAT_TREATMENT_METHOD", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//표면처리
|
||
partMap.put("SURFACE_TREATMENT", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
// if(StringUtils.isBlank(getCellValue(row, columnIndex, formatter, emptyColCnt))) emptyColCnt++;
|
||
//사양(규격)
|
||
// partMap.put("SPEC", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
// if(StringUtils.isBlank(getCellValue(row, columnIndex, formatter, emptyColCnt))) emptyColCnt++;
|
||
//후처리
|
||
// partMap.put("POST_PROCESSING", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//MAKER
|
||
// partMap.put("MAKER", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
|
||
//공급업체 - MAKER 컬럼에 텍스트로 저장 (2025-10-29)
|
||
cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
partMap.put("MAKER", cellValue); // 공급업체명을 MAKER에 저장
|
||
|
||
/* 이전 공급업체 코드 조회 방식 (주석처리)
|
||
partMap.put("SUP_CODE", columnIndex);
|
||
if(!CommonUtils.isBlank(cellValue)){
|
||
sqlParamMap.clear();
|
||
sqlResultMap.clear();
|
||
sqlParamMap.put("SUPPLY_NAME", cellValue);
|
||
Map supply = sqlSession.selectOne("partMng.supplyInfo", sqlParamMap);
|
||
if(null!=supply && !StringUtils.isBlank((String)supply.get("objid"))){
|
||
//&& !CommonUtils.isEmptyMap(partType)
|
||
partMap.put("SUP_CODE", supply.get("objid"));
|
||
sqlResultMap.put("SUP_CODE",supply.get("objid"));
|
||
}else {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "공급업체 확인:"+cellValue, cellValue);
|
||
}
|
||
}
|
||
*/
|
||
|
||
//PART구분(부품유형)
|
||
cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
// if(StringUtils.isBlank(cellValue)) emptyColCnt++;
|
||
partMap.put("PART_TYPE", columnIndex);
|
||
if(!CommonUtils.isBlank(cellValue)){
|
||
sqlParamMap.clear();
|
||
sqlResultMap.clear();
|
||
sqlParamMap.put("CODE_NAME", cellValue);
|
||
Map partType = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null!=partType && !StringUtils.isBlank((String)partType.get("code_id"))){
|
||
//&& !CommonUtils.isEmptyMap(partType)
|
||
partMap.put("PART_TYPE", partType.get("code_id"));
|
||
sqlResultMap.put("PART_TYPE",partType.get("code_id"));
|
||
}else {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "범주 이름 확인:"+cellValue, cellValue);
|
||
}
|
||
}
|
||
|
||
//비고(REMARK)
|
||
partMap.put("REMARK", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
|
||
if(logging) logger.info("partMap:"+partMap);
|
||
|
||
if(emptyColCnt.intValue() < 8) { //모두 공백 아니면 담기
|
||
resultList.add(partMap);
|
||
}else {
|
||
emptyRowCnt++;
|
||
}
|
||
|
||
if(emptyRowCnt > 3) //3줄이상 빈줄이면 중지
|
||
break;
|
||
//}//end of for columns
|
||
}
|
||
}//end of for rows
|
||
}
|
||
|
||
//System.out.println("resultList:"+resultList);
|
||
if(logging) {
|
||
for (Object object : resultList) {
|
||
logger.info("resultList object:"+object);
|
||
}
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
//파트등록(엑셀업로드)
|
||
public void savePartByExcel(HttpServletRequest request,Map paramMap) throws Exception{
|
||
SqlSession sqlSession = null;
|
||
Map sqlMap = new HashMap();
|
||
try{
|
||
List<Map<String, Object>> gridDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("jqGrid")));
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
String objid = CommonUtils.checkNull(paramMap.get("importPopObjid"));
|
||
/*
|
||
String masterObjid = objid;
|
||
String unitCode = CommonUtils.checkNull(paramMap.get("UNIT_CODE"));
|
||
String contracObjid = CommonUtils.checkNull(paramMap.get("CONTRACT_OBJID"));
|
||
|
||
sqlMap.put("OBJID", contracObjid);
|
||
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", sqlMap);
|
||
String projectNo = (String)projectInfo.get("project_no");
|
||
String masterProjectNo = projectNo;
|
||
|
||
sqlMap.put("unitCode", unitCode);
|
||
Map unitInfoMap = (HashMap)sqlSession.selectOne("common.getUnitCodeList", sqlMap);
|
||
String unitName = CommonUtils.checkNull(unitInfoMap.get("name")).replaceAll("\u00A0+", " ");
|
||
String UNIT_NAME = CommonUtils.checkNull(unitInfoMap.get("name"));
|
||
|
||
byte[] utf8Bytes = unitName.getBytes("UTF-8");
|
||
String utf8unitName = new String(utf8Bytes, "UTF-8");
|
||
String filepath = Constants.FILE_STORAGE+"\\PART_DATA\\";
|
||
String filepathFull = filepath+projectNo+File.separator+unitName+File.separator;
|
||
*/
|
||
|
||
sqlMap.clear();
|
||
// sqlMap.put("CUSTOMER_OBJID", CommonUtils.checkNull((String)paramMap.get("CUSTOMER_OBJID")));
|
||
// sqlMap.put("CONTRACT_OBJID", CommonUtils.checkNull((String)paramMap.get("CONTRACT_OBJID")));
|
||
// sqlMap.put("UNIT_CODE", CommonUtils.checkNull((String)paramMap.get("UNIT_CODE")));
|
||
|
||
System.out.println("sqlMap ---->"+sqlMap);
|
||
//sqlSession.insert("partMng.createBOMReportStructureStandardInfo", sqlMap);
|
||
|
||
Map sqlParamMap = new HashMap();
|
||
Map insertMap = new HashMap();
|
||
Map resultMap = new HashMap();
|
||
Map partobjMap = new HashMap();
|
||
for(int i=0; i<gridDataList.size(); i++){
|
||
Map orgMap = gridDataList.get(i);
|
||
insertMap.clear();
|
||
//resultMap.clear();
|
||
//partobjMap.clear();
|
||
//insertMap.putAll(orgMap);
|
||
CommonUtils.copyMap(insertMap, orgMap, true, false);
|
||
|
||
String part_objid = ""; //part_objid
|
||
String PART_NO = CommonUtils.checkNull((String)insertMap.get("PART_NO")); //part_no
|
||
/*
|
||
insertMap.put("OBJID", CommonUtils.createObjId());
|
||
insertMap.put("PART_NO", PART_NO);
|
||
insertMap.put("PART_NAME", CommonUtils.checkNull((String)insertMap.get("PART_NAME")));
|
||
//insertMap.put("PART_NAME", java.util.regex.Matcher.quoteReplacement(CommonUtils.checkNull((String)insertMap.get("PART_NAME"))));
|
||
insertMap.put("QTY", CommonUtils.checkNull((String)insertMap.get("QTY")));
|
||
insertMap.put("UNIT", CommonUtils.checkNull((String)insertMap.get("UNIT")));
|
||
insertMap.put("SPEC", CommonUtils.checkNull((String)insertMap.get("SPEC")));
|
||
insertMap.put("MATERIAL", CommonUtils.checkNull((String)insertMap.get("MATERIAL")));
|
||
insertMap.put("THICKNESS", CommonUtils.checkNull((String)insertMap.get("THICKNESS")));
|
||
insertMap.put("WIDTH", CommonUtils.checkNull((String)insertMap.get("WIDTH")));
|
||
insertMap.put("HEIGHT", CommonUtils.checkNull((String)insertMap.get("HEIGHT")));
|
||
// insertMap.put("OUT_DIAMETER", CommonUtils.checkNull((String)insertMap.get("OUT_DIAMETER")));
|
||
// insertMap.put("IN_DIAMETER", CommonUtils.checkNull((String)insertMap.get("IN_DIAMETER")));
|
||
insertMap.put("LENGTH", CommonUtils.checkNull((String)insertMap.get("LENGTH")));
|
||
insertMap.put("PART_TYPE", CommonUtils.checkNull((String)insertMap.get("PART_TYPE")));
|
||
insertMap.put("REMARK", CommonUtils.checkNull((String)insertMap.get("REMARK")));
|
||
insertMap.put("SUPPLY_CODE", CommonUtils.checkNull((String)insertMap.get("SUPPLY_CODE")));
|
||
insertMap.put("MAKER", CommonUtils.checkNull((String)insertMap.get("MAKER")));
|
||
insertMap.put("POST_PROCESSING", CommonUtils.checkNull((String)insertMap.get("POST_PROCESSING")));
|
||
// insertMap.put("CONTRACT_OBJID", CommonUtils.checkNull((String)paramMap.get("CONTRACT_OBJID")));
|
||
// insertMap.put("PRODUCT_MGMT_OBJID", CommonUtils.checkNull((String)paramMap.get("product_mgmt_objid")));
|
||
*/
|
||
|
||
partobjMap.put("PART_NO", PART_NO);
|
||
resultMap = (HashMap)sqlSession.selectOne("partMng.getPartObjid", partobjMap); //part_no로 is_last = 1 건 조회
|
||
if(null!=resultMap){
|
||
part_objid = CommonUtils.checkNull((String)resultMap.get("part_objid"));
|
||
}else{
|
||
part_objid = CommonUtils.createObjId();
|
||
//PART저장
|
||
insertMap.put("OBJID", part_objid);
|
||
insertMap.put("CONNECTUSERID", CommonUtils.checkNull((String)paramMap.get("CONNECTUSERID")));
|
||
insertMap.put("SUPPLY_CODE", CommonUtils.checkNull((String)insertMap.get("SUPPLY_CODE")));
|
||
//sqlSession.insert("partMng.insertpartInfo", insertMap);
|
||
sqlSession.insert("partMng.mergePartMng", insertMap);
|
||
/*
|
||
Map fileMap = new HashMap();
|
||
fileMap.put("FILE_PATH",filepathFull);
|
||
fileMap.put("WRITER",(String)paramMap.get("CONNECTUSERID"));
|
||
|
||
//dwg
|
||
fileMap.put("OBJID", CommonUtils.createObjId());
|
||
fileMap.put("TARGET_OBJID", part_objid);
|
||
fileMap.put("SAVED_FILE_NAME", CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
fileMap.put("REAL_FILE_NAME",CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
fileMap.put("DOC_TYPE" ,"2D_DRAWING_CAD");
|
||
fileMap.put("DOC_TYPE_NAME","2D(Drawing) CAD 첨부파일");
|
||
fileMap.put("FILE_SIZE","167941");
|
||
fileMap.put("FILE_EXT","DWG");
|
||
|
||
System.out.println("fileMap --->"+ fileMap);
|
||
System.out.println(filepathFull+CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
//처부파일 가져오기
|
||
File file = new File(filepathFull+CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
|
||
System.out.println("file --->"+ file.getName());
|
||
System.out.println("checkBeforeFile(file)" +checkBeforeFile(file));
|
||
if(checkBeforeFile(file)){
|
||
//첨부저장이 존재 할때만 DWG 저장
|
||
sqlSession.insert("partMng.insertpartfileInfo", fileMap);
|
||
}
|
||
|
||
//pdf
|
||
file = new File(filepath+projectNo+File.separator+unitName+File.separator+CommonUtils.checkNull((String)insertMap.get("PART_NO")+".pdf"));
|
||
|
||
if(checkBeforeFile(file)){
|
||
fileMap.isEmpty();
|
||
//첨부저장이 존재 할때만 PDF 저장
|
||
fileMap.put("OBJID", CommonUtils.createObjId());
|
||
fileMap.put("TARGET_OBJID", part_objid);
|
||
fileMap.put("SAVED_FILE_NAME", CommonUtils.checkNull((String)insertMap.get("PART_NO")+".pdf"));
|
||
fileMap.put("REAL_FILE_NAME",CommonUtils.checkNull((String)insertMap.get("PART_NO")+".pdf"));
|
||
fileMap.put("DOC_TYPE" ,"2D_PDF_CAD");
|
||
fileMap.put("DOC_TYPE_NAME","2D(PDF) CAD 첨부파일");
|
||
fileMap.put("FILE_SIZE","167941");
|
||
fileMap.put("FILE_EXT","PDF");
|
||
//첨부저장이 존재 할때만 DWG 저장
|
||
sqlSession.insert("part.insertpartfileInfo", fileMap);
|
||
}
|
||
*/
|
||
}
|
||
|
||
System.out.println(" insertMap--->"+insertMap);
|
||
|
||
}//end of gridDataList
|
||
|
||
sqlSession.commit();
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
sqlSession.rollback();
|
||
throw e;
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* CSV 파일의 인코딩을 자동으로 감지합니다.
|
||
* UTF-8 → CP949 → EUC-KR 순서로 시도
|
||
*/
|
||
private String detectFileEncoding(File file) {
|
||
// 시도할 인코딩 목록 (Windows Excel CSV 기본 인코딩 우선)
|
||
String[] encodings = {"CP949", "UTF-8", "EUC-KR", "MS949"};
|
||
|
||
for (String encoding : encodings) {
|
||
try (FileInputStream fis = new FileInputStream(file);
|
||
InputStreamReader isr = new InputStreamReader(fis, encoding);
|
||
BufferedReader br = new BufferedReader(isr)) {
|
||
|
||
// 처음 몇 줄을 읽어서 깨진 문자 여부 확인
|
||
String line;
|
||
int lineCount = 0;
|
||
boolean hasBrokenChar = false;
|
||
|
||
while ((line = br.readLine()) != null && lineCount < 10) {
|
||
// 깨진 문자 검사 (<28> 또는 replacement character)
|
||
if (line.contains("\uFFFD") || line.contains("?")) {
|
||
hasBrokenChar = true;
|
||
break;
|
||
}
|
||
lineCount++;
|
||
}
|
||
|
||
// 깨진 문자가 없으면 이 인코딩이 올바른 것으로 판단
|
||
if (!hasBrokenChar && lineCount > 0) {
|
||
System.out.println("CSV 인코딩 감지 성공: " + encoding);
|
||
return encoding;
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
// 이 인코딩으로 읽기 실패 시 다음 인코딩 시도
|
||
continue;
|
||
}
|
||
}
|
||
|
||
// 모든 시도 실패 시 기본값 UTF-8 반환
|
||
System.out.println("CSV 인코딩 감지 실패, 기본값 UTF-8 사용");
|
||
return "UTF-8";
|
||
}
|
||
|
||
/**
|
||
* CSV 파일 파싱 (엑셀과 동일한 형식으로 반환)
|
||
* 첫 번째 열이 "수준"인 경우 계층 구조를 자동으로 파악
|
||
*/
|
||
private ArrayList parsingCsvFile(String path, String fileName, SqlSession sqlSession) throws Exception {
|
||
ArrayList resultList = new ArrayList();
|
||
BufferedReader br = null;
|
||
|
||
try {
|
||
File csvFile = new File(path + "\\" + fileName);
|
||
|
||
// 인코딩 자동 감지: UTF-8 → CP949 → EUC-KR 순서로 시도
|
||
String detectedEncoding = detectFileEncoding(csvFile);
|
||
System.out.println("CSV 파일 인코딩 감지: " + detectedEncoding);
|
||
|
||
FileInputStream fis = new FileInputStream(csvFile);
|
||
InputStreamReader isr = new InputStreamReader(fis, detectedEncoding);
|
||
br = new BufferedReader(isr);
|
||
|
||
// UTF-8 BOM 제거 (EF BB BF) - UTF-8인 경우에만
|
||
if ("UTF-8".equals(detectedEncoding)) {
|
||
br.mark(1);
|
||
if (br.read() != 0xFEFF) {
|
||
br.reset(); // BOM이 아니면 처음으로 되돌림
|
||
}
|
||
}
|
||
|
||
String line;
|
||
int rowIndex = 0;
|
||
|
||
// 모든 자품번 수집 및 수준별 품번 매핑
|
||
Set<String> allPartNumbers = new HashSet<>();
|
||
List<String[]> allRows = new ArrayList<>();
|
||
Map<String, String> levelToPartNoMap = new HashMap<>(); // 수준 -> 품번 매핑
|
||
Map<Integer, String> depthToPartNoMap = new HashMap<>(); // 깊이 -> 품번 매핑 (숫자만 있는 경우)
|
||
|
||
while ((line = br.readLine()) != null) {
|
||
String[] values = line.split(",");
|
||
allRows.add(values);
|
||
|
||
// 헤더가 아닌 경우 품번 수집
|
||
if (rowIndex > 0 && values.length > 1) {
|
||
String level = values[0].trim(); // 수준
|
||
String partNo = values[1].trim(); // 품번
|
||
|
||
// CSV 큰따옴표 제거
|
||
if (level.startsWith("\"") && level.endsWith("\"") && level.length() > 1) {
|
||
level = level.substring(1, level.length() - 1);
|
||
}
|
||
if (partNo.startsWith("\"") && partNo.endsWith("\"") && partNo.length() > 1) {
|
||
partNo = partNo.substring(1, partNo.length() - 1);
|
||
}
|
||
|
||
if (!StringUtils.isBlank(partNo)) {
|
||
allPartNumbers.add(partNo);
|
||
if (!StringUtils.isBlank(level)) {
|
||
levelToPartNoMap.put(level, partNo);
|
||
// 숫자만 있는 경우를 위한 깊이 매핑
|
||
try {
|
||
int depth = Integer.parseInt(level);
|
||
depthToPartNoMap.put(depth, partNo);
|
||
} catch (NumberFormatException e) {
|
||
// 숫자가 아니면 무시 (1.1, 1.4.1 같은 형식)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
rowIndex++;
|
||
}
|
||
|
||
// 데이터 파싱
|
||
rowIndex = 0;
|
||
Map<Integer, String> currentDepthPartNoMap = new HashMap<>(); // 현재 처리 중인 각 깊이별 최신 품번
|
||
|
||
for (String[] values : allRows) {
|
||
if (rowIndex == 0) { // 헤더 건너뛰기
|
||
rowIndex++;
|
||
continue;
|
||
}
|
||
|
||
if (values.length < 11) { // 최소 11개 컬럼 필요 (수준 포함)
|
||
rowIndex++;
|
||
continue;
|
||
}
|
||
|
||
Map partMap = new HashMap();
|
||
AtomicInteger emptyColCnt = new AtomicInteger(0);
|
||
String noteMsg = "";
|
||
|
||
int colIndex = 0;
|
||
|
||
// 각 컬럼 파싱 (CSV: 수준, 품번, 품명, 수량, ...)
|
||
String level = getCsvValue(values, colIndex++, emptyColCnt); // 0: 수준
|
||
String partNo = getCsvValue(values, colIndex++, emptyColCnt); // 1: 품번
|
||
String partName = getCsvValue(values, colIndex++, emptyColCnt); // 2: 품명
|
||
String qty = getCsvValue(values, colIndex++, emptyColCnt); // 3: 수량
|
||
String itemQty = getCsvValue(values, colIndex++, emptyColCnt); // 4: 항목수량
|
||
String material = getCsvValue(values, colIndex++, emptyColCnt); // 5: 재료
|
||
String heatTreatmentHardness = getCsvValue(values, colIndex++, emptyColCnt); // 6: 열처리경도
|
||
String heatTreatmentMethod = getCsvValue(values, colIndex++, emptyColCnt); // 7: 열처리방법
|
||
String surfaceTreatment = getCsvValue(values, colIndex++, emptyColCnt); // 8: 표면처리
|
||
String supplier = getCsvValue(values, colIndex++, emptyColCnt); // 9: 공급업체
|
||
String partType = getCsvValue(values, colIndex++, emptyColCnt); // 10: 범주이름
|
||
|
||
// 수준으로부터 부모 품번 찾기
|
||
String parentPartNo = "";
|
||
if (!StringUtils.isBlank(level)) {
|
||
// 숫자만 있는 경우 (1, 2, 3, 4 등)
|
||
try {
|
||
int currentDepth = Integer.parseInt(level);
|
||
|
||
// 현재 깊이의 품번 저장 (다음 행에서 참조할 수 있도록)
|
||
if (!StringUtils.isBlank(partNo)) {
|
||
currentDepthPartNoMap.put(currentDepth, partNo);
|
||
}
|
||
|
||
// 부모 찾기: 바로 이전 깊이의 최신 품번
|
||
if (currentDepth > 1) {
|
||
int parentDepth = currentDepth - 1;
|
||
if (currentDepthPartNoMap.containsKey(parentDepth)) {
|
||
parentPartNo = currentDepthPartNoMap.get(parentDepth);
|
||
}
|
||
}
|
||
} catch (NumberFormatException e) {
|
||
// 숫자가 아닌 경우 (1.1, 1.4.1 등) - 기존 로직 사용
|
||
String parentLevel = getParentLevel(level);
|
||
if (!StringUtils.isBlank(parentLevel) && levelToPartNoMap.containsKey(parentLevel)) {
|
||
parentPartNo = levelToPartNoMap.get(parentLevel);
|
||
}
|
||
}
|
||
}
|
||
|
||
// 유효성 검증
|
||
if(!StringUtils.isBlank(parentPartNo) && rowIndex > 2) {
|
||
if(!allPartNumbers.contains(parentPartNo)) {
|
||
noteMsg += "모품번 미존재:" + parentPartNo + ";";
|
||
}
|
||
}
|
||
|
||
// PART_TYPE 코드 조회
|
||
String partTypeCode = "";
|
||
if(!StringUtils.isBlank(partType) && rowIndex > 2) {
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("CODE_NAME", partType);
|
||
String partNoForCheck = CommonUtils.checkNull(partNo);
|
||
sqlParamMap.put("partNo", partNoForCheck);
|
||
Map partTypeMap = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null != partTypeMap && !StringUtils.isBlank((String)partTypeMap.get("code_id"))){
|
||
partTypeCode = (String)partTypeMap.get("code_id");
|
||
} else {
|
||
noteMsg += "부품유형 확인:" + partType + ";";
|
||
}
|
||
} else if(!StringUtils.isBlank(partType) && rowIndex <= 2) {
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("CODE_NAME", partType);
|
||
Map partTypeMap = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null != partTypeMap && !StringUtils.isBlank((String)partTypeMap.get("code_id"))){
|
||
partTypeCode = (String)partTypeMap.get("code_id");
|
||
}
|
||
}
|
||
|
||
// 공급업체 - MAKER 컬럼에 텍스트로 저장 (2025-10-29)
|
||
String makerValue = supplier; // 공급업체명을 그대로 사용
|
||
|
||
/* 이전 공급업체 코드 조회 방식 (주석처리)
|
||
String supplyCode = "";
|
||
if(!StringUtils.isBlank(supplier)) {
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("SUPPLY_NAME", supplier);
|
||
Map supplyMap = sqlSession.selectOne("partMng.getSupplyCodeByName", sqlParamMap);
|
||
if(null != supplyMap && supplyMap.get("objid") != null){
|
||
// OBJID는 BIGINT 타입이므로 String으로 변환
|
||
supplyCode = String.valueOf(supplyMap.get("objid"));
|
||
} else {
|
||
noteMsg += "공급업체 확인:" + supplier + ";";
|
||
}
|
||
}
|
||
*/
|
||
|
||
// Map에 데이터 저장
|
||
partMap.put("LEVEL", level); // 수준 값 (화면 표시용)
|
||
partMap.put("PARENT_PART_NO", parentPartNo); // 실제 부모 품번 (저장용)
|
||
partMap.put("PART_NO", partNo);
|
||
partMap.put("PART_NAME", partName);
|
||
partMap.put("QTY", qty);
|
||
partMap.put("ITEM_QTY", itemQty);
|
||
partMap.put("MATERIAL", material);
|
||
partMap.put("HEAT_TREATMENT_HARDNESS", heatTreatmentHardness);
|
||
partMap.put("HEAT_TREATMENT_METHOD", heatTreatmentMethod);
|
||
partMap.put("SURFACE_TREATMENT", surfaceTreatment);
|
||
partMap.put("MAKER", makerValue); // MAKER에 저장
|
||
partMap.put("PART_TYPE", partTypeCode);
|
||
partMap.put("NOTE", noteMsg);
|
||
|
||
if(!StringUtils.isBlank(noteMsg) || emptyColCnt.intValue() < 9) {
|
||
resultList.add(partMap);
|
||
}
|
||
|
||
rowIndex++;
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
throw e;
|
||
} finally {
|
||
if (br != null) {
|
||
try {
|
||
br.close();
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* CSV 값 추출 헬퍼 메서드
|
||
*/
|
||
private String getCsvValue(String[] values, int index, AtomicInteger emptyColCnt) {
|
||
if (index >= values.length) {
|
||
emptyColCnt.incrementAndGet();
|
||
return "";
|
||
}
|
||
String value = values[index].trim();
|
||
|
||
// CSV 큰따옴표 제거
|
||
if (value.startsWith("\"") && value.endsWith("\"") && value.length() > 1) {
|
||
value = value.substring(1, value.length() - 1);
|
||
}
|
||
|
||
if (StringUtils.isBlank(value)) {
|
||
emptyColCnt.incrementAndGet();
|
||
}
|
||
return value;
|
||
}
|
||
|
||
/**
|
||
* 수준으로부터 부모 수준 찾기
|
||
* 예: "1.4.1" -> "1.4", "1.8" -> "1", "1" -> ""
|
||
*/
|
||
private String getParentLevel(String level) {
|
||
if (StringUtils.isBlank(level)) {
|
||
return "";
|
||
}
|
||
|
||
// 마지막 점(.)의 위치 찾기
|
||
int lastDotIndex = level.lastIndexOf('.');
|
||
if (lastDotIndex > 0) {
|
||
// 마지막 점 이전까지가 부모 수준
|
||
return level.substring(0, lastDotIndex);
|
||
}
|
||
|
||
// 점이 없으면 최상위 레벨이므로 부모 없음
|
||
return "";
|
||
}
|
||
|
||
/**
|
||
* BOM 복사를 위한 데이터 조회 (엑셀 파싱 형식과 동일하게 반환)
|
||
*/
|
||
public ArrayList getBomDataForCopy(HttpServletRequest request, Map paramMap) throws Exception{
|
||
ArrayList resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
|
||
try {
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
String bomReportObjid = CommonUtils.checkNull((String)paramMap.get("BOM_REPORT_OBJID"));
|
||
|
||
if(StringUtils.isBlank(bomReportObjid)){
|
||
return resultList;
|
||
}
|
||
|
||
// BOM 구조 데이터 조회 (BOM_PART_QTY 테이블에서 직접 조회)
|
||
Map sqlParam = new HashMap();
|
||
sqlParam.put("BOM_REPORT_OBJID", bomReportObjid);
|
||
System.out.println("BOM_REPORT_OBJID: " + bomReportObjid);
|
||
List<Map> bomPartList = sqlSession.selectList("partMng.getBomPartListForCopy", sqlParam);
|
||
System.out.println("bomPartList size: " + bomPartList.size());
|
||
|
||
// 엑셀 파싱 형식으로 변환
|
||
for(Map bomData : bomPartList){
|
||
// PostgreSQL 소문자 결과를 대문자로 변환
|
||
bomData = CommonUtils.toUpperCaseMapKey(bomData);
|
||
|
||
Map partMap = new HashMap();
|
||
|
||
// 모품번 조회 (PARENT_PART_NO가 OBJID이므로 실제 품번을 조회)
|
||
String parentPartNo = "";
|
||
if(!StringUtils.isBlank((String)bomData.get("PARENT_PART_NO"))){
|
||
Map parentParam = new HashMap();
|
||
parentParam.put("OBJID", bomData.get("PARENT_PART_NO"));
|
||
Map parentPart = (Map)sqlSession.selectOne("partMng.getPartInfoByObjid", parentParam);
|
||
if(parentPart != null){
|
||
// PostgreSQL 소문자 결과를 대문자로 변환
|
||
parentPart = CommonUtils.toUpperCaseMapKey(parentPart);
|
||
parentPartNo = CommonUtils.checkNull(parentPart.get("PART_NO"));
|
||
}
|
||
}
|
||
|
||
partMap.put("PARENT_PART_NO", parentPartNo);
|
||
partMap.put("PART_NO", CommonUtils.checkNull(bomData.get("PART_NO")));
|
||
partMap.put("PART_NAME", CommonUtils.checkNull(bomData.get("PART_NAME")));
|
||
partMap.put("QTY", CommonUtils.checkNull(bomData.get("QTY")));
|
||
partMap.put("ITEM_QTY", CommonUtils.checkNull(bomData.get("ITEM_QTY")));
|
||
partMap.put("MATERIAL", CommonUtils.checkNull(bomData.get("MATERIAL")));
|
||
partMap.put("HEAT_TREATMENT_HARDNESS", CommonUtils.checkNull(bomData.get("HEAT_TREATMENT_HARDNESS")));
|
||
partMap.put("HEAT_TREATMENT_METHOD", CommonUtils.checkNull(bomData.get("HEAT_TREATMENT_METHOD")));
|
||
partMap.put("SURFACE_TREATMENT", CommonUtils.checkNull(bomData.get("SURFACE_TREATMENT")));
|
||
partMap.put("SUPPLIER", CommonUtils.checkNull(bomData.get("SUPPLIER")));
|
||
partMap.put("PART_TYPE", CommonUtils.checkNull(bomData.get("PART_TYPE")));
|
||
partMap.put("NOTE", ""); // 복사 시 NOTE는 빈 값
|
||
|
||
resultList.add(partMap);
|
||
}
|
||
|
||
} catch(Exception e){
|
||
e.printStackTrace();
|
||
throw e;
|
||
} finally {
|
||
if(sqlSession != null){
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 업로드된 Excel File을 통해 데이터를 Parsing 한다.(구조(bom)등록)
|
||
* @param request
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public ArrayList parsingExcelFile(HttpServletRequest request,Map paramMap)throws Exception{
|
||
System.out.println("paramMap::"+paramMap);
|
||
ArrayList resultList = new ArrayList();
|
||
ArrayList fileList = commonService.getFileList(paramMap);
|
||
|
||
boolean logging = false;
|
||
String resultColumn = "NOTE";
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
// 통합 템플릿으로 변경하면서 프로젝트 번호 검증은 선택사항으로 변경
|
||
String projectNo = "";
|
||
/*
|
||
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", paramMap);
|
||
if(projectInfo != null) {
|
||
projectNo = (String)projectInfo.get("project_no");
|
||
System.out.println("projectNo:"+projectNo);
|
||
}
|
||
*/
|
||
|
||
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"));
|
||
|
||
// CSV 파일인 경우 (수준 기반 계층 구조)
|
||
if (fileName.endsWith(".csv") || fileName.endsWith(".CSV")) {
|
||
resultList = parsingCsvFile(path, fileName, sqlSession);
|
||
// CSV 파일임을 표시
|
||
for(int i = 0; i < resultList.size(); i++) {
|
||
Map partMap = (Map)resultList.get(i);
|
||
partMap.put("IS_CSV", "Y");
|
||
}
|
||
sqlSession.close();
|
||
return resultList;
|
||
}
|
||
|
||
// Excel 파일인 경우
|
||
FileInputStream fis = new FileInputStream(path+"\\"+fileName);
|
||
|
||
Workbook workBook = null;
|
||
if (fileName.endsWith(".xls") || fileName.endsWith(".XLS")) {
|
||
workBook = new HSSFWorkbook(fis);
|
||
} else if (fileName.endsWith(".xlsx") || fileName.endsWith(".XLSX")) {
|
||
workBook = new XSSFWorkbook(fis);
|
||
}
|
||
Sheet sheet = workBook.getSheetAt(0);
|
||
|
||
DataFormatter formatter = new DataFormatter();
|
||
int rows = sheet.getPhysicalNumberOfRows();
|
||
System.out.println("rows:"+rows);
|
||
|
||
// 모든 자품번 수집 (첫 번째 열 '상태'는 건너뜀)
|
||
Set<String> allPartNumbers = new HashSet<>();
|
||
for (int rowIndex = 1; rowIndex < rows; rowIndex++) { // 2번째 행(index 1)부터 시작 (헤더 1줄 건너뜀)
|
||
Row row = sheet.getRow(rowIndex);
|
||
if (row != null) {
|
||
String partNo = getCellValue(row, 2, formatter, new AtomicInteger(0)).trim(); // 품번 컬럼 (2번째 열)
|
||
if (!StringUtils.isBlank(partNo)) {
|
||
allPartNumbers.add(partNo);
|
||
}
|
||
}
|
||
}
|
||
|
||
int emptyRowCnt = 0;
|
||
AtomicInteger emptyColCnt = new AtomicInteger(0);
|
||
Map partNoUniqueMap = new HashMap();
|
||
|
||
for(int rowIndex= 1 ; rowIndex < rows ; rowIndex++){ // 2번째 행(index 1)부터 시작 (헤더 1줄 건너뜀)
|
||
Row row = sheet.getRow(rowIndex);
|
||
if(null != row){
|
||
emptyColCnt.set(0);
|
||
Map partMap = new HashMap();
|
||
int columnIndex = 1; // 첫 번째 열(상태)은 건너뛰고 1부터 시작
|
||
|
||
// 통합 엑셀 컬럼 매핑 (첫 번째 열 '상태'는 건너뜀)
|
||
// 1: 모품번(PARENT_PART_NO), 2: 품번(PART_NO), 3: 품명(PART_NAME)
|
||
// 4: 수량(QTY), 5: 항목수량(ITEM_QTY), 6: 재료(MATERIAL)
|
||
// 7: 열처리경도(HEAT_TREATMENT_HARDNESS), 8: 열처리방법(HEAT_TREATMENT_METHOD), 9: 표면처리(SURFACE_TREATMENT)
|
||
// 10: 공급업체(SUPPLIER), 11: 범주이름(PART_TYPE)
|
||
|
||
String parentPartNo = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 모품번
|
||
String partNo = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 품번
|
||
String partName = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 품명
|
||
String qty = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 수량
|
||
String itemQty = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 항목수량
|
||
String material = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 재료
|
||
String heatHardness = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 열처리경도
|
||
String heatMethod = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 열처리방법
|
||
String surfaceTreatment = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 표면처리
|
||
String supplier = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 공급업체
|
||
String partType = getCellValue(row, columnIndex++, formatter, emptyColCnt).trim(); // 범주이름
|
||
|
||
// 빈 행 체크
|
||
if(StringUtils.isBlank(partNo) && StringUtils.isBlank(partName)){
|
||
emptyRowCnt++;
|
||
if(emptyRowCnt > 3) break;
|
||
continue;
|
||
}
|
||
emptyRowCnt = 0;
|
||
|
||
// 유효성 검사
|
||
String noteMsg = "";
|
||
|
||
// 모품번 체크
|
||
if(StringUtils.isBlank(parentPartNo) && rowIndex > 1) { // 첫 번째 데이터 행(rowIndex = 1)은 체크하지 않음
|
||
noteMsg += "필수입력 - 모품번;";
|
||
} else if(!StringUtils.isBlank(parentPartNo) && !allPartNumbers.contains(parentPartNo.trim())) {
|
||
noteMsg += "모품번이 자품번 목록에 없습니다: " + parentPartNo + ";";
|
||
}
|
||
|
||
// 품번 체크
|
||
if (StringUtils.isBlank(partNo)) {
|
||
noteMsg += "필수입력 - 품번;";
|
||
} else {
|
||
if (partNoUniqueMap.containsKey(partNo)) {
|
||
noteMsg += "품번 중복: " + partNo + ";";
|
||
}
|
||
|
||
// 프로젝트번호 검증은 선택사항으로 변경 (필요시 주석 해제)
|
||
/*
|
||
if (rowIndex == 1 && !StringUtils.isBlank(projectNo) && !partNo.trim().equals(projectNo)) {
|
||
noteMsg += "1레벨 품번에 프로젝트번호가 없습니다: " + partNo + ";";
|
||
}
|
||
*/
|
||
|
||
partNoUniqueMap.put(partNo, "");
|
||
}
|
||
|
||
// 품명 체크
|
||
if(StringUtils.isBlank(partName)){
|
||
noteMsg += "필수입력 - 품명;";
|
||
}
|
||
|
||
// 수량 체크
|
||
if (StringUtils.isBlank(qty)) {
|
||
noteMsg += "필수입력 - 수량;";
|
||
} else {
|
||
try {
|
||
double qtyValue = Double.parseDouble(qty);
|
||
if (qtyValue <= 0) {
|
||
noteMsg += "수량은 0보다 커야 합니다: " + qty + ";";
|
||
}
|
||
} catch (NumberFormatException e) {
|
||
noteMsg += "수량은 숫자여야 합니다: " + qty + ";";
|
||
}
|
||
}
|
||
|
||
// PART_TYPE 코드 조회
|
||
String partTypeCode = "";
|
||
if(!StringUtils.isBlank(partType) && rowIndex > 2) { // 첫 번째, 두 번째 데이터 행(rowIndex 1,2)은 체크하지 않음
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("CODE_NAME", partType);
|
||
String partNoForCheck = CommonUtils.checkNull(partNo);
|
||
sqlParamMap.put("partNo", partNoForCheck);
|
||
Map partTypeMap = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null != partTypeMap && !StringUtils.isBlank((String)partTypeMap.get("code_id"))){
|
||
partTypeCode = (String)partTypeMap.get("code_id");
|
||
|
||
// 구매품표준인 경우 존재 여부 체크
|
||
if(partType.equals("구매품표준")){
|
||
List<Map<String,Object>> partList = sqlSession.selectList("partMng.existPartNoCheck", sqlParamMap);
|
||
if(null == partList || partList.isEmpty()){
|
||
noteMsg += "품번에 해당하는 구매품표준이 없습니다:" + partNoForCheck + ";";
|
||
}
|
||
}
|
||
} else {
|
||
noteMsg += "부품유형 확인:" + partType + ";";
|
||
}
|
||
} else if(!StringUtils.isBlank(partType) && rowIndex <= 2) {
|
||
// 초기 행에서는 코드만 조회
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("CODE_NAME", partType);
|
||
Map partTypeMap = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null != partTypeMap && !StringUtils.isBlank((String)partTypeMap.get("code_id"))){
|
||
partTypeCode = (String)partTypeMap.get("code_id");
|
||
}
|
||
}
|
||
|
||
// 공급업체 - MAKER 컬럼에 텍스트로 저장 (2025-10-29)
|
||
String makerValue = supplier; // 공급업체명을 그대로 사용
|
||
|
||
/* 이전 공급업체 코드 조회 방식 (주석처리)
|
||
String supplyCode = "";
|
||
if(!StringUtils.isBlank(supplier)) {
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("SUPPLY_NAME", supplier);
|
||
Map supplyMap = sqlSession.selectOne("partMng.getSupplyCodeByName", sqlParamMap);
|
||
if(null != supplyMap && supplyMap.get("objid") != null){
|
||
// OBJID는 BIGINT 타입이므로 String으로 변환
|
||
supplyCode = String.valueOf(supplyMap.get("objid"));
|
||
} else {
|
||
noteMsg += "공급업체 확인:" + supplier + ";";
|
||
}
|
||
}
|
||
*/
|
||
|
||
// Map에 데이터 저장
|
||
partMap.put("PARENT_PART_NO", parentPartNo);
|
||
partMap.put("PART_NO", partNo);
|
||
partMap.put("PART_NAME", partName);
|
||
partMap.put("QTY", qty);
|
||
partMap.put("ITEM_QTY", itemQty);
|
||
partMap.put("MATERIAL", material);
|
||
partMap.put("HEAT_TREATMENT_HARDNESS", heatHardness);
|
||
partMap.put("HEAT_TREATMENT_METHOD", heatMethod);
|
||
partMap.put("SURFACE_TREATMENT", surfaceTreatment);
|
||
partMap.put("MAKER", makerValue); // MAKER에 저장
|
||
partMap.put("PART_TYPE", partTypeCode);
|
||
partMap.put("NOTE", noteMsg);
|
||
|
||
if(logging) logger.info("partMap:"+partMap);
|
||
|
||
if(emptyColCnt.intValue() < 9) { // 모두 공백 아니면 담기
|
||
resultList.add(partMap);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
try{
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
if(logging) {
|
||
for (Object object : resultList) {
|
||
logger.info("resultList object:"+object);
|
||
}
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 스핀들용 엑셀 파싱 (기존 로직)
|
||
*/
|
||
public ArrayList parsingSpindleExcelFile(HttpServletRequest request,Map paramMap)throws Exception{
|
||
System.out.println("paramMap::"+paramMap);
|
||
ArrayList resultList = new ArrayList();
|
||
ArrayList fileList = commonService.getFileList(paramMap);
|
||
|
||
boolean logging = false; // true/false
|
||
String resultColumn = "NOTE";
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", paramMap);
|
||
String projectNo = (String)projectInfo.get("project_no");
|
||
System.out.println("projectNo:"+projectNo);
|
||
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"));
|
||
|
||
//boolean isLoggingBoolean = false;
|
||
|
||
FileInputStream fis = new FileInputStream(path+"\\"+fileName);
|
||
//XSSFWorkbook workBook = new XSSFWorkbook(fis);
|
||
//FormulaEvaluator formulaEval = workBook.getCreationHelper().createFormulaEvaluator();
|
||
//XSSFSheet sheet = workBook.getSheetAt(0);
|
||
|
||
Workbook workBook = null;
|
||
if (fileName.endsWith(".xls") || fileName.endsWith(".XLS")) {
|
||
workBook = new HSSFWorkbook(fis);
|
||
} else if (fileName.endsWith(".xlsx") || fileName.endsWith(".XLSX")) {
|
||
workBook = new XSSFWorkbook(fis);
|
||
}
|
||
Sheet sheet = workBook.getSheetAt(0);
|
||
|
||
// 데이터 포멧터
|
||
DataFormatter formatter = new DataFormatter();
|
||
int rows = sheet.getPhysicalNumberOfRows();
|
||
System.out.println("rows:"+rows);
|
||
|
||
// 모든 자품번 수집
|
||
Set<String> allPartNumbers = new HashSet<>();
|
||
for (int rowIndex = 2; rowIndex < rows; rowIndex++) {
|
||
Row row = sheet.getRow(rowIndex);
|
||
if (row != null) {
|
||
String partNo = getCellValue(row, 1, formatter, new AtomicInteger(0)).trim();
|
||
if (!StringUtils.isBlank(partNo)) {
|
||
allPartNumbers.add(partNo);
|
||
}
|
||
}
|
||
}
|
||
|
||
int emptyRowCnt = 0;
|
||
AtomicInteger emptyColCnt = new AtomicInteger(0);
|
||
Map partNoUniqueMap = new HashMap();
|
||
|
||
for(int rowIndex= 2 ; rowIndex < rows ; rowIndex++){
|
||
//XSSFRow row = sheet.getRow(rowIndex);
|
||
Row row = sheet.getRow(rowIndex);
|
||
if(null != row){
|
||
int columnIndex = 0;
|
||
emptyColCnt.set(0);
|
||
Map partMap = new HashMap();
|
||
|
||
/*
|
||
for(int columnIndex = 0 ; columnIndex < 11 ; 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(7 == columnIndex){
|
||
if(isLoggingBoolean) System.out.println("****************************");
|
||
cellValue = Integer.toString((int)cell.getNumericCellValue());
|
||
if(isLoggingBoolean) System.out.println("cellValue1:"+cellValue);
|
||
}else{
|
||
cellValue = evaluate.formatAsString();
|
||
if(!"#N/A".equals(cellValue)){
|
||
cellValue = cell.getStringCellValue();
|
||
}
|
||
}
|
||
|
||
if(isLoggingBoolean) 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));
|
||
if(isLoggingBoolean) System.out.println("cellValue1:"+cellValue);
|
||
}else{
|
||
cellValue = cell.getNumericCellValue()+"";
|
||
if(isLoggingBoolean) System.out.println("cellValue2:"+cellValue);
|
||
}
|
||
if(isLoggingBoolean) System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_NUMERIC:"+cellValue);
|
||
|
||
break;
|
||
case XSSFCell.CELL_TYPE_STRING:
|
||
cellValue = cell.getStringCellValue()+"";
|
||
if(isLoggingBoolean) System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_STRING:"+cellValue);
|
||
break;
|
||
case XSSFCell.CELL_TYPE_BLANK:
|
||
cellValue = cell.getBooleanCellValue()+"";
|
||
if(isLoggingBoolean) System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_BLANK:"+cellValue);
|
||
break;
|
||
case XSSFCell.CELL_TYPE_ERROR:
|
||
cellValue = cell.getErrorCellValue()+"";
|
||
if(isLoggingBoolean) System.out.println(columnIndex+":"+"XSSFCell.CELL_TYPE_ERROR:"+cellValue);
|
||
break;
|
||
}
|
||
}
|
||
if("false".equals(cellValue)){
|
||
cellValue = "";
|
||
}
|
||
*/
|
||
|
||
//모품번
|
||
String cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
// if(0 == columnIndex){
|
||
// if(!"".equals(cellValue)){
|
||
Map sqlParamMap = new HashMap();
|
||
Map sqlResultMap = new HashMap();
|
||
|
||
partMap.put("PARENT_PART_NO", cellValue.trim());
|
||
if(StringUtils.isBlank(cellValue) && rowIndex > 2) { // 첫 번째 데이터 행(rowIndex = 2)은 체크하지 않음
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 모품번 "+cellValue, cellValue);
|
||
}else if(!StringUtils.isBlank(cellValue) && !allPartNumbers.contains(cellValue.trim())) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "모품번이 자품번 목록에 없습니다: " + cellValue, cellValue);
|
||
}
|
||
// }
|
||
//sqlMap.put("PARENT_PART_NO", cellValue.trim());
|
||
// }
|
||
|
||
//자품번
|
||
// if(1 == columnIndex){
|
||
/*if("".equals(cellValue)){
|
||
break;
|
||
}*/
|
||
cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
partMap.put("PART_NO", cellValue.trim());
|
||
//partNoUniqueMap.put(cellValue,"");
|
||
//sqlMap.put("PART_NO", cellValue.trim());
|
||
if (StringUtils.isBlank(cellValue)) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 자품번 " + cellValue, cellValue);
|
||
} else {
|
||
if (partNoUniqueMap.containsKey(cellValue)) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "품번중복 " + cellValue, cellValue);
|
||
}
|
||
|
||
// 첫 번째 데이터 행(rowIndex == 2)에 대해 추가 검증
|
||
if (rowIndex == 2 && !cellValue.trim().equals(projectNo)) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "1레벨 자품번에 프로젝트번호가 없습니다: " + cellValue, cellValue);
|
||
}
|
||
|
||
// 모든 유효한 자품번에 대해 중복 체크를 위해 맵에 추가
|
||
partNoUniqueMap.put(cellValue, "");
|
||
}
|
||
//System.out.println("partNoUniqueMap:"+partNoUniqueMap);
|
||
// }
|
||
|
||
//품명
|
||
// if(2 == columnIndex){
|
||
cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
partMap.put("PART_NAME", cellValue.trim());
|
||
//sqlMap.put("PART_NAME", cellValue.trim());
|
||
if(CommonUtils.isBlank(cellValue)){
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 품명", cellValue);
|
||
}else{
|
||
}
|
||
//System.out.println("cellValue123::"+cellValue);
|
||
// }
|
||
//수량
|
||
// if(3 == columnIndex){
|
||
String qtyCellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
if (CommonUtils.isBlank(qtyCellValue)) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 수량", qtyCellValue);
|
||
} else {
|
||
try {
|
||
double qtyValue = Double.parseDouble(qtyCellValue);
|
||
if (qtyValue <= 0) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "수량은 0보다 커야 합니다: " + qtyCellValue, qtyCellValue);
|
||
} else {
|
||
partMap.put("QTY", qtyCellValue);
|
||
}
|
||
} catch (NumberFormatException e) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "수량은 숫자여야 합니다: " + qtyCellValue, qtyCellValue);
|
||
}
|
||
}
|
||
// partMap.put("QTY", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//partMap.put("QTY", cellValue.trim());
|
||
//sqlMap.put("QTY", cellValue.trim());
|
||
|
||
// }
|
||
//재질
|
||
// if(4 == columnIndex){
|
||
partMap.put("MATERIAL", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//partMap.put("MATERIAL", cellValue.trim());
|
||
//sqlMap.put("MATERIAL", cellValue.trim());
|
||
|
||
// }
|
||
//규격
|
||
// if(5 == columnIndex){
|
||
partMap.put("SPEC", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//partMap.put("SPEC", cellValue.trim());
|
||
//sqlMap.put("SPEC", cellValue.trim());
|
||
|
||
// }
|
||
//후처리
|
||
// if(6 == columnIndex){
|
||
partMap.put("POST_PROCESSING", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//partMap.put("POST_PROCESSING", cellValue.trim());
|
||
//sqlMap.put("POST_PROCESSING", cellValue.trim());
|
||
|
||
// }
|
||
//MAKER
|
||
// if(7 == columnIndex){
|
||
partMap.put("MAKER", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//partMap.put("MAKER", cellValue.trim());
|
||
//sqlMap.put("MAKER", cellValue.trim());
|
||
|
||
// }
|
||
//부품유형
|
||
// if(8 == columnIndex){
|
||
/* if(cellValue.trim().equals("구매품")){
|
||
partMap.put("PART_TYPE", "0000063");
|
||
sqlMap.put("PART_TYPE", "0000063");
|
||
}else if(cellValue.trim().equals("제작품")){
|
||
partMap.put("PART_TYPE", "0000064");
|
||
sqlMap.put("PART_TYPE","0000064");
|
||
}else if(cellValue.trim().equals("사급품")){
|
||
partMap.put("PART_TYPE", "0000065");
|
||
sqlMap.put("PART_TYPE","0000065");
|
||
}else if(cellValue.trim().equals("표준품")){
|
||
partMap.put("PART_TYPE", "0000085");
|
||
sqlMap.put("PART_TYPE","0000085");
|
||
}*/
|
||
cellValue = getCellValue(row, columnIndex++, formatter, emptyColCnt);
|
||
partMap.put("PART_TYPE", columnIndex);
|
||
//sqlMap.put("PART_TYPE","");
|
||
if(rowIndex > 3) { // 첫 번째, 두 번째 데이터 행은 체크하지 않음
|
||
if(CommonUtils.isBlank(cellValue)) {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "필수입력 - 부품유형", cellValue);
|
||
} else {
|
||
sqlParamMap.clear();
|
||
sqlResultMap.clear();
|
||
sqlParamMap.put("CODE_NAME", cellValue);
|
||
String partNo = CommonUtils.checkNull(partMap.get("PART_NO"));
|
||
sqlParamMap.put("partNo", partNo);
|
||
Map partType = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null!=partType && !StringUtils.isBlank((String)partType.get("code_id"))){
|
||
partMap.put("PART_TYPE", partType.get("code_id"));
|
||
sqlResultMap.put("PART_TYPE",partType.get("code_id"));
|
||
if(cellValue.equals("구매품표준")){
|
||
List<Map<String,Object>> partList = sqlSession.selectList("partMng.existPartNoCheck", sqlParamMap);
|
||
if(null == partList || partList.isEmpty()){
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "품번에 해당하는 구매품표준이 없습니다:"+partNo, cellValue);
|
||
}else{
|
||
|
||
}
|
||
}
|
||
} else {
|
||
setErrMapByExcel(resultColumn, resultList, partMap, true, "부품유형 확인:"+cellValue, cellValue);
|
||
}
|
||
}
|
||
} else {
|
||
if(!CommonUtils.isBlank(cellValue)){
|
||
sqlParamMap.clear();
|
||
sqlResultMap.clear();
|
||
sqlParamMap.put("CODE_NAME", cellValue);
|
||
Map partType = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null!=partType && !StringUtils.isBlank((String)partType.get("code_id"))){
|
||
partMap.put("PART_TYPE", partType.get("code_id"));
|
||
sqlResultMap.put("PART_TYPE",partType.get("code_id"));
|
||
}
|
||
}
|
||
}
|
||
//Map parttype = null;
|
||
//if(!"".equals(CommonUtils.nullToEmpty(cellValue.trim()))){
|
||
// paramMap.put("CODE_NAME", cellValue.trim());
|
||
// parttype = sqlSession.selectOne("partMng.parttypeInfo", paramMap);
|
||
// if(null!=parttype){
|
||
// partMap.put("PART_TYPE", parttype.get("code_id"));
|
||
//sqlMap.put("PART_TYPE",parttype.get("code_id"));
|
||
// }
|
||
//}
|
||
|
||
// }
|
||
//REMARK
|
||
// if(9 == columnIndex){
|
||
partMap.put("REMARK", getCellValue(row, columnIndex++, formatter, emptyColCnt));
|
||
//sqlMap.put("REMARK", cellValue.trim());
|
||
|
||
//resultList.add(partMap);
|
||
//if(isLoggingBoolean)
|
||
// System.out.println("partMap:"+partMap);
|
||
//break;
|
||
// }
|
||
|
||
//비고
|
||
/*partMap.put("QTY", cellValue.trim());
|
||
|
||
sqlMap.put("QTY", cellValue.trim());
|
||
sqlMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull((String)paramMap.get("targetObjId")));
|
||
sqlMap.put("OBJID", CommonUtils.createObjId());
|
||
sqlMap.put("CHILD_OBJID", CommonUtils.createObjId());
|
||
|
||
String PART_NO = CommonUtils.checkNull((String)sqlMap.get("PART_NO"));
|
||
String PARENT_PART_NO = CommonUtils.checkNull((String)sqlMap.get("PARENT_PART_NO"));*/
|
||
|
||
//sqlSession.insert("partMng.relatePartTempInfo", sqlMap);
|
||
if(logging) logger.info("partMap:"+partMap);
|
||
|
||
if(emptyColCnt.intValue() < 8) { //모두 공백 아니면 담기
|
||
resultList.add(partMap);
|
||
}else {
|
||
emptyRowCnt++;
|
||
}
|
||
|
||
if(emptyRowCnt > 3) //3줄이상 빈줄이면 중지
|
||
break;
|
||
|
||
/*}*/
|
||
}
|
||
}
|
||
}
|
||
try{
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
if(logging) {
|
||
for (Object object : resultList) {
|
||
logger.info("resultList object:"+object);
|
||
}
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* 장비용 엑셀 파싱 (새로운 로직)
|
||
* Level=수준, Name=번호=PART_NO, Specification Title=항목 설명=PART_NAME
|
||
* Qty=수량=QTY, Material=재료=MATERIAL
|
||
* Hardness=열처리경도, 열처리방법(장비만), Heat Surface treatment=표면처리
|
||
* Production Make Buy Code=범주 이름=PART_TYPE
|
||
*/
|
||
public ArrayList parsingEquipmentExcelFile(HttpServletRequest request,Map paramMap)throws Exception{
|
||
System.out.println("장비용 엑셀 파싱 시작");
|
||
ArrayList resultList = new ArrayList();
|
||
ArrayList fileList = commonService.getFileList(paramMap);
|
||
|
||
boolean logging = false;
|
||
String resultColumn = "NOTE";
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", paramMap);
|
||
String projectNo = (String)projectInfo.get("project_no");
|
||
System.out.println("projectNo:"+projectNo);
|
||
|
||
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);
|
||
|
||
Workbook workBook = null;
|
||
if (fileName.endsWith(".xls") || fileName.endsWith(".XLS")) {
|
||
workBook = new HSSFWorkbook(fis);
|
||
} else if (fileName.endsWith(".xlsx") || fileName.endsWith(".XLSX")) {
|
||
workBook = new XSSFWorkbook(fis);
|
||
}
|
||
Sheet sheet = workBook.getSheetAt(0);
|
||
|
||
DataFormatter formatter = new DataFormatter();
|
||
int rows = sheet.getPhysicalNumberOfRows();
|
||
System.out.println("rows:"+rows);
|
||
|
||
// 모든 자품번 수집
|
||
Set<String> allPartNumbers = new HashSet<>();
|
||
for (int rowIndex = 2; rowIndex < rows; rowIndex++) {
|
||
Row row = sheet.getRow(rowIndex);
|
||
if (row != null) {
|
||
String partNo = getCellValue(row, 1, formatter, new AtomicInteger(0)).trim(); // 번호 컬럼
|
||
if (!StringUtils.isBlank(partNo)) {
|
||
allPartNumbers.add(partNo);
|
||
}
|
||
}
|
||
}
|
||
|
||
int emptyRowCnt = 0;
|
||
AtomicInteger emptyColCnt = new AtomicInteger(0);
|
||
Map partNoUniqueMap = new HashMap();
|
||
|
||
for(int rowIndex= 2 ; rowIndex < rows ; rowIndex++){
|
||
Row row = sheet.getRow(rowIndex);
|
||
if(null != row){
|
||
emptyColCnt.set(0);
|
||
Map partMap = new HashMap();
|
||
|
||
// 장비 엑셀 컬럼 매핑
|
||
// 0: 수준(Level), 1: 번호(Name/PART_NO), 2: 항목 설명(Specification Title/PART_NAME)
|
||
// 3: 수량(Qty), 4: 항목 수량, 5: 재료(Material)
|
||
// 6: 열처리경도(Hardness), 7: 열처리방법, 8: 표면처리(Heat Surface treatment)
|
||
// 9: 공급업체(Maker), 10: 범주 이름(Production Make Buy Code/PART_TYPE)
|
||
|
||
String level = getCellValue(row, 0, formatter, emptyColCnt).trim(); // 수준
|
||
String partNo = getCellValue(row, 1, formatter, emptyColCnt).trim(); // 번호
|
||
String partName = getCellValue(row, 2, formatter, emptyColCnt).trim(); // 항목 설명
|
||
String qty = getCellValue(row, 3, formatter, emptyColCnt).trim(); // 수량
|
||
String itemQty = getCellValue(row, 4, formatter, emptyColCnt).trim(); // 항목 수량
|
||
String material = getCellValue(row, 5, formatter, emptyColCnt).trim(); // 재료
|
||
String hardness = getCellValue(row, 6, formatter, emptyColCnt).trim(); // 열처리경도
|
||
String heatMethod = getCellValue(row, 7, formatter, emptyColCnt).trim(); // 열처리방법
|
||
String surfaceTreatment = getCellValue(row, 8, formatter, emptyColCnt).trim(); // 표면처리
|
||
String supplier = getCellValue(row, 9, formatter, emptyColCnt).trim(); // 공급업체
|
||
String partType = getCellValue(row, 10, formatter, emptyColCnt).trim(); // 범주 이름
|
||
|
||
// 빈 행 체크
|
||
if(StringUtils.isBlank(partNo) && StringUtils.isBlank(partName)){
|
||
emptyRowCnt++;
|
||
if(emptyRowCnt > 3) break;
|
||
continue;
|
||
}
|
||
emptyRowCnt = 0;
|
||
|
||
// 모품번 찾기
|
||
String parentPartNo = "";
|
||
if(!StringUtils.isBlank(level) && !level.equals("1")){
|
||
// 상위 레벨 찾기
|
||
for(int i = rowIndex - 1; i >= 2; i--){
|
||
Row prevRow = sheet.getRow(i);
|
||
if(prevRow != null){
|
||
String prevLevel = getCellValue(prevRow, 0, formatter, new AtomicInteger(0)).trim();
|
||
String prevPartNo = getCellValue(prevRow, 1, formatter, new AtomicInteger(0)).trim();
|
||
|
||
if(!StringUtils.isBlank(prevLevel)){
|
||
double currentLevelNum = parseLevel(level);
|
||
double prevLevelNum = parseLevel(prevLevel);
|
||
|
||
if(prevLevelNum < currentLevelNum){
|
||
parentPartNo = prevPartNo;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 유효성 검사
|
||
String noteMsg = "";
|
||
|
||
// 프로젝트번호 체크 (1레벨만)
|
||
if("1".equals(level) && !partNo.contains(projectNo)){
|
||
noteMsg += "1레벨 품번에 프로젝트번호 없음;";
|
||
}
|
||
|
||
// 중복 체크
|
||
if(partNoUniqueMap.containsKey(partNo)){
|
||
noteMsg += "품번 중복;";
|
||
}else{
|
||
partNoUniqueMap.put(partNo, partNo);
|
||
}
|
||
|
||
// 모품번 존재 여부 체크
|
||
if(!StringUtils.isBlank(parentPartNo) && !allPartNumbers.contains(parentPartNo)){
|
||
noteMsg += "모품번 없음;";
|
||
}
|
||
|
||
// PART_TYPE 코드 조회
|
||
String partTypeCode = "";
|
||
String partTypeTitle = partType; // 원본 텍스트 저장
|
||
if(!StringUtils.isBlank(partType)){
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("code_name", partType);
|
||
Map partTypeMap = sqlSession.selectOne("partMng.parttypeInfo", sqlParamMap);
|
||
if(null != partTypeMap && !StringUtils.isBlank((String)partTypeMap.get("code_id"))){
|
||
partTypeCode = (String)partTypeMap.get("code_id");
|
||
}
|
||
}
|
||
|
||
// Map에 데이터 저장
|
||
partMap.put("PARENT_PART_NO", parentPartNo);
|
||
partMap.put("PART_NO", partNo);
|
||
partMap.put("PART_NAME", partName);
|
||
partMap.put("QTY", qty);
|
||
partMap.put("MATERIAL", material);
|
||
partMap.put("SPEC", hardness + (StringUtils.isBlank(heatMethod) ? "" : " / " + heatMethod)); // 열처리경도 + 열처리방법
|
||
partMap.put("POST_PROCESSING", surfaceTreatment); // 표면처리
|
||
partMap.put("MAKER", supplier); // 공급업체
|
||
partMap.put("PART_TYPE", partTypeCode); // 범주 코드
|
||
partMap.put("PART_TYPE_TITLE", partTypeTitle); // 범주 이름 (화면 표시용)
|
||
partMap.put("REMARK", ""); // 비고
|
||
partMap.put("NOTE", noteMsg);
|
||
|
||
if(logging) System.out.println("partMap:"+partMap);
|
||
|
||
if(emptyColCnt.intValue() < 8) {
|
||
resultList.add(partMap);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
try{
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
if(logging) {
|
||
for (Object object : resultList) {
|
||
System.out.println("resultList object:"+object);
|
||
}
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* Level 문자열을 숫자로 파싱 (1, 1.1, 1.2.3 등)
|
||
*/
|
||
private double parseLevel(String level){
|
||
if(StringUtils.isBlank(level)) return 0;
|
||
|
||
String[] parts = level.split("\\.");
|
||
double result = 0;
|
||
for(int i = 0; i < parts.length; i++){
|
||
try{
|
||
result += Double.parseDouble(parts[i]) / Math.pow(100, i);
|
||
}catch(Exception e){
|
||
// 파싱 실패시 0 반환
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 품번 중복 체크 (PART_BOM_REPORT 테이블)
|
||
* @param request
|
||
* @param paramMap
|
||
* @return 중복 개수
|
||
*/
|
||
public int checkDuplicatePartNo(HttpServletRequest request, Map paramMap){
|
||
int count = 0;
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
count = sqlSession.selectOne("partMng.checkDuplicatePartNo", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(sqlSession != null){
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
return count;
|
||
}
|
||
|
||
//bom 구조등록(엑셀업로드)
|
||
public void savePartBomMaster(HttpServletRequest request,Map paramMap) throws Exception{
|
||
SqlSession sqlSession = null;
|
||
Map sqlMap = new HashMap();
|
||
try{
|
||
List<Map<String, Object>> gridDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("jqGrid")));
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
// 기존 BOM이 있으면 해당 BOM을 수정, 없으면 새로 생성
|
||
String objid = CommonUtils.checkNull(paramMap.get("importPopObjid"));
|
||
String bomobjid = CommonUtils.checkNull(paramMap.get("BOM_REPORT_OBJID"));
|
||
|
||
if(!"".equals(bomobjid)){
|
||
// 기존 BOM 수정: 기존 파트 데이터 삭제
|
||
objid = bomobjid;
|
||
Map deleteParam = new HashMap();
|
||
deleteParam.put("BOM_REPORT_OBJID", objid);
|
||
sqlSession.delete("partMng.deleteBomPartQtyByBomObjid", deleteParam);
|
||
|
||
// BOM 상태 초기화
|
||
Map resetParam = new HashMap();
|
||
resetParam.put("OBJID", objid);
|
||
sqlSession.update("partMng.resetBomReportStatus", resetParam);
|
||
}
|
||
|
||
String masterObjid = objid;
|
||
|
||
// BOM부터 만들고 프로젝트에 연결하도록 변경 - 프로젝트 유닛 정보 조회 주석처리
|
||
/*
|
||
String unitCode = CommonUtils.checkNull(paramMap.get("UNIT_CODE"));
|
||
String contracObjid = CommonUtils.checkNull(paramMap.get("CONTRACT_OBJID"));
|
||
|
||
sqlMap.put("OBJID", contracObjid);
|
||
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", sqlMap);
|
||
String projectNo = (String)projectInfo.get("project_no");
|
||
String masterProjectNo = projectNo;
|
||
|
||
sqlMap.put("unitCode", unitCode);
|
||
Map unitInfoMap = (HashMap)sqlSession.selectOne("common.getUnitCodeList", sqlMap);
|
||
String unitName = CommonUtils.checkNull(unitInfoMap.get("name")).replaceAll("\u00A0+", " ");
|
||
String UNIT_NAME = CommonUtils.checkNull(unitInfoMap.get("name"));
|
||
|
||
byte[] utf8Bytes = unitName.getBytes("UTF-8");
|
||
String utf8unitName = new String(utf8Bytes, "UTF-8");
|
||
|
||
String filepath = Constants.FILE_STORAGE+"\\PART_DATA\\";
|
||
String filepathFull = filepath+projectNo+File.separator+unitName+File.separator;
|
||
*/
|
||
|
||
// BOM부터 만들고 프로젝트에 연결하도록 변경 - 멀티 프로젝트 처리 주석처리
|
||
/*
|
||
boolean isMaster = true;
|
||
boolean isMulti = false;
|
||
for(int j=1; j<11; j++){
|
||
String APPLICATION_PROJECT_NO = CommonUtils.nullToEmpty((String)paramMap.get("APPLICATION_PROJECT_NO"+j)); //프로젝트 objid
|
||
if(!CommonUtils.isBlank(APPLICATION_PROJECT_NO)) {
|
||
isMulti = true;
|
||
break;
|
||
}
|
||
}
|
||
*/
|
||
//BOM REPORT OBJID
|
||
sqlMap.clear();
|
||
sqlMap.put("OBJID", objid);
|
||
sqlMap.put("MULTI_YN", "N"); // 멀티 프로젝트 기능 비활성화
|
||
sqlMap.put("MULTI_MASTER_YN", "N");
|
||
//sqlMap.put("MULTI_MASTER_OBJID", masterObjid);
|
||
sqlMap.put("CUSTOMER_OBJID", CommonUtils.checkNull((String)paramMap.get("CUSTOMER_OBJID")));
|
||
sqlMap.put("CONTRACT_OBJID", CommonUtils.checkNull((String)paramMap.get("CONTRACT_OBJID")));
|
||
sqlMap.put("UNIT_CODE", CommonUtils.checkNull((String)paramMap.get("UNIT_CODE")));
|
||
sqlMap.put("WRITER", CommonUtils.checkNull((String)paramMap.get("CONNECTUSERID")));
|
||
|
||
// 제품구분, 품번, 품명, 버전 추가
|
||
sqlMap.put("PRODUCT_CD", CommonUtils.checkNull((String)paramMap.get("product_cd")));
|
||
sqlMap.put("PART_NO", CommonUtils.checkNull((String)paramMap.get("bom_part_no")));
|
||
sqlMap.put("PART_NAME", CommonUtils.checkNull((String)paramMap.get("bom_part_name")));
|
||
sqlMap.put("REVISION", CommonUtils.checkNull((String)paramMap.get("version")));
|
||
|
||
//bom report 저장
|
||
System.out.println("sqlMap ---->"+sqlMap);
|
||
sqlSession.insert("partMng.createBOMReportStructureStandardInfo", sqlMap);
|
||
|
||
// 그리드 데이터가 비어있으면 BOM 헤더만 생성하고 종료
|
||
if(gridDataList == null || gridDataList.isEmpty()) {
|
||
System.out.println("=== 빈 E-BOM 생성 완료 (품번: " + sqlMap.get("PART_NO") + ", 품명: " + sqlMap.get("PART_NAME") + ") ===");
|
||
sqlSession.commit();
|
||
return;
|
||
}
|
||
|
||
// BOM 데이터 저장 (프로젝트 연결 없이)
|
||
/*
|
||
String newPartNo1Surffix = "";
|
||
String masterPartNo1 = "";
|
||
String UNIT_CODE2 = "";
|
||
Map sqlParamMap = new HashMap();
|
||
for(int j=0; j<11; j++){ //24032x? - 0은 master 동시건
|
||
String APPLICATION_OBJID = CommonUtils.nullToEmpty((String)paramMap.get("APPLICATION_OBJID"+j));
|
||
String APPLICATION_PROJECT_NO = CommonUtils.nullToEmpty((String)paramMap.get("APPLICATION_PROJECT_NO"+j)); //프로젝트 objid
|
||
|
||
if(j == 0) {
|
||
APPLICATION_PROJECT_NO = CommonUtils.checkNull(paramMap.get("CONTRACT_OBJID"));
|
||
}else {
|
||
isMaster = false;
|
||
}
|
||
|
||
if(!CommonUtils.isBlank(APPLICATION_PROJECT_NO)) {
|
||
|
||
//bom master insert
|
||
if(!isMaster) {
|
||
|
||
sqlMap.clear();
|
||
sqlMap.put("OBJID", APPLICATION_PROJECT_NO);
|
||
projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", sqlMap);
|
||
projectNo = (String)projectInfo.get("project_no"); //프로젝트 no
|
||
|
||
sqlParamMap.clear();
|
||
sqlParamMap.put("project_objid", APPLICATION_PROJECT_NO);
|
||
sqlParamMap.put("unitName", UNIT_NAME);
|
||
unitInfoMap = (HashMap)sqlSession.selectOne("common.getUnitCodeList", sqlParamMap);
|
||
if(unitInfoMap == null || CommonUtils.isEmptyMap(unitInfoMap)) {
|
||
throw new Exception(projectNo+"프로젝트에 "+UNIT_NAME + " UNIT이 존재하지 않습니다.");
|
||
}
|
||
unitName = CommonUtils.checkNull(unitInfoMap.get("name")).replaceAll("\u00A0+", " ");
|
||
UNIT_CODE2 = CommonUtils.checkNull((String)unitInfoMap.get("code"));
|
||
|
||
utf8Bytes = unitName.getBytes("UTF-8");
|
||
utf8unitName = new String(utf8Bytes, "UTF-8");
|
||
filepath = Constants.FILE_STORAGE+"\\PART_DATA\\";
|
||
filepathFull = filepath+projectNo+File.separator+unitName+File.separator;
|
||
|
||
//BOM REPORT OBJID
|
||
objid = CommonUtils.createObjId(); //키 새로 생성
|
||
sqlMap.clear();
|
||
sqlMap.put("OBJID", objid);
|
||
sqlMap.put("MULTI_YN", "Y");
|
||
sqlMap.put("MULTI_MASTER_YN", "N");
|
||
sqlMap.put("MULTI_MASTER_OBJID", masterObjid);
|
||
sqlMap.put("CUSTOMER_OBJID", CommonUtils.checkNull((String)paramMap.get("CUSTOMER_OBJID")));
|
||
sqlMap.put("CONTRACT_OBJID", APPLICATION_PROJECT_NO);
|
||
sqlMap.put("UNIT_CODE", UNIT_CODE2);
|
||
sqlMap.put("WRITER", CommonUtils.checkNull((String)paramMap.get("CONNECTUSERID")));
|
||
//bom report 저장
|
||
|
||
System.out.println("sqlMap ---->"+sqlMap);
|
||
sqlSession.insert("partMng.createBOMReportStructureStandardInfo", sqlMap);
|
||
|
||
//엑셀 등록
|
||
//sqlSession.insert("partMng.relateexcelPartInfo", sqlMap);
|
||
}
|
||
*/
|
||
|
||
Map insertMap = new HashMap();
|
||
Map resultMap = new HashMap();
|
||
Map partobjMap = new HashMap();
|
||
|
||
//bom qty/part insert (프로젝트 연결 없이 직접 저장)
|
||
for(int i=0; i<gridDataList.size(); i++){
|
||
Map orgMap = gridDataList.get(i);
|
||
insertMap.clear();
|
||
CommonUtils.copyMap(insertMap, orgMap, true, false);
|
||
|
||
String part_no = "";
|
||
String PART_NO = CommonUtils.checkNull((String)insertMap.get("PART_NO"));
|
||
String PARENT_PART_NO = CommonUtils.checkNull((String)insertMap.get("PARENT_PART_NO"));
|
||
|
||
insertMap.put("OBJID", CommonUtils.createObjId());
|
||
insertMap.put("BOM_REPORT_OBJID", objid);
|
||
insertMap.put("PARENT_PART_NO", PARENT_PART_NO);
|
||
insertMap.put("PART_NO", PART_NO);
|
||
insertMap.put("PART_NAME", CommonUtils.checkNull((String)insertMap.get("PART_NAME")));
|
||
insertMap.put("QTY", CommonUtils.checkNull((String)insertMap.get("QTY")));
|
||
insertMap.put("UNIT", CommonUtils.checkNull((String)insertMap.get("UNIT")));
|
||
insertMap.put("SPEC", CommonUtils.checkNull((String)insertMap.get("SPEC")));
|
||
insertMap.put("MATERIAL", CommonUtils.checkNull((String)insertMap.get("MATERIAL")));
|
||
insertMap.put("THICKNESS", CommonUtils.checkNull((String)insertMap.get("THICKNESS")));
|
||
insertMap.put("WIDTH", CommonUtils.checkNull((String)insertMap.get("WIDTH")));
|
||
insertMap.put("HEIGHT", CommonUtils.checkNull((String)insertMap.get("HEIGHT")));
|
||
insertMap.put("OUT_DIAMETER", CommonUtils.checkNull((String)insertMap.get("OUT_DIAMETER")));
|
||
insertMap.put("IN_DIAMETER", CommonUtils.checkNull((String)insertMap.get("IN_DIAMETER")));
|
||
insertMap.put("LENGTH", CommonUtils.checkNull((String)insertMap.get("LENGTH")));
|
||
insertMap.put("PART_TYPE", CommonUtils.checkNull((String)insertMap.get("PART_TYPE")));
|
||
insertMap.put("REMARK", CommonUtils.checkNull((String)insertMap.get("REMARK")));
|
||
insertMap.put("SUPPLY_CODE", CommonUtils.checkNull((String)insertMap.get("SUPPLY_CODE")));
|
||
insertMap.put("MAKER", CommonUtils.checkNull((String)insertMap.get("MAKER")));
|
||
insertMap.put("POST_PROCESSING", CommonUtils.checkNull((String)insertMap.get("POST_PROCESSING")));
|
||
insertMap.put("HEAT_TREATMENT_HARDNESS", CommonUtils.checkNull((String)insertMap.get("HEAT_TREATMENT_HARDNESS")));
|
||
insertMap.put("HEAT_TREATMENT_METHOD", CommonUtils.checkNull((String)insertMap.get("HEAT_TREATMENT_METHOD")));
|
||
insertMap.put("SURFACE_TREATMENT", CommonUtils.checkNull((String)insertMap.get("SURFACE_TREATMENT")));
|
||
insertMap.put("STATUS", "deploy"); // 엑셀 업로드 시 deploy 상태로 저장
|
||
insertMap.put("WRITER", CommonUtils.checkNull((String)paramMap.get("CONNECTUSERID")));
|
||
|
||
insertMap.put("CONTRACT_OBJID", CommonUtils.checkNull((String)paramMap.get("CONTRACT_OBJID")));
|
||
insertMap.put("PRODUCT_MGMT_OBJID", CommonUtils.checkNull((String)paramMap.get("product_mgmt_objid")));
|
||
insertMap.put("CONNECTUSERID", CommonUtils.checkNull((String)paramMap.get("CONNECTUSERID")));
|
||
|
||
// 디버깅: SUPPLY_CODE 값 확인
|
||
//System.out.println("=== SUPPLY_CODE DEBUG ===");
|
||
//System.out.println("PART_NO: " + PART_NO);
|
||
//System.out.println("SUPPLY_CODE: " + insertMap.get("SUPPLY_CODE"));
|
||
//System.out.println("========================");
|
||
|
||
partobjMap.put("PART_NO", PART_NO);
|
||
resultMap = (HashMap)sqlSession.selectOne("partMng.getPartObjid", partobjMap); //part_no로 is_last = 1 건 조회
|
||
if(null!=resultMap){
|
||
part_no = CommonUtils.checkNull((String)resultMap.get("part_objid"));
|
||
}else{
|
||
part_no = CommonUtils.createObjId();
|
||
//PART저장
|
||
insertMap.put("PART_OBJID", part_no);
|
||
sqlSession.insert("partMng.insertpartInfo", insertMap);
|
||
|
||
// 파일 저장 부분 주석처리 (프로젝트 경로 정보 없음)
|
||
/*
|
||
Map fileMap = new HashMap();
|
||
fileMap.put("FILE_PATH",filepathFull);
|
||
fileMap.put("WRITER",(String)paramMap.get("CONNECTUSERID"));
|
||
|
||
//첨부저장 PDF 저장
|
||
//sqlSession.insert("part.insertpartfileInfo", fileMap);
|
||
|
||
//dwg
|
||
fileMap.put("OBJID", CommonUtils.createObjId());
|
||
fileMap.put("TARGET_OBJID", part_no);
|
||
fileMap.put("SAVED_FILE_NAME", CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
fileMap.put("REAL_FILE_NAME",CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
fileMap.put("DOC_TYPE" ,"2D_DRAWING_CAD");
|
||
fileMap.put("DOC_TYPE_NAME","2D(Drawing) CAD 첨부파일");
|
||
fileMap.put("FILE_SIZE","167941");
|
||
fileMap.put("FILE_EXT","DWG");
|
||
|
||
System.out.println("fileMap --->"+ fileMap);
|
||
System.out.println(filepathFull+CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
//처부파일 가져오기
|
||
File file = new File(filepathFull+CommonUtils.checkNull((String)insertMap.get("PART_NO")+".dwg"));
|
||
|
||
System.out.println("file --->"+ file.getName());
|
||
System.out.println("checkBeforeFile(file)" +checkBeforeFile(file));
|
||
if(checkBeforeFile(file)){
|
||
//첨부저장이 존재 할때만 DWG 저장
|
||
sqlSession.insert("partMng.insertpartfileInfo", fileMap);
|
||
}
|
||
|
||
//pdf
|
||
file = new File(filepath+projectNo+File.separator+unitName+File.separator+CommonUtils.checkNull((String)insertMap.get("PART_NO")+".pdf"));
|
||
|
||
if(checkBeforeFile(file)){
|
||
fileMap.isEmpty();
|
||
//첨부저장이 존재 할때만 PDF 저장
|
||
fileMap.put("OBJID", CommonUtils.createObjId());
|
||
fileMap.put("TARGET_OBJID", part_no);
|
||
fileMap.put("SAVED_FILE_NAME", CommonUtils.checkNull((String)insertMap.get("PART_NO")+".pdf"));
|
||
fileMap.put("REAL_FILE_NAME",CommonUtils.checkNull((String)insertMap.get("PART_NO")+".pdf"));
|
||
fileMap.put("DOC_TYPE" ,"2D_PDF_CAD");
|
||
fileMap.put("DOC_TYPE_NAME","2D(PDF) CAD 첨부파일");
|
||
fileMap.put("FILE_SIZE","167941");
|
||
fileMap.put("FILE_EXT","PDF");
|
||
//첨부저장이 존재 할때만 DWG 저장
|
||
sqlSession.insert("part.insertpartfileInfo", fileMap);
|
||
}
|
||
*/
|
||
}
|
||
|
||
String parent_part_no = "";
|
||
partobjMap.put("PART_NO", CommonUtils.checkNull((String)insertMap.get("PARENT_PART_NO")));
|
||
resultMap = (HashMap)sqlSession.selectOne("partMng.getPartObjid", partobjMap);
|
||
if(null!=resultMap){
|
||
parent_part_no = CommonUtils.checkNull((String)resultMap.get("part_objid"));
|
||
}
|
||
|
||
String parent_objid ="";
|
||
partobjMap.put("PART_NO", CommonUtils.checkNull((String)insertMap.get("PARENT_PART_NO")));
|
||
partobjMap.put("BOM_REPORT_OBJID", objid);
|
||
// selectList로 변경 (중복 품번 대응)
|
||
List<Map> resultList = sqlSession.selectList("partMng.getBomPartQtyObjid", partobjMap);
|
||
if(resultList != null && resultList.size() > 0){
|
||
resultMap = (HashMap)resultList.get(0); // 첫 번째 결과 사용
|
||
parent_objid = CommonUtils.checkNull((String)resultMap.get("child_objid"));
|
||
}
|
||
|
||
insertMap.put("PARENT_OBJID", parent_objid);
|
||
insertMap.put("CHILD_OBJID", CommonUtils.createObjId());
|
||
|
||
//part objId
|
||
insertMap.put("PARENT_PART_NO", parent_part_no);
|
||
insertMap.put("PART_NO", part_no);
|
||
|
||
System.out.println(" insertMap--->"+insertMap);
|
||
|
||
//BOM저장
|
||
// 기존 BOM 수정 시 deploy 상태는 설정하지 않음 (초기화된 상태 유지)
|
||
|
||
sqlSession.insert("partMng.relatePartInfo", insertMap);
|
||
}//end of gridDataList
|
||
|
||
sqlSession.commit();
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
sqlSession.rollback();
|
||
throw e;
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
static boolean checkBeforeFile(File file){
|
||
//파일이 존재하고
|
||
if(file.exists()){
|
||
//그 파일이 파일이고, 읽을 수 있다면 true를 리턴한다.
|
||
if(file.isFile() && file.canRead()){
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/*dhchoi end*/
|
||
/*************************************************************************************************************************/
|
||
|
||
public Map setChangeDesignPartInfo(HttpServletRequest request, Map paramMap, Map targetPartInfoMap){
|
||
Map<String,Object> resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
//Map<String,Object> targetPartInfoMap = new HashMap();
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
//설변대상의 정보를 가져온다.
|
||
setPartMngCommonCD(paramMap);
|
||
// targetPartInfoMap = sqlSession.selectOne("partMng.partMngInfo", paramMap);
|
||
// targetPartInfoMap = CommonUtils.toUpperCaseMapKey(targetPartInfoMap);
|
||
|
||
if(null != targetPartInfoMap){
|
||
String beforePartObjId = CommonUtils.checkNull(targetPartInfoMap.get("OBJID"));
|
||
String newPartObjId = CommonUtils.createObjId();
|
||
|
||
//resultMap = targetPartInfoMap;
|
||
|
||
targetPartInfoMap.put("OBJID",newPartObjId);
|
||
targetPartInfoMap.put("OBJID_ORG",beforePartObjId);
|
||
targetPartInfoMap.put("STATUS","create");
|
||
targetPartInfoMap.put("IS_LAST","0");
|
||
|
||
List connectFileList = new ArrayList();
|
||
Map fileSqlMap = new HashMap();
|
||
fileSqlMap.put("targetObjId", beforePartObjId);
|
||
connectFileList = sqlSession.selectList("common.getFileList", fileSqlMap);
|
||
|
||
if(null != connectFileList && 0 < connectFileList.size()){
|
||
|
||
connectFileList = CommonUtils.toUpperCaseMapKey(connectFileList);
|
||
|
||
for(int i=0;i<connectFileList.size();i++){
|
||
Map fileInfoMap = new HashMap();
|
||
fileInfoMap = (Map)connectFileList.get(i);
|
||
|
||
String beforeFileObjid = CommonUtils.checkNull(fileInfoMap.get("OBJID"));
|
||
String newFileObjid = CommonUtils.createObjId();
|
||
fileSqlMap.put("NEW_FILE_OBJID", newFileObjid);
|
||
fileSqlMap.put("NEW_PART_OBJID", newPartObjId);
|
||
fileSqlMap.put("BEFORE_FILE_OBJID", beforeFileObjid);
|
||
|
||
sqlSession.insert("partMng.insertChangeDesignPartFile", fileSqlMap);
|
||
}
|
||
sqlSession.commit();
|
||
}
|
||
}
|
||
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return resultMap;
|
||
}
|
||
|
||
public Map setChangeDesignPartInfo(HttpServletRequest request, Map paramMap){
|
||
Map<String,Object> resultMap = new HashMap();
|
||
SqlSession sqlSession = null;
|
||
|
||
Map<String,Object> targetPartInfoMap = new HashMap();
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
//설변대상의 정보를 가져온다.
|
||
setPartMngCommonCD(paramMap);
|
||
|
||
targetPartInfoMap = sqlSession.selectOne("partMng.partMngInfo", paramMap);
|
||
|
||
targetPartInfoMap = CommonUtils.toUpperCaseMapKey(targetPartInfoMap);
|
||
|
||
if(null != targetPartInfoMap){
|
||
String beforePartObjId = CommonUtils.checkNull(targetPartInfoMap.get("OBJID"));
|
||
String newPartObjId = CommonUtils.createObjId();
|
||
|
||
resultMap = targetPartInfoMap;
|
||
|
||
resultMap.put("OBJID",newPartObjId);
|
||
resultMap.put("STATUS","create");
|
||
resultMap.put("IS_LAST","0");
|
||
|
||
List connectFileList = new ArrayList();
|
||
|
||
Map fileSqlMap = new HashMap();
|
||
fileSqlMap.put("targetObjId", beforePartObjId);
|
||
|
||
connectFileList = sqlSession.selectList("common.getFileList", fileSqlMap);
|
||
|
||
if(null != connectFileList && 0 < connectFileList.size()){
|
||
|
||
connectFileList = CommonUtils.toUpperCaseMapKey(connectFileList);
|
||
|
||
for(int i=0;i<connectFileList.size();i++){
|
||
Map fileInfoMap = new HashMap();
|
||
|
||
fileInfoMap = (Map)connectFileList.get(i);
|
||
|
||
String beforeFileObjid = CommonUtils.checkNull(fileInfoMap.get("OBJID"));
|
||
String newFileObjid = CommonUtils.createObjId();
|
||
|
||
fileSqlMap.put("NEW_FILE_OBJID", newFileObjid);
|
||
fileSqlMap.put("NEW_PART_OBJID", newPartObjId);
|
||
fileSqlMap.put("BEFORE_FILE_OBJID", beforeFileObjid);
|
||
|
||
sqlSession.insert("partMng.insertChangeDesignPartFile", fileSqlMap);
|
||
|
||
}
|
||
|
||
sqlSession.commit();
|
||
}
|
||
}
|
||
|
||
}catch(Exception e){
|
||
sqlSession.rollback();
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultMap;
|
||
}
|
||
|
||
|
||
public void saveBomCopySave(HttpServletRequest request,Map paramMap){
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
System.out.println("paramMap ------> " +paramMap);
|
||
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
List<Map<String, Object>> BomPartList = sqlSession.selectList("partMng.getSourceBomPartList", paramMap);
|
||
String TARGET_REV = CommonUtils.checkNull(paramMap.get("TARGET_REV"));
|
||
String BOM_REPORT_OBJID ="";
|
||
if(!"".equals(TARGET_REV)){
|
||
//기존데이터 모두 삭제
|
||
sqlSession.delete("partMng.deleteBomPart", paramMap);
|
||
BOM_REPORT_OBJID = TARGET_REV;
|
||
}else{
|
||
//product_code
|
||
Map info = new HashMap();
|
||
Map newMap = new HashMap();
|
||
newMap.put("product_code", CommonUtils.checkNull(paramMap.get("TARGET_PRODUCT_MGMT_OBJID")));
|
||
info = getBOMStructureRev(request,newMap);
|
||
|
||
System.out.println("info ------> " +info);
|
||
//Map
|
||
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
||
BOM_REPORT_OBJID = CommonUtils.createObjId();
|
||
newMap.put("OBJID", BOM_REPORT_OBJID);
|
||
newMap.put("TARGET_REV", info.get("REV"));
|
||
newMap.put("TARGET_SPEC_NAME", CommonUtils.checkNull(paramMap.get("TARGET_SPEC_NAME")));
|
||
newMap.put("WRITER", person.getUserId());
|
||
//part_bom_report 저장
|
||
sqlSession.insert("partMng.insertPartBomReport", newMap);
|
||
}
|
||
|
||
for(int i=0; i<BomPartList.size(); i++){
|
||
Map insertMap = BomPartList.get(i);
|
||
String OBJID = CommonUtils.createObjId();
|
||
insertMap.put("BOM_REPORT_OBJID", BOM_REPORT_OBJID);
|
||
insertMap.put("OBJID", OBJID);
|
||
insertMap.put("PARENT_OBJID", (String)insertMap.get("parent_objid"));
|
||
insertMap.put("CHILD_OBJID", (String)insertMap.get("child_objid"));
|
||
insertMap.put("PARENT_PART_NO", (String)insertMap.get("parent_part_no"));
|
||
insertMap.put("PART_NO", (String)insertMap.get("part_no"));
|
||
insertMap.put("QTY", (String)insertMap.get("qty"));
|
||
insertMap.put("SEQ", (String)insertMap.get("seq"));
|
||
//part 저장
|
||
sqlSession.insert("partMng.insertBomCopyData", insertMap);
|
||
}
|
||
sqlSession.commit();
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 구조정보의 qty 변경.
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public boolean structureSeqSave(Map paramMap){
|
||
boolean result = false;
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
int cnt = sqlSession.update("partMng.structureSeqSave", paramMap);
|
||
if(cnt > 0) result = true;
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* PART 배포 목록
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public List partMngDeployList(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("partMng.partMngListCnt", 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("partMng.partMngDeployList", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return CommonUtils.toUpperCaseMapKey(resultList);
|
||
}
|
||
|
||
|
||
public ArrayList<HashMap> getPartLinkedBomContractList(Map paramMap){
|
||
ArrayList resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
resultList = CommonUtils.keyChangeUpperArrayList((ArrayList)sqlSession.selectList("partMng.partLinkedBomContractList", paramMap));
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* BOM 계약정보조회
|
||
* @param paramMap
|
||
* @return
|
||
*/
|
||
public Map getBOMContractinfo(HttpServletRequest request,Map paramMap){
|
||
Map resultMap = new HashMap();
|
||
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
||
try{
|
||
resultMap = (HashMap)sqlSession.selectOne("partMng.getBOMContractinfo", paramMap);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||
}
|
||
|
||
public List existPartNoCheck(HttpServletRequest request,Map paramMap){
|
||
List<Map<String,Object>> resultList = new ArrayList();
|
||
SqlSession sqlSession = null;
|
||
|
||
try{
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
||
//part 중복확인
|
||
resultList = sqlSession.selectList("partMng.existPartNoCheck", paramMap);
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* BOM 구조 Part 변경
|
||
* @param paramMap
|
||
* @param partList
|
||
* @return
|
||
*/
|
||
public boolean changeRelatePartInfo(HttpServletRequest request, Map paramMap){
|
||
boolean result = false;
|
||
|
||
//System.out.println("paramMap:"+paramMap);
|
||
|
||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
HttpSession session = request.getSession();
|
||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
Map info = person.getLoginInfo();
|
||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||
|
||
try{
|
||
Map sqlParamMap = new HashMap();
|
||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(paramMap.get("BOM_REPORT_OBJID")));
|
||
sqlParamMap.put("B_OBJID", CommonUtils.checkNull(paramMap.get("OBJID")));
|
||
sqlParamMap.put("RIGHT_OBJID", CommonUtils.checkNull(paramMap.get("rightObjId")));
|
||
|
||
sqlSession.update("partMng.changeRelatePartInfo", sqlParamMap);
|
||
System.out.println("sqlParamMap1::"+sqlParamMap);
|
||
sqlParamMap.put("OBJID", CommonUtils.checkNull(paramMap.get("leftPartObjid")));
|
||
sqlParamMap.put("PARENT_PART_OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||
sqlParamMap.put("PARENT_PART_NO", CommonUtils.checkNull(paramMap.get("leftPartNoQty")));
|
||
sqlParamMap.put("PARENT_QTY_CHILD_OBJID", CommonUtils.checkNull(paramMap.get("leftPartChildObjId")));
|
||
|
||
sqlParamMap.put("CHILD_OBJID", CommonUtils.createObjId());
|
||
sqlParamMap.put("CHANGE_TYPE", CommonUtils.checkNull(paramMap.get("CHANGE_TYPE")));
|
||
sqlParamMap.put("HIS_STATUS", "CHANGE");
|
||
sqlParamMap.put("CHANGE_OPTION", CommonUtils.checkNull(paramMap.get("CHANGE_OPTION")));
|
||
sqlParamMap.put("CHG_PART_OBJID", CommonUtils.checkNull(paramMap.get("rightObjId")));
|
||
sqlParamMap.put("CHG_PART_NO", CommonUtils.checkNull(paramMap.get("rightPartNo")));
|
||
sqlParamMap.put("CHG_PART_REV", CommonUtils.checkNull(paramMap.get("rightPartRev")));
|
||
sqlParamMap.put("STATUS", "adding");
|
||
sqlParamMap.put("WRITER", userId);
|
||
|
||
System.out.println("sqlParamMap2::"+sqlParamMap);
|
||
sqlSession.update("partMng.insertPartMngHistory",sqlParamMap);
|
||
sqlSession.insert("partMng.changeStatusBomReport", sqlParamMap);
|
||
|
||
result = true;
|
||
|
||
sqlSession.commit();
|
||
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
sqlSession.rollback();
|
||
}finally{
|
||
sqlSession.close();
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 도면 파일 정보 DB 저장
|
||
* @param fileMap 파일 정보
|
||
*/
|
||
public void insertDrawingFile(Map<String, Object> fileMap) {
|
||
SqlSession sqlSession = null;
|
||
try {
|
||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
sqlSession.insert("partMng.insertpartfileInfo", fileMap);
|
||
sqlSession.commit();
|
||
} catch(Exception e) {
|
||
e.printStackTrace();
|
||
if(sqlSession != null) {
|
||
sqlSession.rollback();
|
||
}
|
||
throw e;
|
||
} finally {
|
||
if(sqlSession != null) {
|
||
sqlSession.close();
|
||
}
|
||
}
|
||
}
|
||
}
|