3239 lines
113 KiB
Java
3239 lines
113 KiB
Java
/*
|
|
* ContractMgmtService
|
|
*
|
|
* 1.0
|
|
*
|
|
* 2021.10.01
|
|
*
|
|
* Copyright ions
|
|
*/
|
|
package com.pms.salesmgmt.service;
|
|
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.ibatis.session.SqlSession;
|
|
import org.json.simple.JSONArray;
|
|
import org.json.simple.JSONObject;
|
|
import org.json.simple.parser.JSONParser;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import com.pms.common.Message;
|
|
import com.pms.common.SqlMapConfig;
|
|
import com.pms.common.bean.PersonBean;
|
|
import com.pms.common.utils.CommonUtils;
|
|
import com.pms.common.utils.Constants;
|
|
import com.pms.common.utils.MailUtil;
|
|
import com.pms.service.CommonService;
|
|
|
|
/**
|
|
* <pre>
|
|
* 계약관리 Service
|
|
* </pre>
|
|
* @since 2021.10.01
|
|
* @author kim
|
|
* @version 1.0
|
|
*
|
|
* <pre>
|
|
* << 개정 이력 >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ---------------- --------------------- --------------------------------------------------------
|
|
* 2021.10.01 김효일 최초작성
|
|
*
|
|
* </pre>
|
|
*
|
|
*/
|
|
@Service
|
|
public class ContractMgmtService {
|
|
|
|
@Autowired
|
|
CommonService commonService;
|
|
|
|
/**
|
|
* <pre>
|
|
* 계약관리 목록 조회
|
|
* </pre>
|
|
* @param request
|
|
* @param paramMap - 계약관리 검색 정보
|
|
* @return List<Map<String,Object>>
|
|
*
|
|
* <pre>
|
|
* << 개정 이력 >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ---------------- --------------------- ----------------------------------------------------------
|
|
* 2021.10.01 김효일 최초작성
|
|
*
|
|
* </pre>
|
|
*/
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public List<Map<String,Object>> getContractMgmtAll(HttpServletRequest request
|
|
, Map<String, Object> paramMap) {
|
|
|
|
List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
|
|
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("contractMgmt.getContractMgmtListCnt", 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("contractMgmt.getContractMgmtList", paramMap);
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
}
|
|
|
|
/**
|
|
* <pre>
|
|
* 고객, 딜러, 제품를 선택한 계약관리 목록 조회
|
|
* </pre>
|
|
* @param request
|
|
* @param paramMap - 계약관리 검색 정보
|
|
* @return List<Map<String,Object>>
|
|
*
|
|
* <pre>
|
|
* << 개정 이력 >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ---------------- --------------------- ----------------------------------------------------------
|
|
* 2021.10.01 김효일 최초작성
|
|
*
|
|
* </pre>
|
|
*/
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public List<Map<String,Object>> getContractMgmtListRelation(HttpServletRequest request
|
|
, Map<String, Object> paramMap) {
|
|
List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultList = (ArrayList) sqlSession.selectList("contractMgmt.getContractMgmtListRelation", paramMap);
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
}
|
|
|
|
/**
|
|
* <pre>
|
|
* 계약관리 조회
|
|
* </pre>
|
|
* @param paramMap - 계약관리 검색 정보
|
|
* @return Map<String, Object>
|
|
*
|
|
* <pre>
|
|
* << 개정 이력 >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ---------------- --------------------- ----------------------------------------------------------
|
|
* 2021.10.01 김효일 최초작성
|
|
*
|
|
* </pre>
|
|
*/
|
|
public Map<String, Object> getContractMgmt(Map<String, Object> paramMap) {
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultMap = sqlSession.selectOne("contractMgmt.getContractMgmt", paramMap);
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultMap);
|
|
}
|
|
|
|
/**
|
|
* <pre>
|
|
* 계약관리 등록
|
|
* </pre>
|
|
* @param paramMap - 계약관리 정보
|
|
*
|
|
* <pre>
|
|
* << 개정 이력 >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ---------------- --------------------- ----------------------------------------------------------
|
|
* 2021.10.01 김효일 최초작성
|
|
*
|
|
* </pre>
|
|
*/
|
|
public Map<String, Object> saveContractMgmt(HttpServletRequest request
|
|
, Map<String, Object> paramMap){
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String orderDate = (String) paramMap.get("orderDate"); // 계약일자
|
|
orderDate = orderDate.replaceAll("[^0-9]", "");
|
|
paramMap.put("orderDate", orderDate);
|
|
|
|
String finishDate = (String) paramMap.get("finishDate"); // 최종납기일
|
|
finishDate = finishDate.replaceAll("[^0-9]", "");
|
|
paramMap.put("finishDate", finishDate);
|
|
|
|
String orderYm = orderDate.substring(0, 6); // 계약년월
|
|
paramMap.put("orderYm", orderYm);
|
|
|
|
if (paramMap.containsKey("goodsGuarantee") && StringUtils.isBlank((String) paramMap.get("goodsGuarantee"))) {
|
|
paramMap.put("goodsGuarantee", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("goodsQty") && StringUtils.isBlank((String) paramMap.get("goodsQty"))) {
|
|
paramMap.put("goodsQty", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("saleQty") && StringUtils.isBlank((String) paramMap.get("saleQty"))) {
|
|
paramMap.put("saleQty", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("saleQty1") && StringUtils.isBlank((String) paramMap.get("saleQty1"))) {
|
|
paramMap.put("saleQty1", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("supplyQty") && StringUtils.isBlank((String) paramMap.get("supplyQty"))) {
|
|
paramMap.put("supplyQty", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("salePrice") && StringUtils.isBlank((String) paramMap.get("salePrice"))) {
|
|
paramMap.put("salePrice", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("saleAmt") && StringUtils.isBlank((String) paramMap.get("saleAmt"))) {
|
|
paramMap.put("saleAmt", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("vatAmt") && StringUtils.isBlank((String) paramMap.get("vatAmt"))) {
|
|
paramMap.put("vatAmt", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("supplyAmt") && StringUtils.isBlank((String) paramMap.get("supplyAmt"))) {
|
|
paramMap.put("supplyAmt", null);
|
|
}
|
|
|
|
if (paramMap.containsKey("rcptAmt") && StringUtils.isBlank((String) paramMap.get("rcptAmt"))) {
|
|
paramMap.put("rcptAmt", null);
|
|
}
|
|
|
|
if (StringUtils.isBlank((String) paramMap.get("orderNo"))) {
|
|
String acntUnit = (String) paramMap.get("acntUnit"); // 사업부
|
|
|
|
int orderSer = sqlSession.selectOne("contractMgmt.getContractMgmtOrderSer", paramMap); // 일련번호
|
|
paramMap.put("orderSer", orderSer);
|
|
|
|
// 계약번호 생성
|
|
String orderNo = acntUnit + orderYm + StringUtils.leftPad(String.valueOf(orderSer), 3, "0");
|
|
paramMap.put("orderNo", orderNo);
|
|
}
|
|
|
|
// 작성자
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("cretEmpNo", person.getUserId());
|
|
|
|
String cancelFlag = request.getParameter("cancelFlag");
|
|
if (StringUtils.isBlank(cancelFlag) || !"Y".equals(cancelFlag)) {
|
|
cancelFlag = "N";
|
|
paramMap.put("cancelFlag", cancelFlag);
|
|
} else {
|
|
// 취소자
|
|
paramMap.put("cancelWorkMan", person.getUserId());
|
|
}
|
|
|
|
int cnt = sqlSession.update("contractMgmt.insertContractMgmt", 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;
|
|
}
|
|
|
|
/**
|
|
* <pre>
|
|
* 계약관리 삭제
|
|
* </pre>
|
|
* @param paramMap - 계약관리 정보
|
|
*
|
|
* <pre>
|
|
* << 개정 이력 >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ---------------- --------------------- ----------------------------------------------------------
|
|
* 2021.10.01 김효일 최초작성
|
|
*
|
|
* </pre>
|
|
*/
|
|
public Map<String, Object> deleteContractMgmt(HttpServletRequest request
|
|
, Map<String, Object> paramMap){
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
// 취소자
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("cancelWorkMan", person.getUserId());
|
|
|
|
int cnt = sqlSession.delete("contractMgmt.deleteContractMgmt", paramMap);
|
|
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 getcontractList(HttpServletRequest request,Map paramMap){
|
|
List<Map> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
Map pageMap = (HashMap)sqlSession.selectOne("contractMgmt.contractListCnt", paramMap);
|
|
|
|
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
|
|
|
|
paramMap.put("PAGE_END", pageMap.get("PAGE_END"));
|
|
paramMap.put("PAGE_START", pageMap.get("PAGE_START"));
|
|
|
|
resultList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("contractMgmt.contractList", paramMap));
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
|
|
/**
|
|
* 계약관리 목록조회 CNT
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getContractListCnt(HttpServletRequest request,Map paramMap){
|
|
Map<String,Object> pagingMap = new HashMap();
|
|
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("contractMgmt.contractListCnt", paramMap);
|
|
|
|
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
|
|
|
|
paramMap.put("PAGE_END", pageMap.get("PAGE_END"));
|
|
paramMap.put("PAGE_START", pageMap.get("PAGE_START"));*/
|
|
|
|
pagingMap = sqlSession.selectOne("contractMgmt.contractListCnt", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return pagingMap;
|
|
}
|
|
|
|
/**
|
|
* 견적관리 목록조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getestimateList(HttpServletRequest request,Map paramMap){
|
|
List<Map> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
Map pageMap = (HashMap)sqlSession.selectOne("contractMgmt.estimateListCnt", paramMap);
|
|
|
|
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
|
|
|
|
paramMap.put("PAGE_END", pageMap.get("PAGE_END"));
|
|
paramMap.put("PAGE_START", pageMap.get("PAGE_START"));
|
|
|
|
resultList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("contractMgmt.estimateList", paramMap));
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
|
|
/**
|
|
* 계약 등록
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getContractInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("contractMgmt.getOrderMgmtInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
public Map getContractMgmtInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("contractMgmt.getContractMgmtInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
public List overlapOrder(HttpServletRequest request,Map paramMap){
|
|
List<Map<String,Object>> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
//차수 중복확인
|
|
resultList = sqlSession.selectList("contractMgmt.overlapOrder", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/** 견적등록 저장. 프로젝트 생성은 주문서 등록에서 처리 */
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map saveContractMgmtInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
Map resultList = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("writer", person.getUserId());
|
|
int cnt = sqlSession.update("contractMgmt.saveContractMgmtInfo", paramMap);
|
|
|
|
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;
|
|
}
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map saveContractMgmtInfo_old(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
Map resultList = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("writer", person.getUserId());
|
|
int cnt = sqlSession.update("contractMgmt.saveContractMgmtInfo", paramMap);
|
|
|
|
//영업 수주 완료시 자동 프로젝트 등록 로직
|
|
String result_cd= CommonUtils.checkNull(paramMap.get("contract_result"));
|
|
String contract_objid= CommonUtils.checkNull(paramMap.get("objId"));
|
|
String category_cd= CommonUtils.checkNull(paramMap.get("category_cd"));
|
|
String target_project_no= CommonUtils.checkNull(paramMap.get("target_project_no_direct"));
|
|
int overhaul_order = Integer.parseInt(CommonUtils.checkNull(paramMap.get("overhaul_order"),"1"));
|
|
int project_cnt= Integer.parseInt(CommonUtils.checkNull(paramMap.get("facility_qty"), "1"));
|
|
long contract_price_currency= Long.parseLong(CommonUtils.checkNull(paramMap.get("contract_price_currency"), "0"));
|
|
long contract_price= Long.parseLong(CommonUtils.checkNull(paramMap.get("contract_price"), "0"));
|
|
|
|
//수주가와 금액은 대수로 나누어서 등록
|
|
paramMap.put("contract_price_currency", contract_price_currency/project_cnt + "");
|
|
paramMap.put("contract_price", contract_price/project_cnt + "");
|
|
|
|
if("0000964".equals(result_cd)){
|
|
resultList = sqlSession.selectOne("contractMgmt.getProjectListBycontractObjid", paramMap);
|
|
System.out.println("resultList:::"+resultList);
|
|
//resultList = sqlSession.selectOne("contractMgmt.getProjectCnt", paramMap);
|
|
if(null==resultList){
|
|
|
|
for (int i=0; i<project_cnt; i++){
|
|
|
|
paramMap.put("OBJID", CommonUtils.createObjId());
|
|
paramMap.put("is_temp", '1');
|
|
paramMap.put("facility_qty", '1');
|
|
if("0000170".equals(category_cd) || "0000171".equals(category_cd)){
|
|
paramMap.put("overhaul_project_no", target_project_no);
|
|
paramMap.put("overhaul_order", overhaul_order+i);
|
|
}else{
|
|
}
|
|
//프로젝트 등록
|
|
cnt = sqlSession.update("project.createProject", paramMap);
|
|
//프로젝트 TASK 등록
|
|
cnt = sqlSession.insert("contractMgmt.insertProjectTask", paramMap);
|
|
//프로젝트 SETUP_TASK 등록
|
|
cnt = sqlSession.insert("contractMgmt.insertProjectSetupTask", paramMap);
|
|
|
|
//project_no - unit 폴더 생성
|
|
//paramMap.put("OBJID", paramMap.get("OBJID"));
|
|
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", paramMap);
|
|
|
|
paramMap.put("contract_objid", paramMap.get("objId"));
|
|
paramMap.put("customer_product", paramMap.get("mechanical_type"));
|
|
List<Map<String,Object>> taskUnitList = (ArrayList)sqlSession.selectList("project.getWbsTaskListByProject", paramMap);
|
|
if(CommonUtils.isNotEmpty(taskUnitList) && !taskUnitList.isEmpty()){
|
|
String projectNo = (String)projectInfo.get("project_no");
|
|
String filepath = Constants.FILE_STORAGE+"\\PART_DATA\\";
|
|
for (Map<String, Object> map : taskUnitList) {
|
|
File file = new File(filepath+File.separator+projectNo+File.separator+CommonUtils.checkNull((String)map.get("unit_no"))+"-"+CommonUtils.checkNull((String)map.get("task_name")));
|
|
if(!file.exists()){
|
|
file.mkdirs();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
sqlSession.update("project.ModifyProjectByContract", paramMap);
|
|
}
|
|
}
|
|
if(cnt > 0){
|
|
//계약완료 일시 메일
|
|
if("0000964".equals(CommonUtils.checkNull(paramMap.get("contract_result")))){
|
|
commonService.SendMail(paramMap,"CONTRACT_COMP",CommonUtils.checkNull(paramMap.get("pm_user_id")));
|
|
//그냥 등록일때 메일
|
|
}else{
|
|
if("regist".equals(CommonUtils.checkNull(paramMap.get("actionType")))){
|
|
commonService.SendMail(paramMap,"CONTRACT_REG",CommonUtils.checkNull(paramMap.get("")));
|
|
}
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map saveContractMgmtReviewInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("writer", person.getUserId());
|
|
int cnt = sqlSession.update("contractMgmt.saveContractMgmtReviewInfo", paramMap);
|
|
|
|
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
|
|
*/
|
|
public void setMonthColumn(HttpServletRequest request, Map paramMap){
|
|
ArrayList<HashMap<String,Object>> monthList = new ArrayList();
|
|
try{
|
|
for(int i=0;i<12;i++){
|
|
HashMap monthMap = new HashMap();
|
|
String month = String.valueOf(i+1);
|
|
String monthTitle = month+"월";
|
|
|
|
monthMap.put("MONTH_TITLE", monthTitle);
|
|
|
|
if(i+1 < 10){
|
|
month = "0"+month;
|
|
}
|
|
|
|
monthMap.put("MONTH", month);
|
|
monthMap.put("CONTRACT_MONTH_COL_NAME", "CONTRACT_CNT_MONTH_"+month);
|
|
monthMap.put("CONTRACT_COST_MONTH_COL_NAME", "CONTRACT_COST_MONTH_"+month);
|
|
monthMap.put("RELEASE_MONTH_COL_NAME", "RELEASE_CNT_MONTH_"+month);
|
|
monthMap.put("MONTH_FIRST_DAY_COL_NAME", "MONTH_FIRST_DAY_"+month);
|
|
monthMap.put("MONTH_LAST_DAY_COL_NAME", "MONTH_LAST_DAY_"+month);
|
|
|
|
monthList.add(monthMap);
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
paramMap.put("monthList", monthList);
|
|
|
|
request.setAttribute("monthList", monthList);
|
|
}
|
|
|
|
/**
|
|
* 고객사의 목록을 가져온다.(페이징 처리된 목록)
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList<HashMap<String,Object>> getSUPPLYInfoListPaging(HttpServletRequest request,Map<String,Object> paramMap){
|
|
ArrayList<HashMap<String,Object>> oemInfoList = 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("contractMgmt.getSUPPLYInfoListCnt", paramMap);
|
|
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
|
|
|
|
paramMap.put("PAGE_END", pageMap.get("PAGE_END"));
|
|
paramMap.put("PAGE_START", pageMap.get("PAGE_START"));
|
|
|
|
oemInfoList = (ArrayList)sqlSession.selectList("contractMgmt.getSUPPLYInfoList", paramMap);
|
|
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(oemInfoList);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 고객사의 정보를 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public HashMap<String,Object> getSupMngInfo(HttpServletRequest request,Map<String,Object> paramMap){
|
|
HashMap<String,Object> oemInfo = new HashMap();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
|
|
String objid = CommonUtils.checkNull(request.getParameter("objid"));
|
|
|
|
if(!"".equals(objid)){
|
|
HashMap sqlParamMap = new HashMap();
|
|
sqlParamMap.put("objid", objid);
|
|
oemInfo = (HashMap)sqlSession.selectOne("contractMgmt.getSupMngInfo", sqlParamMap);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(oemInfo);
|
|
}
|
|
|
|
//황의돈=================================================================================================
|
|
/**
|
|
* 계약현황
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getContractDashBoard(HttpServletRequest request,Map paramMap){
|
|
List<Map<String,Object>> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("contractMgmt.getContractDashBoard", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
}
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map deleteContractMngInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
System.out.println("paramMap : "+paramMap);
|
|
|
|
String[] objIds = request.getParameterValues("objId");
|
|
|
|
int cnt = 0;
|
|
for(int i=0; i<objIds.length; i++){
|
|
paramMap.put("objId", objIds[i]);
|
|
cnt += sqlSession.update("contractMgmt.deleteContractMngInfo", paramMap);
|
|
}
|
|
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.DELETE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map deletesupplyMngInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
System.out.println("paramMap : "+paramMap);
|
|
|
|
String[] objIds = request.getParameterValues("objId");
|
|
|
|
int cnt = 0;
|
|
for(int i=0; i<objIds.length; i++){
|
|
paramMap.put("objId", objIds[i]);
|
|
cnt += sqlSession.update("contractMgmt.deletesupplyMngInfo", paramMap);
|
|
}
|
|
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.DELETE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 계약 옵션 리스트
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getContractOptionList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("contractMgmt.getContractOptionList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
}
|
|
|
|
|
|
/** 공급업체 등록
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map saveSupMgmtInfo(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 writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
paramMap.put("userId", writer);*/
|
|
|
|
int cnt = sqlSession.update("contractMgmt.mergeSupMgmtInfo", paramMap);
|
|
|
|
String objid = CommonUtils.checkNull(paramMap.get("objid"));
|
|
|
|
//paramMap.put("objid", CommonUtils.createObjId());
|
|
//paramMap.put("targetObjid", objid);
|
|
//paramMap.put("writer", writer);
|
|
|
|
//sqlSession.update("admin.insertSupplyMngHistory", paramMap);
|
|
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
|
|
/**
|
|
* 상담내역 목록조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List counselingList(HttpServletRequest request,Map paramMap){
|
|
List<Map> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
Map pageMap = (HashMap)sqlSession.selectOne("contractMgmt.counselingListCnt", paramMap);
|
|
|
|
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
|
|
|
|
paramMap.put("PAGE_END", pageMap.get("PAGE_END"));
|
|
paramMap.put("PAGE_START", pageMap.get("PAGE_START"));
|
|
|
|
resultList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("contractMgmt.counselingList", paramMap));
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
public Map getcounselingMgmtInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("contractMgmt.getcounselingMgmtInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
|
|
/** 공급업체 등록
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map savecounselingInfo(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 writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
paramMap.put("userId", writer);
|
|
|
|
int cnt = sqlSession.update("contractMgmt.savecounselingInfo", 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 Map getEstimateMgmtInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("contractMgmt.getEstimateMgmtInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map saveEstimateMgmtInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("userId", person.getUserId());
|
|
int cnt = sqlSession.update("contractMgmt.saveEstimateMgmtInfo", paramMap);
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map deleteEstimateMgmtInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
System.out.println("paramMap : "+paramMap);
|
|
|
|
String[] objIds = request.getParameterValues("chk_objId");
|
|
|
|
int cnt = 0;
|
|
for(int i=0; i<objIds.length; i++){
|
|
paramMap.put("objId", objIds[i]);
|
|
cnt += sqlSession.delete("contractMgmt.deleteEstimateMgmtInfo", paramMap);
|
|
}
|
|
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.DELETE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
//계약등록
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map createEstimateMgmtInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
System.out.println("paramMap : "+paramMap);
|
|
|
|
String[] objIds = request.getParameterValues("chk_objId");
|
|
|
|
int cnt = 0;
|
|
for(int i=0; i<objIds.length; i++){
|
|
paramMap.put("objId", objIds[i]);
|
|
//견적 상태값 계약완료로 변경
|
|
cnt += sqlSession.update("contractMgmt.updateEstimateMgmtInfo", paramMap);
|
|
|
|
paramMap.put("contractobjid",CommonUtils.createObjId());
|
|
|
|
//견적 내용 계약으로 등록
|
|
cnt += sqlSession.insert("contractMgmt.createEstimateMgmtInfo", paramMap);
|
|
}
|
|
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.DELETE_FAILED);
|
|
e.printStackTrace();
|
|
sqlSession.rollback();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 영업목표 Form PopUp
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map<String,Object> getYearGoalInfo(HttpServletRequest request,Map paramMap){
|
|
Map<String,Object> resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
resultMap = (HashMap)sqlSession.selectOne("contractMgmt.getYearGoalInfo", paramMap);
|
|
|
|
String yearGoalObjId = "";
|
|
if(CommonUtils.isNotEmpty(resultMap)){
|
|
yearGoalObjId = CommonUtils.checkNull(resultMap.get("year_goal_objid"));
|
|
}else{
|
|
resultMap = new HashMap();
|
|
}
|
|
|
|
if("".equals(yearGoalObjId)){
|
|
yearGoalObjId = CommonUtils.createObjId();
|
|
}
|
|
|
|
resultMap.put("YEAR_GOAL_OBJID", yearGoalObjId);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultMap);
|
|
}
|
|
/**
|
|
* 영업목표 저장
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map<String,Object> saveYearGoalInfo(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);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
paramMap.put("WRITER", writer);
|
|
|
|
sqlSession.insert("contractMgmt.saveYearGoalInfo", paramMap);
|
|
|
|
sqlSession.commit();
|
|
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
|
|
}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 Map<String,Object> deleteYearGoalInfo(HttpServletRequest request,Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String targetObjId = CommonUtils.checkNull(paramMap.get("checkArr"));
|
|
|
|
System.out.println("paramMap:"+paramMap);
|
|
|
|
if(!"".equals(targetObjId)){
|
|
sqlSession.delete("contractMgmt.deleteYearGoalInfo", paramMap);
|
|
|
|
sqlSession.commit();
|
|
}
|
|
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
|
|
}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 getCustomerContactInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
resultMap = (Map) sqlSession.selectOne("contractMgmt.getCustomerContactInfo", paramMap);
|
|
} catch(Exception e){
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 기본 정보 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getEstimateTemplateInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
|
String templateObjId = CommonUtils.checkNull(paramMap.get("templateObjId"));
|
|
String templateType = CommonUtils.checkNull(paramMap.get("template_type"));
|
|
|
|
System.out.println("=== getEstimateTemplateInfo 파라미터 ===");
|
|
System.out.println("objId: " + objId);
|
|
System.out.println("templateObjId: " + templateObjId);
|
|
System.out.println("templateType: " + templateType);
|
|
|
|
// templateObjId가 있으면 직접 조회
|
|
if(!"".equals(templateObjId) && !"-1".equals(templateObjId)){
|
|
paramMap.put("templateObjId", templateObjId);
|
|
}
|
|
|
|
// objId 또는 templateObjId 중 하나라도 있으면 조회
|
|
if((!"".equals(objId) && !"-1".equals(objId)) || (!"".equals(templateObjId) && !"-1".equals(templateObjId))){
|
|
// 견적서 기본 정보 조회 (CONTRACT_MGMT 테이블에서)
|
|
Map baseInfo = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateInfo", paramMap);
|
|
System.out.println("baseInfo: " + baseInfo);
|
|
if(baseInfo != null){
|
|
resultMap = CommonUtils.toUpperCaseMapKey(baseInfo);
|
|
System.out.println("baseInfo (변환 후): " + resultMap);
|
|
}
|
|
|
|
// 견적서 템플릿 정보 조회 (ESTIMATE_TEMPLATE 테이블에서, 있는 경우)
|
|
Map templateInfo = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateData", paramMap);
|
|
System.out.println("templateInfo: " + templateInfo);
|
|
if(templateInfo != null && !templateInfo.isEmpty()){
|
|
templateInfo = CommonUtils.toUpperCaseMapKey(templateInfo);
|
|
System.out.println("templateInfo (변환 후): " + templateInfo);
|
|
resultMap.putAll(templateInfo);
|
|
}
|
|
|
|
System.out.println("최종 resultMap 크기: " + resultMap.size());
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 품목 정보 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List<Map> getEstimateTemplateItems(Map paramMap){
|
|
List<Map> resultList = new ArrayList<Map>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
|
String templateObjId = CommonUtils.checkNull(paramMap.get("templateObjId"));
|
|
String templateType = CommonUtils.checkNull(paramMap.get("template_type"));
|
|
|
|
System.out.println("=== getEstimateTemplateItems 파라미터 ===");
|
|
System.out.println("objId: " + objId);
|
|
System.out.println("templateObjId: " + templateObjId);
|
|
System.out.println("templateType: " + templateType);
|
|
|
|
// templateObjId가 있으면 우선 사용, 없으면 objId 사용
|
|
String targetId = !"".equals(templateObjId) && !"-1".equals(templateObjId) ? templateObjId : objId;
|
|
|
|
if(!"".equals(targetId) && !"-1".equals(targetId)){
|
|
// 장비 견적서(Template 2)인 경우 categories_json에서 데이터 가져오기
|
|
if("2".equals(templateType)){
|
|
// templateObjId가 있으면 직접 조회, 없으면 contract_objid로 조회
|
|
if(!"".equals(templateObjId) && !"-1".equals(templateObjId)){
|
|
paramMap.put("templateObjId", templateObjId);
|
|
}
|
|
|
|
// ESTIMATE_TEMPLATE에서 categories_json 조회
|
|
Map templateData = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateData", paramMap);
|
|
System.out.println("=== getEstimateTemplateItems 디버깅 ===");
|
|
System.out.println("templateData (변환 전): " + templateData);
|
|
|
|
if(templateData != null){
|
|
// 대문자로 변환
|
|
templateData = CommonUtils.toUpperCaseMapKey(templateData);
|
|
System.out.println("templateData (변환 후): " + templateData);
|
|
|
|
// 대소문자 모두 체크 (안전장치)
|
|
String categoriesJson = CommonUtils.checkNull(templateData.get("CATEGORIES_JSON"));
|
|
if("".equals(categoriesJson)) categoriesJson = CommonUtils.checkNull(templateData.get("categories_json"));
|
|
|
|
System.out.println("categoriesJson: " + categoriesJson);
|
|
|
|
if(categoriesJson != null && !categoriesJson.isEmpty()){
|
|
// JSON 파싱 (Gson 사용)
|
|
com.google.gson.Gson gson = new com.google.gson.Gson();
|
|
java.lang.reflect.Type listType = new com.google.gson.reflect.TypeToken<List<Map>>(){}.getType();
|
|
resultList = gson.fromJson(categoriesJson, listType);
|
|
System.out.println("파싱된 resultList 크기: " + resultList.size());
|
|
}
|
|
}
|
|
}
|
|
// 일반 견적서(Template 1)인 경우 기존 방식대로 ESTIMATE_TEMPLATE_ITEM에서 조회
|
|
else {
|
|
resultList = sqlSession.selectList("contractMgmt.getEstimateTemplateItems", paramMap);
|
|
}
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 목록 조회
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getEstimateTemplateList(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
List<Map> list = sqlSession.selectList("contractMgmt.getEstimateTemplateList", paramMap);
|
|
|
|
resultMap.put("result", "success");
|
|
resultMap.put("list", list);
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", "error");
|
|
resultMap.put("msg", "목록 조회 중 오류가 발생했습니다.");
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 OBJID로 조회 (견적현황 클릭 시)
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getEstimateTemplateByObjId(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String templateObjId = CommonUtils.checkNull(paramMap.get("templateObjId"));
|
|
|
|
if(!"".equals(templateObjId) && !"-1".equals(templateObjId)){
|
|
// ESTIMATE_TEMPLATE 테이블에서 직접 조회
|
|
resultMap = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateByObjId", paramMap);
|
|
|
|
// CONTRACT_MGMT 정보도 함께 조회
|
|
if(resultMap != null && !resultMap.isEmpty()){
|
|
String contractObjId = CommonUtils.checkNull(resultMap.get("CONTRACT_OBJID"));
|
|
if(!"".equals(contractObjId)){
|
|
Map contractInfo = new HashMap();
|
|
contractInfo.put("objId", contractObjId);
|
|
Map contractData = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateInfo", contractInfo);
|
|
if(contractData != null && !contractData.isEmpty()){
|
|
// CONTRACT 정보를 resultMap에 추가 (템플릿 정보가 우선)
|
|
contractData.putAll(resultMap);
|
|
resultMap = contractData;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 품목 조회 (템플릿 OBJID로)
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List<Map> getEstimateTemplateItemsByTemplateObjId(Map paramMap){
|
|
List<Map> resultList = new ArrayList<Map>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String templateObjId = CommonUtils.checkNull(paramMap.get("templateObjId"));
|
|
|
|
if(!"".equals(templateObjId) && !"-1".equals(templateObjId)){
|
|
resultList = sqlSession.selectList("contractMgmt.getEstimateTemplateItemsByTemplateObjId", paramMap);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 저장
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map saveEstimateTemplate(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);
|
|
String userId = person.getUserId();
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId")); // CONTRACT_OBJID
|
|
String templateObjId = CommonUtils.checkNull(paramMap.get("templateObjId")); // 기존 템플릿 수정 시
|
|
String templateType = CommonUtils.checkNull(paramMap.get("template_type"));
|
|
String itemsJson = CommonUtils.checkNull(paramMap.get("items"));
|
|
String categoriesJson = CommonUtils.checkNull(paramMap.get("categories"));
|
|
|
|
// 합계 정보 (일반 견적서용)
|
|
String totalAmount = CommonUtils.checkNull(paramMap.get("total_amount"));
|
|
String totalAmountKrw = CommonUtils.checkNull(paramMap.get("total_amount_krw"));
|
|
|
|
paramMap.put("writer", userId);
|
|
paramMap.put("chg_user_id", userId);
|
|
paramMap.put("total_amount", totalAmount);
|
|
paramMap.put("total_amount_krw", totalAmountKrw);
|
|
|
|
// 기존 템플릿 수정인지 신규 작성인지 확인
|
|
// 중요: templateObjId가 명시적으로 있을 때만 수정, 없으면 항상 신규 작성
|
|
boolean isUpdate = false;
|
|
|
|
if(!"".equals(templateObjId) && !"-1".equals(templateObjId)){
|
|
// templateObjId가 명시적으로 있으면 해당 템플릿 수정 (견적현황에서 기존 견적서 열어서 수정한 경우)
|
|
Map existingTemplate = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateByObjId", paramMap);
|
|
if(existingTemplate != null && !existingTemplate.isEmpty()){
|
|
isUpdate = true;
|
|
paramMap.put("template_objid", templateObjId);
|
|
}
|
|
}
|
|
// else: templateObjId가 없으면 항상 신규 견적서 작성 (같은 영업번호에 여러 견적서 가능)
|
|
|
|
if(isUpdate){
|
|
// 기존 견적서 수정
|
|
sqlSession.update("contractMgmt.updateEstimateTemplate", paramMap);
|
|
} else {
|
|
// 신규 견적서 작성 - 새로운 OBJID 생성
|
|
templateObjId = CommonUtils.createObjId();
|
|
paramMap.put("template_objid", templateObjId);
|
|
paramMap.put("contract_objid", objId);
|
|
sqlSession.insert("contractMgmt.insertEstimateTemplate", paramMap);
|
|
}
|
|
|
|
// 기존 품목 삭제
|
|
sqlSession.delete("contractMgmt.deleteEstimateTemplateItems", paramMap);
|
|
|
|
// 품목 정보 저장
|
|
if(!"".equals(itemsJson)){
|
|
// JSON 파싱 및 저장 로직 (실제 구현 시 JSON 라이브러리 사용)
|
|
// 여기서는 간단히 파라미터로 받은 데이터를 저장
|
|
paramMap.put("items_json", itemsJson);
|
|
sqlSession.insert("contractMgmt.insertEstimateTemplateItems", paramMap);
|
|
}
|
|
|
|
// 카테고리 정보 저장 (장비 견적서용)
|
|
if(!"".equals(categoriesJson)){
|
|
paramMap.put("categories_json", categoriesJson);
|
|
sqlSession.update("contractMgmt.updateEstimateTemplateCategories", paramMap);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
|
|
resultMap.put("result", "success");
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
|
|
}catch(Exception e){
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
resultMap.put("result", "error");
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 장비 견적서 저장 (Template 2)
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map saveEstimateTemplate2(HttpServletRequest request, Map paramMap) throws Exception {
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String userId = CommonUtils.checkNull(paramMap.get("userId"));
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
|
String templateObjId = CommonUtils.checkNull(paramMap.get("templateObjId"));
|
|
String categoriesJson = CommonUtils.checkNull(paramMap.get("categories"));
|
|
|
|
paramMap.put("writer", userId);
|
|
paramMap.put("chg_user_id", userId);
|
|
paramMap.put("template_type", "2"); // 장비 견적서
|
|
|
|
// 기존 템플릿 수정인지 신규 작성인지 확인
|
|
boolean isUpdate = false;
|
|
|
|
if(!"".equals(templateObjId) && !"-1".equals(templateObjId)){
|
|
Map existingTemplate = (Map) sqlSession.selectOne("contractMgmt.getEstimateTemplateByObjId", paramMap);
|
|
if(existingTemplate != null && !existingTemplate.isEmpty()){
|
|
isUpdate = true;
|
|
paramMap.put("template_objid", templateObjId);
|
|
|
|
// objId가 없으면 기존 템플릿에서 가져오기
|
|
if("".equals(objId) || "-1".equals(objId)){
|
|
existingTemplate = CommonUtils.toUpperCaseMapKey(existingTemplate);
|
|
objId = CommonUtils.checkNull(existingTemplate.get("CONTRACT_OBJID"));
|
|
paramMap.put("contract_objid", objId);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(isUpdate){
|
|
// 기존 견적서 수정
|
|
sqlSession.update("contractMgmt.updateEstimateTemplate2", paramMap);
|
|
} else {
|
|
// 신규 견적서 작성
|
|
templateObjId = CommonUtils.createObjId();
|
|
paramMap.put("template_objid", templateObjId);
|
|
paramMap.put("contract_objid", objId);
|
|
sqlSession.insert("contractMgmt.insertEstimateTemplate2", paramMap);
|
|
}
|
|
|
|
// 카테고리 정보 저장 (categories_json 필드에 저장)
|
|
if(!"".equals(categoriesJson)){
|
|
paramMap.put("categories_json", categoriesJson);
|
|
sqlSession.update("contractMgmt.updateEstimateTemplateCategories", paramMap);
|
|
}
|
|
|
|
// 장비 견적서도 ESTIMATE_TEMPLATE_ITEM에 저장 (일관성을 위해)
|
|
// 기존 품목 삭제
|
|
sqlSession.delete("contractMgmt.deleteEstimateTemplateItems", paramMap);
|
|
|
|
// 품목 정보 생성 및 저장
|
|
String partName = CommonUtils.checkNull(paramMap.get("part_name"));
|
|
String partObjId = CommonUtils.checkNull(paramMap.get("part_objid"));
|
|
Object totalAmount = paramMap.get("total_amount");
|
|
|
|
if(!"".equals(partName) && totalAmount != null) {
|
|
try {
|
|
long amount = Long.parseLong(totalAmount.toString().replaceAll("[^0-9]", ""));
|
|
|
|
// 수량은 categories JSON에서 CNC Machine의 quantity를 가져옴
|
|
int quantity = 1; // 기본값
|
|
|
|
System.out.println("=== 장비 견적서 수량 추출 시작 ===");
|
|
System.out.println("categoriesJson: " + categoriesJson);
|
|
|
|
if(!"".equals(categoriesJson)) {
|
|
try {
|
|
// JSON 파싱
|
|
org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
|
|
org.json.simple.JSONArray categoriesArray = (org.json.simple.JSONArray) parser.parse(categoriesJson);
|
|
|
|
System.out.println("categories 배열 크기: " + categoriesArray.size());
|
|
|
|
// CNC Machine 카테고리 찾기
|
|
for(int i = 0; i < categoriesArray.size(); i++) {
|
|
org.json.simple.JSONObject category = (org.json.simple.JSONObject) categoriesArray.get(i);
|
|
String categoryId = (String) category.get("category");
|
|
|
|
System.out.println("카테고리 " + i + ": " + categoryId);
|
|
|
|
if("cnc_machine".equals(categoryId)) {
|
|
System.out.println("CNC Machine 카테고리 찾음!");
|
|
|
|
// cnc_machine의 quantity는 items 배열 안에 있음
|
|
org.json.simple.JSONArray items = (org.json.simple.JSONArray) category.get("items");
|
|
System.out.println("items 배열: " + items);
|
|
|
|
if(items != null && items.size() > 0) {
|
|
org.json.simple.JSONObject firstItem = (org.json.simple.JSONObject) items.get(0);
|
|
Object qtyObj = firstItem.get("quantity");
|
|
|
|
System.out.println("quantity 객체: " + qtyObj);
|
|
System.out.println("quantity 타입: " + (qtyObj != null ? qtyObj.getClass().getName() : "null"));
|
|
|
|
if(qtyObj != null && !"".equals(qtyObj.toString().trim())) {
|
|
// quantity는 텍스트 형식일 수 있으므로 첫 줄만 추출
|
|
String qtyStr = qtyObj.toString().split("\n")[0].trim();
|
|
System.out.println("추출된 수량 문자열: '" + qtyStr + "'");
|
|
|
|
if(!qtyStr.isEmpty()) {
|
|
String numOnly = qtyStr.replaceAll("[^0-9]", "");
|
|
System.out.println("숫자만 추출: '" + numOnly + "'");
|
|
|
|
if(!numOnly.isEmpty()) {
|
|
quantity = Integer.parseInt(numOnly);
|
|
System.out.println("최종 수량: " + quantity);
|
|
}
|
|
}
|
|
} else {
|
|
System.out.println("quantity가 null이거나 비어있음");
|
|
}
|
|
} else {
|
|
System.out.println("items 배열이 비어있음");
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
System.out.println("최종 결정된 수량: " + quantity);
|
|
} catch(Exception e) {
|
|
System.out.println("수량 추출 실패, 기본값 1 사용");
|
|
e.printStackTrace();
|
|
}
|
|
} else {
|
|
System.out.println("categoriesJson이 비어있음");
|
|
}
|
|
|
|
// 단가 계산 (총액 / 수량)
|
|
long unitPrice = quantity > 0 ? amount / quantity : amount;
|
|
|
|
// JSON 형식으로 품목 데이터 생성
|
|
String itemJson = "[{" +
|
|
"\"seq\": 1," +
|
|
"\"category\": \"\"," +
|
|
"\"part_objid\": \"" + partObjId + "\"," +
|
|
"\"description\": \"" + partName + "\"," +
|
|
"\"specification\": \"\"," +
|
|
"\"quantity\": " + quantity + "," +
|
|
"\"unit\": \"EA\"," +
|
|
"\"unit_price\": " + unitPrice + "," +
|
|
"\"amount\": " + amount + "," +
|
|
"\"note\": \"\"," +
|
|
"\"remark\": \"\"" +
|
|
"}]";
|
|
|
|
paramMap.put("items_json", itemJson);
|
|
sqlSession.insert("contractMgmt.insertEstimateTemplateItems", paramMap);
|
|
|
|
System.out.println("장비 견적서 품목 저장 완료 - 품명: " + partName + ", 수량: " + quantity + ", 단가: " + unitPrice);
|
|
} catch(Exception e) {
|
|
System.out.println("장비 견적서 품목 저장 실패: " + e.getMessage());
|
|
e.printStackTrace();
|
|
// 품목 저장 실패해도 견적서는 저장되도록 예외를 던지지 않음
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
|
|
resultMap.put("result", "success");
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
|
|
}catch(Exception e){
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
throw e; // 예외를 컨트롤러로 전달
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 견적서 메일 발송
|
|
* @param request
|
|
* @param paramMap - objId (CONTRACT_OBJID)
|
|
* @return
|
|
*/
|
|
public Map sendEstimateMail(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
|
|
|
// 1. 계약 정보 조회
|
|
Map contractInfo = (Map) sqlSession.selectOne("contractMgmt.getContractInfoForMail", paramMap);
|
|
if(contractInfo == null || contractInfo.isEmpty()){
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "계약 정보를 찾을 수 없습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
// 2. 최종 차수 견적서 조회
|
|
Map estimateTemplate = (Map) sqlSession.selectOne("contractMgmt.getLatestEstimateTemplate", paramMap);
|
|
if(estimateTemplate == null || estimateTemplate.isEmpty()){
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "견적서를 찾을 수 없습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
// 디버깅: estimateTemplate 출력
|
|
System.out.println("===== Estimate Template Debug =====");
|
|
for(Object key : estimateTemplate.keySet()){
|
|
System.out.println(key + " = " + estimateTemplate.get(key));
|
|
}
|
|
System.out.println("===================================");
|
|
|
|
String templateObjId = CommonUtils.checkNull(estimateTemplate.get("objid"));
|
|
if("".equals(templateObjId)) templateObjId = CommonUtils.checkNull(estimateTemplate.get("OBJID"));
|
|
|
|
String templateType = CommonUtils.checkNull(estimateTemplate.get("template_type"));
|
|
if("".equals(templateType)) templateType = CommonUtils.checkNull(estimateTemplate.get("TEMPLATE_TYPE"));
|
|
|
|
// 3. 견적서 품목 조회
|
|
List<Map> estimateItems = new ArrayList<Map>();
|
|
|
|
if("2".equals(templateType)) {
|
|
// 장비 견적서 (Template 2): CATEGORIES_JSON 파싱
|
|
String categoriesJson = CommonUtils.checkNull(estimateTemplate.get("categories_json"));
|
|
if("".equals(categoriesJson)) categoriesJson = CommonUtils.checkNull(estimateTemplate.get("CATEGORIES_JSON"));
|
|
|
|
if(!"".equals(categoriesJson)) {
|
|
try {
|
|
Gson gson = new Gson();
|
|
List<Map> categories = gson.fromJson(categoriesJson, List.class);
|
|
|
|
// CNC Machine 카테고리의 items 추출
|
|
for(Map category : categories) {
|
|
String categoryName = CommonUtils.checkNull(category.get("category"));
|
|
if("cnc_machine".equals(categoryName)) {
|
|
List<Map> items = (List<Map>) category.get("items");
|
|
if(items != null && !items.isEmpty()) {
|
|
estimateItems.addAll(items);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
} catch(Exception e) {
|
|
System.out.println("CATEGORIES_JSON 파싱 오류: " + e.getMessage());
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
} else {
|
|
// 일반 견적서 (Template 1): ESTIMATE_TEMPLATE_ITEM 테이블 조회
|
|
Map itemParam = new HashMap();
|
|
itemParam.put("templateObjId", templateObjId);
|
|
estimateItems = sqlSession.selectList("contractMgmt.getEstimateTemplateItemsByTemplateObjId", itemParam);
|
|
}
|
|
|
|
System.out.println("===== Estimate Items Debug =====");
|
|
System.out.println("Template Type: " + templateType);
|
|
System.out.println("Items count: " + (estimateItems != null ? estimateItems.size() : 0));
|
|
if(estimateItems != null && !estimateItems.isEmpty()){
|
|
for(int i = 0; i < Math.min(3, estimateItems.size()); i++){
|
|
Map item = estimateItems.get(i);
|
|
System.out.println("Item " + (i+1) + " keys: " + item.keySet());
|
|
}
|
|
}
|
|
System.out.println("================================");
|
|
|
|
// 4. 메일 제목 생성
|
|
String contractNo = CommonUtils.checkNull(contractInfo.get("contract_no"));
|
|
String customerName = CommonUtils.checkNull(contractInfo.get("customer_name"));
|
|
String subject = "[" + customerName + "] " + contractNo + " 견적서";
|
|
|
|
// mail_log 조회용 제목 (OBJID 포함)
|
|
String subjectForLog = subject + " [OBJID:" + objId + "]";
|
|
|
|
// 5. 메일 내용 생성 (간단한 텍스트 버전)
|
|
String contents = makeEstimateMailContents(contractInfo, estimateTemplate, estimateItems);
|
|
|
|
// 6. 수신자 정보 설정
|
|
ArrayList<String> toEmailList = new ArrayList<String>();
|
|
String customerEmail = CommonUtils.checkNull(contractInfo.get("customer_email"));
|
|
if(!"".equals(customerEmail)){
|
|
toEmailList.add(customerEmail);
|
|
} else {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "고객사 이메일 정보가 없습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
// 7. 참조: 작성자 이메일
|
|
ArrayList<String> ccEmailList = new ArrayList<String>();
|
|
String writerEmail = CommonUtils.checkNull(contractInfo.get("writer_email"));
|
|
if(!"".equals(writerEmail)){
|
|
ccEmailList.add(writerEmail);
|
|
}
|
|
|
|
// 7-1. PDF 파일 처리 (세션 ID로 업로드된 경우)
|
|
ArrayList<HashMap> attachFileList = new ArrayList<HashMap>();
|
|
String pdfSessionId = CommonUtils.checkNull(paramMap.get("pdfSessionId"));
|
|
|
|
if(!"".equals(pdfSessionId)) {
|
|
// 세션 ID로 저장된 PDF 파일 가져오기
|
|
File pdfFile = getPdfFromSession(pdfSessionId, estimateTemplate);
|
|
if(pdfFile != null && pdfFile.exists()) {
|
|
HashMap<String, String> fileMap = new HashMap<String, String>();
|
|
fileMap.put(Constants.Db.COL_FILE_REAL_NAME, pdfFile.getName());
|
|
fileMap.put(Constants.Db.COL_FILE_SAVED_NAME, pdfFile.getName());
|
|
fileMap.put(Constants.Db.COL_FILE_PATH, pdfFile.getParent());
|
|
attachFileList.add(fileMap);
|
|
|
|
System.out.println("PDF 파일 첨부 완료: " + pdfFile.getAbsolutePath());
|
|
} else {
|
|
System.out.println("PDF 파일을 찾을 수 없습니다: " + pdfSessionId);
|
|
}
|
|
}
|
|
|
|
// 8. 메일 발송
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String fromUserId = person.getUserId();
|
|
|
|
System.out.println("===== 메일 발송 시도 =====");
|
|
System.out.println("From UserId: " + fromUserId);
|
|
System.out.println("To Email: " + toEmailList);
|
|
System.out.println("CC Email: " + ccEmailList);
|
|
System.out.println("Subject (실제 메일): " + subject);
|
|
System.out.println("Subject (mail_log): " + subjectForLog);
|
|
System.out.println("첨부파일 개수: " + attachFileList.size());
|
|
System.out.println("========================");
|
|
|
|
boolean mailSent = false;
|
|
try {
|
|
// UTF-8 인코딩 메서드 사용 (견적서는 한글 내용이 많음)
|
|
mailSent = MailUtil.sendMailWithAttachFileUTF8(
|
|
fromUserId,
|
|
null, // fromEmail (자동으로 SMTP 설정 사용)
|
|
new ArrayList<String>(), // toUserIdList (빈 리스트)
|
|
toEmailList,
|
|
ccEmailList,
|
|
new ArrayList<String>(), // bccEmailList (빈 리스트)
|
|
null, // important
|
|
subject, // 실제 메일 제목 (OBJID 없음)
|
|
contents,
|
|
attachFileList.size() > 0 ? attachFileList : null, // PDF 첨부
|
|
"CONTRACT_ESTIMATE",
|
|
subjectForLog // mail_log용 제목 (OBJID 포함)
|
|
);
|
|
|
|
System.out.println("메일 발송 결과: " + mailSent);
|
|
|
|
} catch(Exception mailEx) {
|
|
System.out.println("메일 발송 중 예외 발생: " + mailEx.getMessage());
|
|
mailEx.printStackTrace();
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "메일 발송 중 예외가 발생했습니다: " + mailEx.getMessage());
|
|
return resultMap;
|
|
}
|
|
|
|
if(mailSent){
|
|
resultMap.put("result", "success");
|
|
resultMap.put("message", "견적서가 성공적으로 발송되었습니다.");
|
|
} else {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "메일 발송에 실패했습니다.");
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "메일 발송 중 오류가 발생했습니다: " + e.getMessage());
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 견적서 메일 내용 생성
|
|
* @param contractInfo
|
|
* @param estimateTemplate
|
|
* @param estimateItems
|
|
* @return
|
|
*/
|
|
private String makeEstimateMailContents(Map contractInfo, Map estimateTemplate, List<Map> estimateItems){
|
|
StringBuilder contents = new StringBuilder();
|
|
|
|
contents.append("<html>");
|
|
contents.append("<head>");
|
|
contents.append("<meta charset='UTF-8'>");
|
|
contents.append("<style>");
|
|
contents.append("body { font-family: 'Malgun Gothic', '맑은 고딕', Arial, sans-serif; margin: 0; padding: 20px; background-color: #f5f5f5; }");
|
|
contents.append(".estimate-container { width: 210mm; background: white; margin: 0 auto; padding: 20mm; box-shadow: 0 0 10px rgba(0,0,0,0.1); box-sizing: border-box; }");
|
|
contents.append(".title { text-align: center; font-size: 28pt; font-weight: bold; letter-spacing: 20px; margin-bottom: 40px; padding: 10px 0; }");
|
|
contents.append(".header-section { width: 100%; margin-bottom: 30px; overflow: hidden; }");
|
|
contents.append(".header-left { float: left; width: 48%; }");
|
|
contents.append(".header-right { float: right; width: 48%; text-align: right; }");
|
|
contents.append(".info-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }");
|
|
contents.append(".info-table td { padding: 5px 8px; border: 1px solid #000; font-size: 9pt; }");
|
|
contents.append(".info-table .label { background-color: #f0f0f0; font-weight: bold; width: 80px; text-align: center; }");
|
|
contents.append(".company-info { display: inline-block; text-align: right; }");
|
|
contents.append(".company-stamp { width: 120px; height: 120px; border: 2px solid #e74c3c; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; position: relative; }");
|
|
contents.append(".company-stamp-text { writing-mode: vertical-rl; font-size: 16pt; font-weight: bold; color: #e74c3c; letter-spacing: 3px; }");
|
|
contents.append(".company-details { font-size: 9pt; line-height: 1.6; margin-top: 10px; }");
|
|
contents.append(".greeting-section { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; padding: 0px 5px; }");
|
|
contents.append(".greeting-left { line-height: 1.6; font-size: 10pt; }");
|
|
contents.append(".greeting-right { text-align: right; font-size: 9pt; line-height: 1.8; }");
|
|
contents.append(".items-table { width: 100%; border-collapse: collapse; margin-bottom: 30px; }");
|
|
contents.append(".items-table th, .items-table td { border: 1px solid #000; padding: 3px 5px; text-align: center; font-size: 9pt; line-height: 1.3; }");
|
|
contents.append(".items-table th { background-color: #f0f0f0; font-weight: bold; }");
|
|
contents.append(".text-left { text-align: left; }");
|
|
contents.append(".text-right { text-align: right; }");
|
|
contents.append(".text-center { text-align: center; }");
|
|
contents.append("</style>");
|
|
contents.append("</head>");
|
|
contents.append("<body>");
|
|
contents.append("<div class='estimate-container'>");
|
|
|
|
// 제목
|
|
contents.append("<div class='title'>견 적 서</div>");
|
|
|
|
// estimateTemplate 키는 대문자/소문자 모두 체크
|
|
// 수신처는 contractInfo에서 고객사명 가져오기
|
|
String recipient = CommonUtils.checkNull(contractInfo.get("customer_name"));
|
|
if("".equals(recipient)) recipient = CommonUtils.checkNull(contractInfo.get("CUSTOMER_NAME"));
|
|
// 없으면 estimateTemplate에서 가져오기
|
|
if("".equals(recipient)) recipient = CommonUtils.checkNull(estimateTemplate.get("recipient"));
|
|
if("".equals(recipient)) recipient = CommonUtils.checkNull(estimateTemplate.get("RECIPIENT"));
|
|
|
|
String contactPerson = CommonUtils.checkNull(estimateTemplate.get("contact_person"));
|
|
if("".equals(contactPerson)) contactPerson = CommonUtils.checkNull(estimateTemplate.get("CONTACT_PERSON"));
|
|
|
|
String estimateNo = CommonUtils.checkNull(estimateTemplate.get("estimate_no"));
|
|
if("".equals(estimateNo)) estimateNo = CommonUtils.checkNull(estimateTemplate.get("ESTIMATE_NO"));
|
|
|
|
String executorDate = CommonUtils.checkNull(estimateTemplate.get("executor"));
|
|
if("".equals(executorDate)) executorDate = CommonUtils.checkNull(estimateTemplate.get("EXECUTOR"));
|
|
if("".equals(executorDate)) executorDate = CommonUtils.checkNull(estimateTemplate.get("executor_date"));
|
|
if("".equals(executorDate)) executorDate = CommonUtils.checkNull(estimateTemplate.get("EXECUTOR_DATE"));
|
|
|
|
// 담당자 정보
|
|
String managerName = CommonUtils.checkNull(estimateTemplate.get("manager_name"));
|
|
if("".equals(managerName)) managerName = CommonUtils.checkNull(estimateTemplate.get("MANAGER_NAME"));
|
|
if("".equals(managerName)) managerName = "영업부";
|
|
|
|
String managerContact = CommonUtils.checkNull(estimateTemplate.get("manager_contact"));
|
|
if("".equals(managerContact)) managerContact = CommonUtils.checkNull(estimateTemplate.get("MANAGER_CONTACT"));
|
|
|
|
// 헤더 섹션 (왼쪽: 기본정보, 오른쪽: 회사정보)
|
|
contents.append("<div class='header-section'>");
|
|
|
|
// 왼쪽: 기본 정보 테이블
|
|
contents.append("<div class='header-left'>");
|
|
contents.append("<table class='info-table'>");
|
|
contents.append("<tr><td class='label'>시행일자</td><td>" + executorDate + "</td></tr>");
|
|
contents.append("<tr><td class='label'>수신처</td><td>" + recipient + "</td></tr>");
|
|
contents.append("<tr><td class='label'>수신인</td><td>" + contactPerson + "</td></tr>");
|
|
contents.append("<tr><td class='label'>견적번호</td><td>" + estimateNo + "</td></tr>");
|
|
contents.append("</table>");
|
|
contents.append("</div>");
|
|
|
|
// 오른쪽: 회사 정보
|
|
contents.append("<div class='header-right'>");
|
|
contents.append("<div class='company-info'>");
|
|
|
|
// 회사 도장 이미지 경로
|
|
String projectRoot = System.getProperty("user.dir");
|
|
String companyStampPath = projectRoot + "/WebContent/images/company_stamp.png";
|
|
|
|
// Docker 환경인 경우 다른 경로 시도
|
|
File stampFile = new File(companyStampPath);
|
|
if(!stampFile.exists()) {
|
|
companyStampPath = "/usr/local/tomcat/webapps/ROOT/images/company_stamp.png";
|
|
stampFile = new File(companyStampPath);
|
|
if(!stampFile.exists()) {
|
|
companyStampPath = "";
|
|
}
|
|
}
|
|
|
|
String stampBase64 = !"".equals(companyStampPath) ? encodeImageToBase64(companyStampPath) : "";
|
|
|
|
if(!"".equals(stampBase64)) {
|
|
// 이미지가 있으면 Base64로 인코딩된 이미지 표시
|
|
contents.append("<img src='" + stampBase64 + "' alt='회사 도장' style='max-width: 150px; height: auto; margin: 0 auto 15px; display: block;'>");
|
|
} else {
|
|
// 이미지가 없으면 텍스트로 표시
|
|
contents.append("<div class='company-stamp'>");
|
|
contents.append("<div class='company-stamp-text'>(주)알피에스<br>대표이사<br>이 종 현</div>");
|
|
contents.append("</div>");
|
|
}
|
|
|
|
// 회사 주소 및 연락처
|
|
contents.append("<div class='company-details'>");
|
|
contents.append("대전광역시 유성구 국제과학10로 8<br>");
|
|
contents.append("TEL:(042)602-3300 FAX:(042)672-3399");
|
|
contents.append("</div>");
|
|
|
|
contents.append("</div>"); // company-info 닫기
|
|
contents.append("</div>"); // header-right 닫기
|
|
|
|
contents.append("</div>"); // header-section 닫기
|
|
|
|
// 인사말 및 담당자 정보
|
|
contents.append("<div class='greeting-section'>");
|
|
contents.append("<div class='greeting-left'>");
|
|
contents.append("견적을 요청해 주셔서 대단히 감사합니다.<br>");
|
|
contents.append("하기와 같이 견적서를 제출합니다.");
|
|
contents.append("</div>");
|
|
contents.append("<div class='greeting-right'>");
|
|
contents.append("담당자 : " + managerName + "<br>");
|
|
if(!"".equals(managerContact)) {
|
|
contents.append("연락처 : " + managerContact + "<br>");
|
|
}
|
|
contents.append("<span style='font-size: 10pt; margin-top: 5px; display: inline-block;'>부가세 별도</span>");
|
|
contents.append("</div>");
|
|
contents.append("</div>");
|
|
|
|
// 견적 품목
|
|
if(estimateItems != null && !estimateItems.isEmpty()){
|
|
contents.append("<table class='items-table'>");
|
|
contents.append("<thead>");
|
|
contents.append("<tr>");
|
|
contents.append("<th style='width:6%;'>번호<br>NO.</th>");
|
|
contents.append("<th style='width:20%;'>품 명<br>DESCRIPTION</th>");
|
|
contents.append("<th style='width:22%;'>규 격<br>SPECIFICATION</th>");
|
|
contents.append("<th style='width:7%;'>수량<br>Q'TY</th>");
|
|
contents.append("<th style='width:8%;'>단위<br>UNIT</th>");
|
|
contents.append("<th style='width:11%;'>단 가<br>UNIT<br>PRICE</th>");
|
|
contents.append("<th style='width:11%;'>금 액<br>AMOUNT</th>");
|
|
contents.append("<th style='width:15%;'>비고</th>");
|
|
contents.append("</tr>");
|
|
contents.append("</thead>");
|
|
contents.append("<tbody>");
|
|
|
|
long totalAmount = 0;
|
|
for(int i = 0; i < estimateItems.size(); i++){
|
|
Map item = estimateItems.get(i);
|
|
String amount = CommonUtils.checkNull(item.get("amount"));
|
|
if(!"".equals(amount)){
|
|
try {
|
|
totalAmount += Long.parseLong(amount.replace(",", ""));
|
|
} catch(Exception e){}
|
|
}
|
|
|
|
contents.append("<tr>");
|
|
contents.append("<td class='text-center'>" + (i + 1) + "</td>");
|
|
contents.append("<td class='text-left'>" + CommonUtils.checkNull(item.get("description")) + "</td>");
|
|
contents.append("<td class='text-left'>" + CommonUtils.checkNull(item.get("specification")) + "</td>");
|
|
contents.append("<td class='text-center'>" + CommonUtils.checkNull(item.get("quantity")) + "</td>");
|
|
contents.append("<td class='text-center'>" + CommonUtils.checkNull(item.get("unit")) + "</td>");
|
|
contents.append("<td class='text-right'>" + CommonUtils.checkNull(item.get("unit_price")) + "</td>");
|
|
contents.append("<td class='text-right'>" + CommonUtils.checkNull(item.get("amount")) + "</td>");
|
|
contents.append("<td class='text-left'>" + CommonUtils.checkNull(item.get("note")) + "</td>");
|
|
contents.append("</tr>");
|
|
}
|
|
|
|
// 계 (총 합계) - 통화 기호 포함
|
|
String totalAmountStr = CommonUtils.checkNull(estimateTemplate.get("total_amount"));
|
|
if("".equals(totalAmountStr)) totalAmountStr = CommonUtils.checkNull(estimateTemplate.get("TOTAL_AMOUNT"));
|
|
|
|
// DB에 저장된 합계가 없으면 계산한 값 사용
|
|
if("".equals(totalAmountStr)){
|
|
totalAmountStr = String.format("%,d", totalAmount);
|
|
}
|
|
|
|
// 통화 기호 가져오기
|
|
String currencyName = CommonUtils.checkNull(estimateTemplate.get("contract_currency_name"));
|
|
if("".equals(currencyName)) currencyName = CommonUtils.checkNull(estimateTemplate.get("CONTRACT_CURRENCY_NAME"));
|
|
|
|
String currencySymbol = "₩"; // 기본값
|
|
if(currencyName.indexOf("달러") >= 0 || "USD".equals(currencyName)) {
|
|
currencySymbol = "$";
|
|
} else if(currencyName.indexOf("유로") >= 0 || "EUR".equals(currencyName)) {
|
|
currencySymbol = "€";
|
|
} else if(currencyName.indexOf("엔") >= 0 || "JPY".equals(currencyName)) {
|
|
currencySymbol = "¥";
|
|
} else if(currencyName.indexOf("위안") >= 0 || "CNY".equals(currencyName)) {
|
|
currencySymbol = "¥";
|
|
}
|
|
|
|
contents.append("<tr style='background-color:#f0f0f0; font-weight:bold;'>");
|
|
contents.append("<td colspan='6' class='text-center'>계</td>");
|
|
contents.append("<td class='text-right'>" + currencySymbol + totalAmountStr + "</td>");
|
|
contents.append("<td></td>");
|
|
contents.append("</tr>");
|
|
|
|
// 원화환산 공급가액 - 제거 (화면에서도 숨김 처리)
|
|
|
|
// 테이블 내 비고 (항상 표시)
|
|
String noteRemarks = CommonUtils.checkNull(estimateTemplate.get("note_remarks"));
|
|
if("".equals(noteRemarks)) noteRemarks = CommonUtils.checkNull(estimateTemplate.get("NOTE_REMARKS"));
|
|
|
|
System.out.println("===== 비고 내용 확인 =====");
|
|
System.out.println("noteRemarks: [" + noteRemarks + "]");
|
|
System.out.println("========================");
|
|
|
|
contents.append("<tr>");
|
|
contents.append("<td colspan='8' style='height:100px; vertical-align:top; padding:10px; text-align:left;'>");
|
|
contents.append("<div style='font-weight:bold; margin-bottom:10px;'><비고></div>");
|
|
contents.append("<div style='white-space:pre-wrap;'>" + noteRemarks + "</div>");
|
|
contents.append("</td>");
|
|
contents.append("</tr>");
|
|
|
|
// 참조사항 (NOTE1~4)
|
|
String note1 = CommonUtils.checkNull(estimateTemplate.get("note1"));
|
|
if("".equals(note1)) note1 = CommonUtils.checkNull(estimateTemplate.get("NOTE1"));
|
|
if("".equals(note1)) note1 = "1. 견적유효기간: 일";
|
|
|
|
String note2 = CommonUtils.checkNull(estimateTemplate.get("note2"));
|
|
if("".equals(note2)) note2 = CommonUtils.checkNull(estimateTemplate.get("NOTE2"));
|
|
if("".equals(note2)) note2 = "2. 납품기간: 발주 후 1주 이내";
|
|
|
|
String note3 = CommonUtils.checkNull(estimateTemplate.get("note3"));
|
|
if("".equals(note3)) note3 = CommonUtils.checkNull(estimateTemplate.get("NOTE3"));
|
|
if("".equals(note3)) note3 = "3. VAT 별도";
|
|
|
|
String note4 = CommonUtils.checkNull(estimateTemplate.get("note4"));
|
|
if("".equals(note4)) note4 = CommonUtils.checkNull(estimateTemplate.get("NOTE4"));
|
|
if("".equals(note4)) note4 = "4. 결제 조건 : 기존 결제조건에 따름.";
|
|
|
|
// 참조사항 행 추가
|
|
contents.append("<tr>");
|
|
contents.append("<td colspan='8' style='vertical-align: top; padding: 10px; text-align: left;'>");
|
|
contents.append("<div style='font-weight: bold; margin-bottom: 10px;'><참조사항></div>");
|
|
contents.append("<div style='margin-bottom: 5px;'>" + note1 + "</div>");
|
|
contents.append("<div style='margin-bottom: 5px;'>" + note2 + "</div>");
|
|
contents.append("<div style='margin-bottom: 5px;'>" + note3 + "</div>");
|
|
contents.append("<div style='margin-bottom: 5px;'>" + note4 + "</div>");
|
|
contents.append("</td>");
|
|
contents.append("</tr>");
|
|
|
|
// 하단 회사명 행 추가
|
|
contents.append("<tr>");
|
|
contents.append("<td colspan='8' style='text-align: right; padding: 15px; font-size: 10pt; font-weight: bold; border: none;'>");
|
|
contents.append("㈜알피에스");
|
|
contents.append("</td>");
|
|
contents.append("</tr>");
|
|
|
|
contents.append("</tbody>");
|
|
contents.append("</table>");
|
|
}
|
|
|
|
contents.append("</div>"); // estimate-container 닫기
|
|
contents.append("</body>");
|
|
contents.append("</html>");
|
|
|
|
return contents.toString();
|
|
}
|
|
|
|
/**
|
|
* 이미지 파일을 Base64로 인코딩
|
|
* @param imagePath 이미지 파일 경로
|
|
* @return Base64 인코딩된 문자열 (data:image/png;base64,...)
|
|
*/
|
|
private String encodeImageToBase64(String imagePath) {
|
|
try {
|
|
File imageFile = new File(imagePath);
|
|
if(!imageFile.exists()) {
|
|
return "";
|
|
}
|
|
|
|
java.io.FileInputStream fis = new java.io.FileInputStream(imageFile);
|
|
byte[] imageBytes = new byte[(int) imageFile.length()];
|
|
fis.read(imageBytes);
|
|
fis.close();
|
|
|
|
// Apache Commons Codec 사용 (Java 7 호환)
|
|
String base64 = org.apache.commons.codec.binary.Base64.encodeBase64String(imageBytes);
|
|
|
|
// 파일 확장자로 MIME 타입 결정
|
|
String mimeType = "image/png";
|
|
if(imagePath.toLowerCase().endsWith(".jpg") || imagePath.toLowerCase().endsWith(".jpeg")) {
|
|
mimeType = "image/jpeg";
|
|
} else if(imagePath.toLowerCase().endsWith(".gif")) {
|
|
mimeType = "image/gif";
|
|
}
|
|
|
|
return "data:" + mimeType + ";base64," + base64;
|
|
} catch(Exception e) {
|
|
System.out.println("이미지 Base64 인코딩 실패: " + e.getMessage());
|
|
e.printStackTrace();
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 영업정보 조회 (수주등록용)
|
|
* @param contractObjId
|
|
* @return
|
|
*/
|
|
public Map<String, Object> getContractInfo(String contractObjId) {
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
paramMap.put("objId", contractObjId);
|
|
|
|
resultMap = (Map<String, Object>) sqlSession.selectOne("contractMgmt.getContractInfo", paramMap);
|
|
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(sqlSession != null) {
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
return resultMap != null ? resultMap : new HashMap<String, Object>();
|
|
}
|
|
|
|
/**
|
|
* 고객사 정보 조회
|
|
*/
|
|
public Map<String, Object> getCustomerInfo(String customerObjId) {
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
paramMap.put("objId", customerObjId);
|
|
|
|
resultMap = (Map<String, Object>) sqlSession.selectOne("common.getSupplyInfo", paramMap);
|
|
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(sqlSession != null) {
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
return resultMap != null ? resultMap : new HashMap<String, Object>();
|
|
}
|
|
|
|
/**
|
|
* 수주정보 조회 (영업정보와 동일)
|
|
* @param objId
|
|
* @return
|
|
*/
|
|
public Map<String, Object> getOrderInfo(String objId) {
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
paramMap.put("objId", objId);
|
|
|
|
// TB_CONTRACT_MGMT 테이블에서 조회
|
|
resultMap = (Map<String, Object>) sqlSession.selectOne("contractMgmt.getOrderInfo", paramMap);
|
|
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(sqlSession != null) {
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
return resultMap != null ? resultMap : new HashMap<String, Object>();
|
|
}
|
|
|
|
/**
|
|
* 계약 품목 조회
|
|
* @param paramMap - contractObjId
|
|
* @return
|
|
*/
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public List<Map> getContractItems(Map paramMap){
|
|
SqlSession sqlSession = null;
|
|
List<Map> items = new ArrayList<Map>();
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
items = sqlSession.selectList("contractMgmt.getContractItems", paramMap);
|
|
|
|
System.out.println("=== getContractItems 디버깅 시작 ===");
|
|
System.out.println("조회된 품목 수: " + (items != null ? items.size() : 0));
|
|
|
|
// ORDER_* 정보가 없으면 견적서에서 가져오기
|
|
if(items != null && !items.isEmpty()) {
|
|
for(Map item : items) {
|
|
// ORDER_QUANTITY가 없거나 0이면 견적서에서 가져오기
|
|
Object orderQty = item.get("order_quantity");
|
|
System.out.println("품목 PART_NO: " + item.get("part_no") + ", ORDER_QUANTITY: " + orderQty);
|
|
|
|
if(orderQty == null || "".equals(orderQty.toString().trim()) || "0".equals(orderQty.toString().trim())) {
|
|
System.out.println("ORDER_QUANTITY가 비어있음 - 견적서에서 조회 시작");
|
|
|
|
// 최종 견적서 조회
|
|
Map estimateParam = new HashMap();
|
|
estimateParam.put("objId", paramMap.get("contractObjId"));
|
|
Map latestEstimate = sqlSession.selectOne("contractMgmt.getLatestEstimateTemplate", estimateParam);
|
|
|
|
System.out.println("최종 견적서 조회 결과: " + (latestEstimate != null ? "있음" : "없음"));
|
|
|
|
if(latestEstimate != null) {
|
|
// 일반 견적서와 장비 견적서 모두 ESTIMATE_TEMPLATE_ITEM에서 조회
|
|
Map itemParam = new HashMap();
|
|
itemParam.put("templateObjId", latestEstimate.get("OBJID"));
|
|
itemParam.put("partObjId", item.get("part_objid"));
|
|
|
|
System.out.println("견적서 품목 조회 - templateObjId: " + latestEstimate.get("OBJID") + ", partObjId: " + item.get("part_objid"));
|
|
|
|
Map estimateItem = sqlSession.selectOne("contractMgmt.getEstimateTemplateItemByPartObjId", itemParam);
|
|
|
|
System.out.println("견적서 품목 조회 결과: " + (estimateItem != null ? "있음" : "없음"));
|
|
|
|
if(estimateItem != null) {
|
|
System.out.println("견적서 품목 - quantity: " + estimateItem.get("quantity") + ", unit_price: " + estimateItem.get("unit_price"));
|
|
|
|
// 견적서의 수량, 단가 정보를 ORDER_* 필드에 매핑
|
|
item.put("order_quantity", estimateItem.get("quantity"));
|
|
item.put("order_unit_price", estimateItem.get("unit_price"));
|
|
|
|
// 공급가액 계산
|
|
Object quantity = estimateItem.get("quantity");
|
|
Object unitPrice = estimateItem.get("unit_price");
|
|
long supplyPrice = 0;
|
|
|
|
if(quantity != null && unitPrice != null) {
|
|
try {
|
|
long qty = Long.parseLong(quantity.toString().replaceAll("[^0-9]", ""));
|
|
long price = Long.parseLong(unitPrice.toString().replaceAll("[^0-9]", ""));
|
|
supplyPrice = qty * price;
|
|
} catch(Exception e) {
|
|
System.out.println("금액 계산 실패: " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
item.put("order_supply_price", supplyPrice);
|
|
item.put("order_vat", Math.round(supplyPrice * 0.1));
|
|
item.put("order_total_amount", supplyPrice + Math.round(supplyPrice * 0.1));
|
|
|
|
System.out.println("계산 완료 - 공급가액: " + supplyPrice + ", 부가세: " + Math.round(supplyPrice * 0.1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 대문자 변환
|
|
items = CommonUtils.keyChangeUpperList(items);
|
|
|
|
System.out.println("=== getContractItems 디버깅 종료 ===");
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return items;
|
|
}
|
|
|
|
/**
|
|
* 견적서 템플릿 품목 조회 (수주등록용)
|
|
* 최종 견적서의 품목 정보를 수주등록 형식으로 변환하여 반환
|
|
*
|
|
* 참고: 이 메서드는 사용되지 않음. getContractItems()를 사용하세요.
|
|
* 일반 견적서와 장비 견적서 모두 ESTIMATE_TEMPLATE_ITEM에 저장되므로
|
|
* 동일한 방식으로 처리 가능
|
|
*
|
|
* @param paramMap - contractObjId
|
|
* @return
|
|
*/
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public List<Map> getEstimateTemplateItemsForOrder(Map paramMap){
|
|
SqlSession sqlSession = null;
|
|
List<Map> items = new ArrayList<Map>();
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
// 1. 최종 견적서 템플릿 조회
|
|
Map templateParam = new HashMap();
|
|
templateParam.put("objId", paramMap.get("contractObjId"));
|
|
Map template = sqlSession.selectOne("contractMgmt.getLatestEstimateTemplate", templateParam);
|
|
|
|
if(template != null) {
|
|
template = CommonUtils.toUpperCaseMapKey(template);
|
|
|
|
// 일반 견적서와 장비 견적서 모두 ESTIMATE_TEMPLATE_ITEM에서 조회
|
|
Map itemParam = new HashMap();
|
|
itemParam.put("templateObjId", template.get("OBJID"));
|
|
List<Map> templateItems = sqlSession.selectList("contractMgmt.getEstimateTemplateItemsByTemplateObjId", itemParam);
|
|
|
|
// 수주등록 형식으로 변환
|
|
for(Map templateItem : templateItems) {
|
|
Map orderItem = new HashMap();
|
|
|
|
// ESTIMATE_TEMPLATE_ITEM -> CONTRACT_ITEM 형식으로 매핑
|
|
orderItem.put("OBJID", templateItem.get("objid")); // 템플릿 품목 OBJID (참고용)
|
|
orderItem.put("CONTRACT_OBJID", paramMap.get("contractObjId"));
|
|
orderItem.put("PART_OBJID", templateItem.get("part_objid"));
|
|
orderItem.put("PART_NO", templateItem.get("description")); // 품명
|
|
orderItem.put("PART_NAME", templateItem.get("description")); // 품명
|
|
orderItem.put("SERIAL_NO", ""); // S/N은 비워둠
|
|
orderItem.put("QUANTITY", templateItem.get("quantity")); // 수량
|
|
orderItem.put("DUE_DATE", "");
|
|
orderItem.put("CUSTOMER_REQUEST", "");
|
|
orderItem.put("RETURN_REASON", "");
|
|
|
|
// 수주 정보는 견적서 값으로 초기화
|
|
orderItem.put("ORDER_QUANTITY", templateItem.get("quantity"));
|
|
orderItem.put("ORDER_UNIT_PRICE", templateItem.get("unit_price"));
|
|
|
|
// 공급가액 계산 (수량 * 단가)
|
|
Object quantity = templateItem.get("quantity");
|
|
Object unitPrice = templateItem.get("unit_price");
|
|
long supplyPrice = 0;
|
|
|
|
if(quantity != null && unitPrice != null) {
|
|
try {
|
|
long qty = Long.parseLong(quantity.toString().replaceAll("[^0-9]", ""));
|
|
long price = Long.parseLong(unitPrice.toString().replaceAll("[^0-9]", ""));
|
|
supplyPrice = qty * price;
|
|
} catch(Exception e) {
|
|
// 계산 실패 시 0
|
|
}
|
|
}
|
|
|
|
orderItem.put("ORDER_SUPPLY_PRICE", supplyPrice);
|
|
orderItem.put("ORDER_VAT", Math.round(supplyPrice * 0.1)); // 부가세 10%
|
|
orderItem.put("ORDER_TOTAL_AMOUNT", supplyPrice + Math.round(supplyPrice * 0.1));
|
|
|
|
items.add(orderItem);
|
|
}
|
|
|
|
// 대문자 변환
|
|
items = CommonUtils.keyChangeUpperList(items);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return items;
|
|
}
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
public Map saveOrderInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
Map resultList = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("writer", person.getUserId());
|
|
|
|
String contract_objid= CommonUtils.checkNull(paramMap.get("contractObjId"));
|
|
paramMap.put("objId", contract_objid);
|
|
|
|
// 품목별 수주 정보 업데이트 및 합계 계산
|
|
String itemsJson = CommonUtils.checkNull(paramMap.get("items_json"));
|
|
long totalSupplyPrice = 0;
|
|
long totalVat = 0;
|
|
long totalAmount = 0;
|
|
|
|
if(!"".equals(itemsJson)){
|
|
try {
|
|
// JSON 파싱
|
|
JSONParser parser = new JSONParser();
|
|
JSONArray jsonArray = (JSONArray) parser.parse(itemsJson);
|
|
|
|
// 각 품목별로 업데이트 및 합계 계산
|
|
for(int i = 0; i < jsonArray.size(); i++) {
|
|
JSONObject item = (JSONObject) jsonArray.get(i);
|
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
|
|
|
String orderSupplyPrice = item.get("orderSupplyPrice") != null ? item.get("orderSupplyPrice").toString().replace(",", "") : "0";
|
|
String orderVat = item.get("orderVat") != null ? item.get("orderVat").toString().replace(",", "") : "0";
|
|
String orderTotalAmount = item.get("orderTotalAmount") != null ? item.get("orderTotalAmount").toString().replace(",", "") : "0";
|
|
|
|
itemMap.put("contractItemObjId", item.get("contractItemObjId") != null ? item.get("contractItemObjId").toString() : "");
|
|
itemMap.put("orderQuantity", item.get("orderQuantity") != null ? item.get("orderQuantity").toString() : "");
|
|
itemMap.put("orderUnitPrice", item.get("orderUnitPrice") != null ? item.get("orderUnitPrice").toString() : "");
|
|
itemMap.put("orderSupplyPrice", orderSupplyPrice);
|
|
itemMap.put("orderVat", orderVat);
|
|
itemMap.put("orderTotalAmount", orderTotalAmount);
|
|
|
|
sqlSession.update("contractMgmt.updateContractItemOrderInfo", itemMap);
|
|
|
|
// 합계 계산
|
|
try {
|
|
totalSupplyPrice += Long.parseLong(orderSupplyPrice);
|
|
totalVat += Long.parseLong(orderVat);
|
|
totalAmount += Long.parseLong(orderTotalAmount);
|
|
} catch (NumberFormatException e) {
|
|
// 숫자 변환 실패 시 무시
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
throw new Exception("품목 정보 저장 중 오류가 발생했습니다.");
|
|
}
|
|
}
|
|
|
|
// 합계를 paramMap에 추가
|
|
paramMap.put("order_supply_price", String.valueOf(totalSupplyPrice));
|
|
paramMap.put("order_vat", String.valueOf(totalVat));
|
|
paramMap.put("order_total_amount", String.valueOf(totalAmount));
|
|
|
|
// 기본 수주 정보 및 합계 업데이트
|
|
int cnt = sqlSession.update("contractMgmt.updateOrderInfo", paramMap);
|
|
|
|
//영업 수주 완료시 자동 프로젝트 등록 로직
|
|
String result_cd= CommonUtils.checkNull(paramMap.get("contract_result"));
|
|
|
|
String category_cd= CommonUtils.checkNull(paramMap.get("category_cd"));
|
|
String target_project_no= CommonUtils.checkNull(paramMap.get("target_project_no_direct"));
|
|
//int overhaul_order = Integer.parseInt(CommonUtils.checkNull(paramMap.get("overhaul_order"),"1"));
|
|
//int project_cnt= Integer.parseInt(CommonUtils.checkNull(paramMap.get("facility_qty"), "1"));
|
|
//long contract_price_currency= Long.parseLong(CommonUtils.checkNull(paramMap.get("contract_price_currency"), "0"));
|
|
//long contract_price= Long.parseLong(CommonUtils.checkNull(paramMap.get("contract_price"), "0"));
|
|
|
|
//수주가와 금액은 대수로 나누어서 등록
|
|
//paramMap.put("contract_price_currency", contract_price_currency/project_cnt + "");
|
|
//paramMap.put("contract_price", contract_price/project_cnt + "");
|
|
|
|
if("0000964".equals(result_cd) || "0000968".equals(result_cd)){
|
|
// 품목별로 프로젝트 생성
|
|
List<Map> contractItems = getContractItems(paramMap);
|
|
|
|
if(contractItems != null && !contractItems.isEmpty()) {
|
|
System.out.println("품목 개수: " + contractItems.size() + "개 - 품목별 프로젝트 생성 시작");
|
|
|
|
for(Map item : contractItems) {
|
|
// 품목별 프로젝트 존재 여부 확인
|
|
Map<String, Object> projectCheckParam = new HashMap<String, Object>();
|
|
projectCheckParam.put("contractObjId", contract_objid);
|
|
projectCheckParam.put("part_objid", item.get("PART_OBJID"));
|
|
|
|
resultList = sqlSession.selectOne("contractMgmt.getProjectListByContractAndPartObjid", projectCheckParam);
|
|
|
|
if(null == resultList) {
|
|
// 새 프로젝트 생성
|
|
Map<String, Object> projectParam = new HashMap<String, Object>();
|
|
projectParam.putAll(paramMap); // 기본 정보 복사
|
|
|
|
// 품목별 정보 설정
|
|
projectParam.put("OBJID", CommonUtils.createObjId());
|
|
projectParam.put("is_temp", '1');
|
|
projectParam.put("part_objid", item.get("PART_OBJID"));
|
|
projectParam.put("part_no", item.get("PART_NO"));
|
|
projectParam.put("part_name", item.get("PART_NAME"));
|
|
projectParam.put("quantity", item.get("ORDER_QUANTITY") != null ? item.get("ORDER_QUANTITY") : item.get("QUANTITY"));
|
|
projectParam.put("due_date", item.get("DUE_DATE"));
|
|
|
|
if("0000170".equals(category_cd) || "0000171".equals(category_cd)){
|
|
projectParam.put("overhaul_project_no", target_project_no);
|
|
}
|
|
|
|
System.out.println("프로젝트 생성 - PART_OBJID: " + item.get("PART_OBJID") + ", 품번: " + item.get("PART_NO") + ", 품명: " + item.get("PART_NAME"));
|
|
|
|
// 프로젝트 등록
|
|
cnt = sqlSession.update("project.createProject", projectParam);
|
|
// 프로젝트 TASK 등록
|
|
cnt = sqlSession.insert("contractMgmt.insertProjectTask", projectParam);
|
|
// 프로젝트 SETUP_TASK 등록
|
|
cnt = sqlSession.insert("contractMgmt.insertProjectSetupTask", projectParam);
|
|
|
|
// project_no - unit 폴더 생성
|
|
Map<String,Object> projectInfo = (Map)sqlSession.selectOne("project.getProjectMngInfo", projectParam);
|
|
|
|
projectParam.put("contract_objid", contract_objid);
|
|
projectParam.put("customer_product", projectParam.get("mechanical_type"));
|
|
List<Map<String,Object>> taskUnitList = (ArrayList)sqlSession.selectList("project.getWbsTaskListByProject", projectParam);
|
|
if(CommonUtils.isNotEmpty(taskUnitList) && !taskUnitList.isEmpty()){
|
|
String projectNo = (String)projectInfo.get("project_no");
|
|
String filepath = Constants.FILE_STORAGE+"\\PART_DATA\\";
|
|
for (Map<String, Object> map : taskUnitList) {
|
|
File file = new File(filepath+File.separator+projectNo+File.separator+CommonUtils.checkNull((String)map.get("unit_no"))+"-"+CommonUtils.checkNull((String)map.get("task_name")));
|
|
if(!file.exists()){
|
|
file.mkdirs();
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
// 기존 프로젝트 업데이트
|
|
Map<String, Object> updateParam = new HashMap<String, Object>();
|
|
updateParam.putAll(paramMap);
|
|
updateParam.put("part_objid", item.get("PART_OBJID"));
|
|
updateParam.put("part_no", item.get("PART_NO"));
|
|
updateParam.put("part_name", item.get("PART_NAME"));
|
|
updateParam.put("quantity", item.get("ORDER_QUANTITY") != null ? item.get("ORDER_QUANTITY") : item.get("QUANTITY"));
|
|
updateParam.put("due_date", item.get("DUE_DATE"));
|
|
|
|
System.out.println("프로젝트 업데이트 - PART_OBJID: " + item.get("PART_OBJID") + ", 품번: " + item.get("PART_NO"));
|
|
sqlSession.update("project.ModifyProjectByContract", updateParam);
|
|
}
|
|
}
|
|
} else {
|
|
System.out.println("품목이 없습니다 - 기존 방식으로 프로젝트 생성");
|
|
// 품목이 없는 경우 기존 방식대로 처리
|
|
resultList = sqlSession.selectOne("contractMgmt.getProjectListBycontractObjid", paramMap);
|
|
if(null==resultList){
|
|
paramMap.put("OBJID", CommonUtils.createObjId());
|
|
paramMap.put("is_temp", '1');
|
|
if("0000170".equals(category_cd) || "0000171".equals(category_cd)){
|
|
paramMap.put("overhaul_project_no", target_project_no);
|
|
}
|
|
cnt = sqlSession.update("project.createProject", paramMap);
|
|
cnt = sqlSession.insert("contractMgmt.insertProjectTask", paramMap);
|
|
cnt = sqlSession.insert("contractMgmt.insertProjectSetupTask", paramMap);
|
|
}else{
|
|
sqlSession.update("project.ModifyProjectByContract", paramMap);
|
|
}
|
|
}
|
|
}
|
|
// if(cnt > 0){
|
|
//계약완료 일시 메일
|
|
// if("0000964".equals(CommonUtils.checkNull(paramMap.get("contract_result")))){
|
|
// commonService.SendMail(paramMap,"CONTRACT_COMP",CommonUtils.checkNull(paramMap.get("pm_user_id")));
|
|
//그냥 등록일때 메일
|
|
// }else{
|
|
// if("regist".equals(CommonUtils.checkNull(paramMap.get("actionType")))){
|
|
// commonService.SendMail(paramMap,"CONTRACT_REG",CommonUtils.checkNull(paramMap.get("")));
|
|
// }
|
|
// }
|
|
// }
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* 품목 저장 (여러 건) - UPSERT 방식
|
|
* @param contractObjId 견적 OBJID
|
|
* @param itemList 품목 목록
|
|
* @param userId 사용자 ID
|
|
* @return 성공 여부
|
|
*/
|
|
public Map<String, Object> saveContractItems(String contractObjId, List<Map<String, Object>> itemList, String userId) {
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
|
|
try {
|
|
System.out.println("=== saveContractItems 시작 (UPSERT 방식) ===");
|
|
System.out.println("contractObjId: " + contractObjId);
|
|
System.out.println("itemList size: " + (itemList != null ? itemList.size() : 0));
|
|
System.out.println("userId: " + userId);
|
|
|
|
// 프론트에서 전달된 품목 OBJID 목록 수집
|
|
Set<String> currentItemObjIds = new HashSet<String>();
|
|
|
|
// 품목 UPSERT
|
|
if (itemList != null && !itemList.isEmpty()) {
|
|
for (int i = 0; i < itemList.size(); i++) {
|
|
Map<String, Object> item = itemList.get(i);
|
|
|
|
System.out.println("품목 " + (i+1) + " 처리 중: " + item);
|
|
|
|
// 기존 품목 OBJID가 있으면 사용, 없으면 새로 생성
|
|
String itemObjId = CommonUtils.checkNull(item.get("objId"));
|
|
if (itemObjId.isEmpty()) {
|
|
itemObjId = CommonUtils.createObjId();
|
|
System.out.println("새 품목 OBJID 생성: " + itemObjId);
|
|
} else {
|
|
System.out.println("기존 품목 OBJID 사용: " + itemObjId);
|
|
}
|
|
currentItemObjIds.add(itemObjId);
|
|
|
|
// 품목 저장
|
|
Map<String, Object> itemParam = new HashMap<String, Object>();
|
|
itemParam.put("objId", itemObjId);
|
|
itemParam.put("contractObjId", contractObjId);
|
|
itemParam.put("seq", i + 1);
|
|
itemParam.put("partObjId", item.get("partObjId"));
|
|
itemParam.put("partNo", item.get("partNo"));
|
|
itemParam.put("partName", item.get("partName"));
|
|
|
|
// quantity를 Integer로 변환
|
|
Object quantityObj = item.get("quantity");
|
|
Integer quantity = null;
|
|
if(quantityObj != null) {
|
|
if(quantityObj instanceof Integer) {
|
|
quantity = (Integer) quantityObj;
|
|
} else if(quantityObj instanceof Double) {
|
|
quantity = ((Double) quantityObj).intValue();
|
|
} else {
|
|
// String인 경우 콤마 제거 후 변환
|
|
String quantityStr = quantityObj.toString().replace(",", "").trim();
|
|
if(!quantityStr.isEmpty()) {
|
|
quantity = Integer.parseInt(quantityStr);
|
|
}
|
|
}
|
|
}
|
|
itemParam.put("quantity", quantity);
|
|
|
|
itemParam.put("dueDate", item.get("dueDate"));
|
|
itemParam.put("customerRequest", item.get("customerRequest"));
|
|
itemParam.put("returnReason", item.get("returnReason"));
|
|
itemParam.put("writer", userId);
|
|
|
|
System.out.println("품목 UPSERT 시도 - OBJID: " + itemObjId);
|
|
int result = sqlSession.insert("contractMgmt.upsertContractItem", itemParam);
|
|
System.out.println("품목 UPSERT 결과: " + result);
|
|
|
|
// 기존 S/N 전체 비활성화 (새로 저장할 것이므로)
|
|
Map<String, Object> deleteSnParam = new HashMap<String, Object>();
|
|
deleteSnParam.put("itemObjId", itemObjId);
|
|
sqlSession.update("contractMgmt.deleteItemSerials", deleteSnParam);
|
|
|
|
// S/N 저장
|
|
@SuppressWarnings("unchecked")
|
|
List<Map<String, Object>> snList = (List<Map<String, Object>>) item.get("snList");
|
|
if (snList != null && !snList.isEmpty()) {
|
|
for (int j = 0; j < snList.size(); j++) {
|
|
Map<String, Object> sn = snList.get(j);
|
|
String serialNo = (String) sn.get("value");
|
|
|
|
// S/N 값이 비어있으면 건너뛰기
|
|
if (serialNo == null || serialNo.trim().isEmpty()) {
|
|
System.out.println("S/N 값이 비어있어서 건너뜀");
|
|
continue;
|
|
}
|
|
|
|
// S/N OBJID는 항상 새로 생성 (기존 것을 비활성화했으므로)
|
|
String snObjId = CommonUtils.createObjId();
|
|
|
|
Map<String, Object> snParam = new HashMap<String, Object>();
|
|
snParam.put("objId", snObjId);
|
|
snParam.put("itemObjId", itemObjId);
|
|
snParam.put("seq", j + 1);
|
|
snParam.put("serialNo", serialNo);
|
|
snParam.put("writer", userId);
|
|
|
|
sqlSession.insert("contractMgmt.upsertContractItemSerial", snParam);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 프론트에서 전달되지 않은 기존 품목들은 INACTIVE 처리
|
|
if (!currentItemObjIds.isEmpty()) {
|
|
Map<String, Object> inactiveParam = new HashMap<String, Object>();
|
|
inactiveParam.put("contractObjId", contractObjId);
|
|
inactiveParam.put("currentItemObjIds", new ArrayList<String>(currentItemObjIds));
|
|
inactiveParam.put("userId", userId);
|
|
sqlSession.update("contractMgmt.inactivateRemovedItems", inactiveParam);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", "품목이 저장되었습니다.");
|
|
|
|
} catch (Exception e) {
|
|
sqlSession.rollback();
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", "품목 저장 중 오류가 발생했습니다.");
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 품번 목록 조회 (is_last = 1)
|
|
* @return 품번 목록
|
|
*/
|
|
public List<Map<String, Object>> getPartList() {
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
List<Map<String, Object>> partList = new ArrayList<Map<String, Object>>();
|
|
|
|
try {
|
|
partList = sqlSession.selectList("contractMgmt.getPartList");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return partList;
|
|
}
|
|
|
|
/**
|
|
* 품번 검색 (검색어 기반)
|
|
*/
|
|
public List<Map<String, Object>> searchPartList(Map<String, Object> paramMap) {
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
List<Map<String, Object>> partList = new ArrayList<Map<String, Object>>();
|
|
|
|
try {
|
|
partList = sqlSession.selectList("contractMgmt.searchPartList", paramMap);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return partList;
|
|
}
|
|
|
|
|
|
/**
|
|
* 품목 목록 조회
|
|
* @param contractObjId 견적 OBJID
|
|
* @return 품목 목록
|
|
*/
|
|
public List<Map<String, Object>> getContractItemList(String contractObjId) {
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
List<Map<String, Object>> itemList = new ArrayList<Map<String, Object>>();
|
|
|
|
try {
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
param.put("contractObjId", contractObjId);
|
|
|
|
itemList = sqlSession.selectList("contractMgmt.getContractItemList", param);
|
|
|
|
// 각 품목의 S/N 목록 조회
|
|
for (Map<String, Object> item : itemList) {
|
|
String itemObjId = (String) item.get("OBJID");
|
|
if(itemObjId == null) {
|
|
itemObjId = (String) item.get("objid");
|
|
}
|
|
|
|
System.out.println("품목 OBJID: " + itemObjId);
|
|
|
|
Map<String, Object> snParam = new HashMap<String, Object>();
|
|
snParam.put("itemObjId", itemObjId);
|
|
|
|
List<Map<String, Object>> snList = sqlSession.selectList("contractMgmt.getContractItemSerialList", snParam);
|
|
System.out.println("조회된 S/N 개수: " + (snList != null ? snList.size() : 0));
|
|
|
|
item.put("SN_LIST", snList);
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
|
|
return itemList;
|
|
}
|
|
|
|
/**
|
|
* PDF 청크 업로드 처리
|
|
* @param request
|
|
* @param paramMap - sessionId, chunkIndex, totalChunks, chunk
|
|
* @return
|
|
*/
|
|
public Map uploadPdfChunk(HttpServletRequest request, Map<String, Object> paramMap) {
|
|
Map resultMap = new HashMap();
|
|
|
|
try {
|
|
System.out.println("===== uploadPdfChunk 호출 =====");
|
|
System.out.println("전달된 파라미터: " + paramMap);
|
|
System.out.println("==============================");
|
|
|
|
String sessionId = CommonUtils.checkNull(paramMap.get("sessionId"));
|
|
String chunkIndexStr = CommonUtils.checkNull(paramMap.get("chunkIndex"));
|
|
String totalChunksStr = CommonUtils.checkNull(paramMap.get("totalChunks"));
|
|
String chunk = CommonUtils.checkNull(paramMap.get("chunk"));
|
|
|
|
if("".equals(sessionId) || "".equals(chunkIndexStr) || "".equals(totalChunksStr) || "".equals(chunk)) {
|
|
System.out.println("필수 파라미터 누락");
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "필수 파라미터가 누락되었습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
int chunkIndex = Integer.parseInt(chunkIndexStr);
|
|
int totalChunks = Integer.parseInt(totalChunksStr);
|
|
|
|
System.out.println("청크 업로드: " + sessionId + " [" + (chunkIndex + 1) + "/" + totalChunks + "]");
|
|
System.out.println("청크 크기: " + chunk.length() + " bytes");
|
|
|
|
// 임시 디렉토리에 청크 저장
|
|
String tempDir = System.getProperty("java.io.tmpdir");
|
|
String chunkDir = tempDir + File.separator + "pdf_chunks" + File.separator + sessionId;
|
|
File chunkDirFile = new File(chunkDir);
|
|
if(!chunkDirFile.exists()) {
|
|
chunkDirFile.mkdirs();
|
|
}
|
|
|
|
// 청크 파일 저장
|
|
String chunkFileName = "chunk_" + chunkIndex + ".txt";
|
|
File chunkFile = new File(chunkDir + File.separator + chunkFileName);
|
|
java.io.FileWriter fw = new java.io.FileWriter(chunkFile);
|
|
fw.write(chunk);
|
|
fw.close();
|
|
|
|
// 마지막 청크인 경우 모든 청크를 합쳐서 PDF 파일 생성
|
|
if(chunkIndex == totalChunks - 1) {
|
|
System.out.println("모든 청크 수신 완료, PDF 파일 생성 시작");
|
|
|
|
// 모든 청크 읽어서 합치기
|
|
StringBuilder fullBase64 = new StringBuilder();
|
|
for(int i = 0; i < totalChunks; i++) {
|
|
File cf = new File(chunkDir + File.separator + "chunk_" + i + ".txt");
|
|
java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader(cf));
|
|
String line;
|
|
while((line = br.readLine()) != null) {
|
|
fullBase64.append(line);
|
|
}
|
|
br.close();
|
|
}
|
|
|
|
// Base64 디코딩하여 PDF 파일 생성 (Apache Commons Codec 사용)
|
|
byte[] pdfBytes = org.apache.commons.codec.binary.Base64.decodeBase64(fullBase64.toString());
|
|
|
|
String pdfFileName = sessionId + ".pdf";
|
|
File pdfFile = new File(tempDir + File.separator + pdfFileName);
|
|
java.io.FileOutputStream fos = new java.io.FileOutputStream(pdfFile);
|
|
fos.write(pdfBytes);
|
|
fos.close();
|
|
|
|
pdfFile.deleteOnExit();
|
|
|
|
System.out.println("PDF 파일 생성 완료: " + pdfFile.getAbsolutePath());
|
|
|
|
// 청크 파일들 삭제
|
|
for(int i = 0; i < totalChunks; i++) {
|
|
File cf = new File(chunkDir + File.separator + "chunk_" + i + ".txt");
|
|
cf.delete();
|
|
}
|
|
chunkDirFile.delete();
|
|
}
|
|
|
|
resultMap.put("result", "success");
|
|
|
|
} catch(Exception e) {
|
|
System.out.println("청크 업로드 중 오류: " + e.getMessage());
|
|
e.printStackTrace();
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", e.getMessage());
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 세션 ID로 저장된 PDF 파일 가져오기
|
|
* @param sessionId
|
|
* @param estimateTemplate
|
|
* @return
|
|
*/
|
|
private File getPdfFromSession(String sessionId, Map estimateTemplate) {
|
|
try {
|
|
String tempDir = System.getProperty("java.io.tmpdir");
|
|
File pdfFile = new File(tempDir + File.separator + sessionId + ".pdf");
|
|
|
|
if(pdfFile.exists()) {
|
|
// 견적번호로 파일명 변경
|
|
String estimateNo = CommonUtils.checkNull(estimateTemplate.get("estimate_no"));
|
|
if("".equals(estimateNo)) estimateNo = CommonUtils.checkNull(estimateTemplate.get("ESTIMATE_NO"));
|
|
if("".equals(estimateNo)) estimateNo = "견적서";
|
|
|
|
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
|
|
String timestamp = sdf.format(new java.util.Date());
|
|
String newFileName = estimateNo + "_" + timestamp + ".pdf";
|
|
File renamedFile = new File(tempDir + File.separator + newFileName);
|
|
|
|
// 파일 복사
|
|
java.nio.file.Files.copy(pdfFile.toPath(), renamedFile.toPath(),
|
|
java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
renamedFile.deleteOnExit();
|
|
|
|
// 원본 파일 삭제
|
|
pdfFile.delete();
|
|
|
|
return renamedFile;
|
|
}
|
|
|
|
return null;
|
|
|
|
} catch(Exception e) {
|
|
System.out.println("PDF 파일 가져오기 중 오류: " + e.getMessage());
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 계약 정보 조회 (메일 발송용)
|
|
* @param paramMap - objId (CONTRACT_OBJID)
|
|
* @return
|
|
*/
|
|
public Map getContractInfoForMail(Map paramMap) {
|
|
SqlSession sqlSession = null;
|
|
Map contractInfo = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
contractInfo = (Map) sqlSession.selectOne("contractMgmt.getContractInfoForMail", paramMap);
|
|
} catch(Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return contractInfo;
|
|
}
|
|
|
|
/**
|
|
* 견적서 메일 발송 (커스텀)
|
|
* @param request
|
|
* @param paramMap - objId, pdfSessionId, toEmails, ccEmails, subject, contents
|
|
* @return
|
|
*/
|
|
public Map sendEstimateMailCustom(HttpServletRequest request, Map paramMap) {
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try {
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
|
String toEmailsStr = CommonUtils.checkNull(paramMap.get("toEmails"));
|
|
String ccEmailsStr = CommonUtils.checkNull(paramMap.get("ccEmails"));
|
|
String subject = CommonUtils.checkNull(paramMap.get("subject"));
|
|
String contents = CommonUtils.checkNull(paramMap.get("contents"));
|
|
String pdfSessionId = CommonUtils.checkNull(paramMap.get("pdfSessionId"));
|
|
|
|
// 1. 계약 정보 조회
|
|
Map contractInfo = (Map) sqlSession.selectOne("contractMgmt.getContractInfoForMail", paramMap);
|
|
if(contractInfo == null || contractInfo.isEmpty()) {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "계약 정보를 찾을 수 없습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
// 2. 최종 차수 견적서 조회
|
|
Map estimateTemplate = (Map) sqlSession.selectOne("contractMgmt.getLatestEstimateTemplate", paramMap);
|
|
if(estimateTemplate == null || estimateTemplate.isEmpty()) {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "견적서를 찾을 수 없습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
// 3. 수신인 이메일 리스트 생성
|
|
ArrayList<String> toEmailList = new ArrayList<String>();
|
|
if(!"".equals(toEmailsStr)) {
|
|
String[] toEmails = toEmailsStr.split(",");
|
|
for(String email : toEmails) {
|
|
String trimmedEmail = email.trim();
|
|
if(!"".equals(trimmedEmail)) {
|
|
toEmailList.add(trimmedEmail);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(toEmailList.isEmpty()) {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "수신인 이메일이 없습니다.");
|
|
return resultMap;
|
|
}
|
|
|
|
// 4. 참조 이메일 리스트 생성
|
|
ArrayList<String> ccEmailList = new ArrayList<String>();
|
|
|
|
// 작성자 이메일 자동 추가
|
|
String writerEmail = CommonUtils.checkNull(contractInfo.get("writer_email"));
|
|
if("".equals(writerEmail)) writerEmail = CommonUtils.checkNull(contractInfo.get("WRITER_EMAIL"));
|
|
if(!"".equals(writerEmail)) {
|
|
ccEmailList.add(writerEmail);
|
|
}
|
|
|
|
// 사용자가 입력한 참조 이메일 추가
|
|
if(!"".equals(ccEmailsStr)) {
|
|
String[] ccEmails = ccEmailsStr.split(",");
|
|
for(String email : ccEmails) {
|
|
String trimmedEmail = email.trim();
|
|
if(!"".equals(trimmedEmail) && !ccEmailList.contains(trimmedEmail)) {
|
|
ccEmailList.add(trimmedEmail);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 5. PDF 파일 처리
|
|
ArrayList<HashMap> attachFileList = new ArrayList<HashMap>();
|
|
if(!"".equals(pdfSessionId)) {
|
|
File pdfFile = getPdfFromSession(pdfSessionId, estimateTemplate);
|
|
if(pdfFile != null && pdfFile.exists()) {
|
|
HashMap<String, String> fileMap = new HashMap<String, String>();
|
|
fileMap.put(Constants.Db.COL_FILE_REAL_NAME, pdfFile.getName());
|
|
fileMap.put(Constants.Db.COL_FILE_SAVED_NAME, pdfFile.getName());
|
|
fileMap.put(Constants.Db.COL_FILE_PATH, pdfFile.getParent());
|
|
attachFileList.add(fileMap);
|
|
|
|
System.out.println("PDF 파일 첨부 완료: " + pdfFile.getAbsolutePath());
|
|
} else {
|
|
System.out.println("PDF 파일을 찾을 수 없습니다: " + pdfSessionId);
|
|
}
|
|
}
|
|
|
|
// 6. 메일 발송
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String fromUserId = person.getUserId();
|
|
|
|
// mail_log 조회용 제목 (OBJID 포함)
|
|
String subjectForLog = subject + " [OBJID:" + objId + "]";
|
|
|
|
System.out.println("===== 커스텀 메일 발송 시도 =====");
|
|
System.out.println("From UserId: " + fromUserId);
|
|
System.out.println("To Email: " + toEmailList);
|
|
System.out.println("CC Email: " + ccEmailList);
|
|
System.out.println("Subject (실제 메일): " + subject);
|
|
System.out.println("Subject (mail_log): " + subjectForLog);
|
|
System.out.println("첨부파일 개수: " + attachFileList.size());
|
|
System.out.println("================================");
|
|
|
|
// HTML 형식으로 내용 변환 (줄바꿈 처리)
|
|
String htmlContents = contents.replace("\n", "<br/>");
|
|
|
|
boolean mailSent = false;
|
|
try {
|
|
mailSent = MailUtil.sendMailWithAttachFileUTF8(
|
|
fromUserId,
|
|
null, // fromEmail (자동으로 SMTP 설정 사용)
|
|
new ArrayList<String>(), // toUserIdList (빈 리스트)
|
|
toEmailList,
|
|
ccEmailList,
|
|
new ArrayList<String>(), // bccEmailList (빈 리스트)
|
|
null, // important
|
|
subject, // 실제 메일 제목 (OBJID 없음)
|
|
htmlContents,
|
|
attachFileList.size() > 0 ? attachFileList : null,
|
|
"CONTRACT_ESTIMATE",
|
|
subjectForLog // mail_log용 제목 (OBJID 포함)
|
|
);
|
|
|
|
System.out.println("메일 발송 결과: " + mailSent);
|
|
|
|
} catch(Exception mailEx) {
|
|
System.out.println("메일 발송 중 예외 발생: " + mailEx.getMessage());
|
|
mailEx.printStackTrace();
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "메일 발송 중 예외가 발생했습니다: " + mailEx.getMessage());
|
|
return resultMap;
|
|
}
|
|
|
|
if(mailSent) {
|
|
resultMap.put("result", "success");
|
|
resultMap.put("message", "견적서가 성공적으로 발송되었습니다.");
|
|
} else {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "메일 발송에 실패했습니다.");
|
|
}
|
|
|
|
} catch(Exception e) {
|
|
resultMap.put("result", "error");
|
|
resultMap.put("message", "메일 발송 중 오류가 발생했습니다: " + e.getMessage());
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
}
|