2025-08-29 15:46:08 +09:00
|
|
|
package com.pms.service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import com.pms.common.SqlMapConfig;
|
|
|
|
|
import com.pms.common.bean.PersonBean;
|
|
|
|
|
import com.pms.common.utils.CommonUtils;
|
|
|
|
|
import com.pms.common.utils.Constants;
|
|
|
|
|
import com.pms.common.utils.MailUtil;
|
|
|
|
|
import com.pms.salesmgmt.service.SalesMngService;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class ApprovalService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
CommonService commonService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
SalesMngService salesMngService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
PurchaseOrderService purchaseOrderService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* targetObjId를 통해 등록된 approval이 있는지 체크한다.
|
|
|
|
|
* 있다면 해당 approval object id를 리턴.
|
|
|
|
|
* 없다면 approval을 생성 후, object id를 리턴.
|
|
|
|
|
*
|
|
|
|
|
* transaction 관리대상.
|
|
|
|
|
* </pre>
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return approval의 object id
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public String checkApprovalObjId(SqlSession sqlSession, Map paramMap)throws Exception{
|
|
|
|
|
String result = "";
|
|
|
|
|
|
|
|
|
|
Map map = sqlSession.selectOne("approval.selectApprovalInfo", paramMap);
|
|
|
|
|
if(map != null) result = CommonUtils.checkNull(map.get("OBJID"));
|
|
|
|
|
|
|
|
|
|
if("".equals(result)){
|
|
|
|
|
result = CommonUtils.createObjId();
|
|
|
|
|
paramMap.put("objId", result);
|
|
|
|
|
paramMap.put("systemType", Constants.SYSTEM_NAME);
|
|
|
|
|
sqlSession.insert("approval.insertApprovalInfo", paramMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paramMap.put("approvalObjId", result);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map getLastApprovalInfo(SqlSession sqlSession, Map paramMap)throws Exception{
|
|
|
|
|
paramMap.put("search_type", "last");
|
|
|
|
|
Map map = sqlSession.selectOne("approval.selectApprovalInfo", paramMap);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* Route 신규 생성
|
|
|
|
|
* 반려 후, 생성이 될 수 있으니 Approval의 상태값을 inProcess로 변경.
|
|
|
|
|
* paramMap의 approvalObjId가 필요함.
|
|
|
|
|
*
|
|
|
|
|
* transaction 관리대상.
|
|
|
|
|
* </pre>
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return route의 object id
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public String createRouteInfo(SqlSession sqlSession, Map paramMap)throws Exception{
|
|
|
|
|
String result = "";
|
|
|
|
|
|
|
|
|
|
//1. Approval의 status를 inProcess로 변경.
|
|
|
|
|
Map approvalParamMap = new HashMap();
|
|
|
|
|
approvalParamMap.put("approvalObjId", CommonUtils.checkNull(paramMap.get("approvalObjId")));
|
|
|
|
|
approvalParamMap.put("status", "inProcess");
|
|
|
|
|
sqlSession.update("approval.changeApprovalStatus", approvalParamMap);
|
|
|
|
|
|
|
|
|
|
//2. route 생성
|
|
|
|
|
result = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
|
|
|
paramMap.put("routeObjId", result);
|
|
|
|
|
paramMap.put("systemType", Constants.SYSTEM_NAME);
|
|
|
|
|
sqlSession.insert("approval.createRouteInfo", paramMap);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void createApprovalTagetInfo(SqlSession sqlSession, Map paramMap, String targetObjIdsArr [])throws Exception{
|
|
|
|
|
if(!CommonUtils.isEmpty(targetObjIdsArr) && targetObjIdsArr.length > 0) {
|
|
|
|
|
Map dupCheckMap = new HashMap();
|
|
|
|
|
for (String targetObjId : targetObjIdsArr) {
|
|
|
|
|
if(StringUtils.isNotBlank(targetObjId) && !dupCheckMap.containsKey(targetObjId)) { //중복제거
|
|
|
|
|
dupCheckMap.put(targetObjId, "");
|
|
|
|
|
|
|
|
|
|
//1. APPROVAL_TARGET 생성
|
|
|
|
|
String objid = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
|
|
|
paramMap.put("objId", objid);
|
|
|
|
|
paramMap.put("targetObjId", targetObjId);
|
|
|
|
|
//paramMap.put("systemType", Constants.SYSTEM_NAME);
|
|
|
|
|
sqlSession.insert("approval.createApprovalTagetInfo", paramMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* Inboxtask 신규 생성
|
|
|
|
|
*
|
|
|
|
|
* transaction 관리대상.
|
|
|
|
|
* </pre>
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @param normalArr
|
|
|
|
|
* @param helpArr
|
|
|
|
|
* @param refArr
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public boolean createInboxTask(SqlSession sqlSession, Map paramMap, List<String> normalArr, List<String> helpArr, List<String> refArr)throws Exception{
|
|
|
|
|
boolean result = false;
|
|
|
|
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
for(String targetUserId : normalArr){
|
|
|
|
|
idx++;
|
|
|
|
|
|
|
|
|
|
paramMap.put("inboxTaskObjId", CommonUtils.createObjId());
|
|
|
|
|
paramMap.put("seq", idx);
|
|
|
|
|
paramMap.put("approvalType", "normal");
|
|
|
|
|
|
|
|
|
|
if(idx == 1){
|
|
|
|
|
paramMap.put("status", "ready");
|
|
|
|
|
|
|
|
|
|
//EO 결재 상신(최초) 시 결재구분 일반 중 첫번째 인원에게 메일을 발송한다.
|
|
|
|
|
String targetType = CommonUtils.checkNull(paramMap.get("targetType"));
|
|
|
|
|
|
|
|
|
|
System.out.println("createInboxTask(paramMap):"+paramMap);
|
|
|
|
|
|
|
|
|
|
if("EO".equals(targetType)){
|
|
|
|
|
|
|
|
|
|
System.out.println("createInboxTask(idx):"+idx);
|
|
|
|
|
System.out.println("createInboxTask(targetUserId):"+targetUserId);
|
|
|
|
|
|
|
|
|
|
approvalEODistribute(sqlSession, paramMap,targetUserId);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
paramMap.put("status", "standby");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paramMap.put("targetUserId", targetUserId);
|
|
|
|
|
sqlSession.insert("approval.createInboxTaskInfo", paramMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(String targetUserId : helpArr){
|
|
|
|
|
if(!"null".equals(targetUserId)){
|
|
|
|
|
paramMap.put("inboxTaskObjId", CommonUtils.createObjId());
|
|
|
|
|
paramMap.put("seq", 0);
|
|
|
|
|
paramMap.put("approvalType", "help");
|
|
|
|
|
paramMap.put("status", "ready");
|
|
|
|
|
paramMap.put("targetUserId", targetUserId);
|
|
|
|
|
sqlSession.insert("approval.createInboxTaskInfo", paramMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(String targetUserId : refArr){
|
|
|
|
|
if(!"null".equals(targetUserId)){
|
|
|
|
|
paramMap.put("inboxTaskObjId", CommonUtils.createObjId());
|
|
|
|
|
paramMap.put("seq", 0);
|
|
|
|
|
paramMap.put("approvalType", "ref");
|
|
|
|
|
paramMap.put("status", "complete");
|
|
|
|
|
paramMap.put("targetUserId", targetUserId);
|
|
|
|
|
sqlSession.insert("approval.createInboxTaskInfo", paramMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 결재함 목록 조회
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList getApprovalList(HttpServletRequest request, Map paramMap){
|
|
|
|
|
ArrayList<HashMap<String,Object>> resultList = new ArrayList();
|
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), Constants.ADMIN_COUNT_PER_PAGE+"");
|
|
|
|
|
|
|
|
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
|
|
|
|
|
|
//접속자 정보 등록
|
|
|
|
|
HttpSession session = request.getSession();
|
|
|
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
|
|
|
String connectUserId = CommonUtils.checkNull(person.getUserId());
|
|
|
|
|
paramMap.put("connectUserId", connectUserId);
|
|
|
|
|
|
|
|
|
|
paramMap.put("systemType", Constants.SYSTEM_NAME);
|
|
|
|
|
|
|
|
|
|
Map pageMap = (HashMap)sqlSession.selectOne("approval.selectApprovalListCnt", paramMap);
|
|
|
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap);
|
|
|
|
|
System.out.println("pageMap : "+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("approval.selectApprovalList", paramMap);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* approvalObjId를 통해 route 목록을 조회한다.
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List getRouteList(Map paramMap){
|
|
|
|
|
List resultList = new ArrayList();
|
|
|
|
|
|
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
try{
|
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("approval.getRouteList", paramMap);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* routeObjId를 통해 route 정보를 조회한다.
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map getRouteInfo(Map paramMap){
|
|
|
|
|
Map resultMap = new HashMap();
|
|
|
|
|
|
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
try{
|
|
|
|
|
resultMap = (HashMap)sqlSession.selectOne("approval.getRouteInfo", paramMap);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* route별 inboxtask 목록을 조회한다.
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List getInboxtaskList(Map paramMap){
|
|
|
|
|
List resultList = new ArrayList();
|
|
|
|
|
|
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
try{
|
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("approval.selectInboxtaskList", paramMap);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 담당자 결재 처리
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void setApprovalResult(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
String result = CommonUtils.checkNull(paramMap.get("result"));
|
|
|
|
|
String status = "";
|
|
|
|
|
|
|
|
|
|
if("Y".equals(result)) status = "complete";
|
|
|
|
|
else if("N".equals(result)) status = "reject";
|
|
|
|
|
else status = "cancel";
|
|
|
|
|
|
|
|
|
|
paramMap.put("status", status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("setApprovalResult.paramMap : "+paramMap);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.setInboxtaskResult", paramMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//다음순번의 결재자에게 메일발송 (개발필요) 반려가 되었을경우는 다른 함수에서 처리.
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 승인일 경우 다음 결재자가 있는지 확인 후, 다음 결재자의 상태를 ready로 변경한다.
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void changeNextApprovalStatus(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
int nextSeq = Integer.parseInt(CommonUtils.checkNull(paramMap.get("seq"), "0"))+1;
|
|
|
|
|
paramMap.put("nextSeq", nextSeq);
|
|
|
|
|
Map<String,Object> map = sqlSession.selectOne("approval.getNextApprovalObjId", paramMap);
|
|
|
|
|
|
|
|
|
|
map = CommonUtils.toUpperCaseMapKey(map);
|
|
|
|
|
|
|
|
|
|
System.out.println("changeNextApprovalStatus(map):"+map);
|
|
|
|
|
|
|
|
|
|
if(map != null && !map.isEmpty()){
|
|
|
|
|
String nextInboxtaskObjId = CommonUtils.checkNull(map.get("INBOXTASK_OBJID"));
|
|
|
|
|
sqlSession.update("approval.setNextInboxtaskStatus", nextInboxtaskObjId);
|
|
|
|
|
|
|
|
|
|
Map targetMap = sqlSession.selectOne("approval.getTargetType", paramMap);
|
|
|
|
|
String targetType = CommonUtils.checkNull(targetMap.get("TARGET_TYPE"));
|
|
|
|
|
String nextUserId = CommonUtils.checkNull(map.get("TARGET_USER_ID"));
|
|
|
|
|
String targetObjId = CommonUtils.checkNull(map.get("TARGET_OBJID"));
|
|
|
|
|
String sendEmail = CommonUtils.checkNull(map.get("EMAIL"));
|
|
|
|
|
System.out.println("changeNextApprovalStatus(targetMap):"+targetMap);
|
|
|
|
|
String mailTitle = "";
|
|
|
|
|
|
|
|
|
|
if("EO".equals(targetType)){
|
|
|
|
|
|
|
|
|
|
HashMap eoParamMap = new HashMap();
|
|
|
|
|
eoParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
eoParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
eoParamMap.put("status", "ready");
|
|
|
|
|
|
|
|
|
|
approvalEODistribute(sqlSession, eoParamMap, nextUserId);
|
|
|
|
|
|
|
|
|
|
}else if("EXPENSE_APPLY".equals(targetType)){ //경비신청
|
|
|
|
|
|
|
|
|
|
mailTitle = "[경비신청서 결재요청] 1건이 발생했습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", nextUserId, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
|
|
|
|
|
}else if("ISSUE_RELEASE".equals(targetType)){ //통합문제점
|
|
|
|
|
|
|
|
|
|
mailTitle = "[문제점개선대책서 결재요청] 1건이 발생했습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", nextUserId, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
|
|
|
|
|
}else if("MATERIAL_APPLY".equals(targetType)){ //메일발송
|
|
|
|
|
|
|
|
|
|
mailTitle = "[발주서 결재요청] 1건이 발생했습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", nextUserId, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
|
|
|
|
|
}else if("MATERIAL_SORTAPPLY".equals(targetType)){ //메일발송
|
|
|
|
|
|
|
|
|
|
mailTitle = "[발주서 결재요청] 1건이 발생했습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", nextUserId, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 승인일 경우 다음 결재자가 있는지 확인 후, 다음 결재자에게 메일을 발송한다.
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void SendMailNextApproval(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
int nextSeq = Integer.parseInt(CommonUtils.checkNull(paramMap.get("seq"), "0"))+1;
|
|
|
|
|
paramMap.put("nextSeq", nextSeq);
|
|
|
|
|
Map map = sqlSession.selectOne("approval.getNextApprovalObjId", paramMap);
|
|
|
|
|
|
|
|
|
|
System.out.println("changeNextApprovalStatus(map):"+map);
|
|
|
|
|
|
|
|
|
|
if(map != null && !map.isEmpty()){
|
|
|
|
|
String nextInboxtaskObjId = CommonUtils.checkNull(map.get("INBOXTASK_OBJID"));
|
|
|
|
|
sqlSession.update("approval.setNextInboxtaskStatus", nextInboxtaskObjId);
|
|
|
|
|
|
|
|
|
|
Map targetMap = sqlSession.selectOne("approval.getTargetType", paramMap);
|
|
|
|
|
String targetType = CommonUtils.checkNull(targetMap.get("TARGET_TYPE"));
|
|
|
|
|
String nextUserId = CommonUtils.checkNull(map.get("TARGET_USER_ID"));
|
|
|
|
|
String targetObjId = CommonUtils.checkNull(map.get("TARGET_OBJID"));
|
|
|
|
|
//EO 경우 다음 결재진행자에게 EO 갑지내용으로 메일을 발송한다.
|
|
|
|
|
|
|
|
|
|
System.out.println("changeNextApprovalStatus(targetMap):"+targetMap);
|
|
|
|
|
|
|
|
|
|
if("EO".equals(targetType)){
|
|
|
|
|
|
|
|
|
|
HashMap eoParamMap = new HashMap();
|
|
|
|
|
eoParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
eoParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
eoParamMap.put("status", "ready");
|
|
|
|
|
|
|
|
|
|
approvalEODistribute(sqlSession, eoParamMap, nextUserId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Route의 모든 결재자가 결재처리되었는지 확인 후, Route의 상태를 complete로 변경한다.
|
|
|
|
|
* approval도 종결시킨다.
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void completeRouteInfo(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
Map<String,Object> map = sqlSession.selectOne("approval.getNotCompleteInboxtaskCnt", paramMap);
|
|
|
|
|
|
|
|
|
|
map = CommonUtils.toUpperCaseMapKey(map);
|
|
|
|
|
|
|
|
|
|
int cnt = Integer.parseInt(CommonUtils.checkNull(map.get("CNT"), "0"));
|
|
|
|
|
|
|
|
|
|
//ready나 standby인 상태값이 하나도 없다면 route, approval을 종결시킨다.
|
|
|
|
|
if(cnt == 0){
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("completeStatus", "complete");
|
|
|
|
|
sqlParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
sqlSession.update("approval.completeRoute", sqlParamMap);
|
|
|
|
|
|
|
|
|
|
//approval 종결
|
|
|
|
|
sqlSession.update("approval.completeApproval", paramMap);
|
|
|
|
|
|
|
|
|
|
HashMap routeSqlParamMap = new HashMap();
|
|
|
|
|
routeSqlParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
|
|
|
|
|
Map<String,Object> routeMap = sqlSession.selectOne("approval.getRouteInfo", routeSqlParamMap);
|
|
|
|
|
|
|
|
|
|
routeMap = CommonUtils.toUpperCaseMapKey(routeMap);
|
|
|
|
|
|
|
|
|
|
//targetType을 가져와서 상태값 처리(PDM은 EO밖에 없음.)
|
|
|
|
|
Map<String,Object> targetMap = sqlSession.selectOne("approval.getTargetType", paramMap);
|
|
|
|
|
|
|
|
|
|
targetMap = CommonUtils.toUpperCaseMapKey(targetMap);
|
|
|
|
|
|
|
|
|
|
String targetType = CommonUtils.checkNull(targetMap.get("TARGET_TYPE"));
|
|
|
|
|
String targetObjId = CommonUtils.checkNull(targetMap.get("TARGET_OBJID"));
|
|
|
|
|
String writer = CommonUtils.checkNull(routeMap.get("WRITER"));
|
|
|
|
|
|
|
|
|
|
String sendEmail = CommonUtils.checkNull(routeMap.get("EMAIL"));
|
|
|
|
|
|
|
|
|
|
String mailTitle = "";
|
|
|
|
|
|
|
|
|
|
//route와 approval이 종결되었다고 알림메일 발송(개발필요)
|
|
|
|
|
if("EO".equals(targetType)){ //EO
|
|
|
|
|
targetMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
targetMap.put("resultMessage", CommonUtils.checkNull(paramMap.get("resultMessage")));
|
|
|
|
|
targetMap.put("status", "release");
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeEOStatus", targetMap);
|
|
|
|
|
approvalEODistribute(sqlSession, targetMap, writer);
|
|
|
|
|
}else if("PROBLEM".equals(targetType)){ //통합문제점
|
|
|
|
|
targetMap.put("status", "release");
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeProblemApprovalStatus", targetMap);
|
|
|
|
|
}else if("EXPENSE_APPLY".equals(targetType)){ //경비신청
|
|
|
|
|
|
|
|
|
|
mailTitle = "[경비신청서 결재완료]결재가 완료 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("ISSUE_RELEASE".equals(targetType)){ //통합문제점
|
|
|
|
|
targetMap.put("status", "WPS01100");
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeIssueMgmtApprovalStatus", targetMap);
|
|
|
|
|
|
|
|
|
|
mailTitle = "[문제점개선대책서 결재완료]결재가 완료 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("MATERIAL_APPLY".equals(targetType)){ //발주서작성
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map materMap = sqlSession.selectOne("approval.getmaterstatus", targetMap);
|
|
|
|
|
String STATUS_CD = CommonUtils.checkNull(materMap.get("STATUS_CD"));
|
|
|
|
|
if("PURSTCD00200".equals(STATUS_CD)){
|
|
|
|
|
targetMap.put("status", "PURSTCD00300");
|
|
|
|
|
}else if("PURSTCD00500".equals(STATUS_CD)){
|
|
|
|
|
targetMap.put("status", "PURSTCD00600");
|
|
|
|
|
}
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeMaterApprovalStatus", targetMap);
|
|
|
|
|
mailTitle = "[발주서 결재완료]결재가 완료 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("MATERIAL_SORTAPPLY".equals(targetType)){ //발주서작성
|
|
|
|
|
targetMap.put("status", "PURSTCD00600");
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeMaterApprovalStatus", targetMap);
|
|
|
|
|
mailTitle = "[발주서 결재완료]결재가 완료 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("USED_MNG".equals(targetType)){ //중고관리
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("statusName", "결재완료");
|
|
|
|
|
targetMap.put("statusCommCD", Constants.USED_MNG_STATUS_CD);
|
|
|
|
|
sqlSession.update("approval.changeUsedMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("CUSTOMER_MNG".equals(targetType)){ //중고관리
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("statusName", "결재완료");
|
|
|
|
|
targetMap.put("statusCommCD", Constants.CUSTOMER_MNG_STATUS_CD);
|
|
|
|
|
sqlSession.update("approval.changeCustomerMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("CHECK_REPORT_MNG".equals(targetType)){ //검수관리
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("status", "approvalComplete");
|
|
|
|
|
sqlSession.update("approval.checkReportMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("EO_MNG".equals(targetType)){ //EO 등록
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("status", "approvalComplete");
|
|
|
|
|
targetMap.put("writer", writer);
|
|
|
|
|
sqlSession.update("approval.eoMngApprovalStatus", targetMap);
|
|
|
|
|
// 결제완료시 eo mng 의 reg date를 now()로 업데이트 , eo date
|
|
|
|
|
sqlSession.update("eoMng.changeEOEDITDate", targetMap);
|
|
|
|
|
// 결제완료시 part mng 의 eo를 현재 편집중인 eo로 업데이트 , eo date
|
|
|
|
|
sqlSession.update("eoMng.changePartEO", targetMap);
|
|
|
|
|
|
|
|
|
|
}else if("MOLD_DEV_REQUEST".equals(targetType)){ //금형제작의뢰
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("status", "approvalComplete");
|
|
|
|
|
sqlSession.update("approval.moldDevRequestApprovalStatus", targetMap);
|
|
|
|
|
}else if("ECR_MNG".equals(targetType)){ //ECR
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "0000102");
|
|
|
|
|
sqlSession.update("approval.EcrMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("AS_MNG".equals(targetType)){ //ECR
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "0000102");
|
|
|
|
|
sqlSession.update("approval.ASMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("CSM".equals(targetType)){ //customer_service_mgmt
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "0000102");
|
|
|
|
|
sqlSession.update("approval.CSMApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("SALES_REQUEST".equals(targetType)){ //구매의뢰
|
|
|
|
|
sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "approvalComplete");
|
|
|
|
|
sqlSession.update("approval.salesRequestApprovalStatus", sqlParamMap);
|
|
|
|
|
|
|
|
|
|
salesMngService.afterApprovalCompleteSalesRequest(sqlSession, sqlParamMap);
|
|
|
|
|
}else if("PURCHASE_ORDER".equals(targetType)){ //발주
|
|
|
|
|
sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "approvalComplete");
|
|
|
|
|
sqlSession.update("approval.purchaseOrderApprovalStatus", sqlParamMap);
|
|
|
|
|
|
|
|
|
|
purchaseOrderService.afterApprovalCompleteRouteInfo(sqlSession, routeMap, targetMap, sqlParamMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//동시발주 관련 메일 N건 발송 처리 추가(240109)
|
|
|
|
|
// =>메인 1건만 나가는거로 변경되서 주석처리
|
|
|
|
|
/*
|
|
|
|
|
List multiMasterList = new ArrayList();
|
|
|
|
|
paramMap.put("MULTI_MASTER_OBJID", targetObjId);
|
|
|
|
|
multiMasterList = commonService.selectList("purchaseOrder.selectPurchaseOrderMasterList", null, paramMap);
|
|
|
|
|
if(CommonUtils.isNotEmpty(multiMasterList) && !multiMasterList.isEmpty()) {
|
|
|
|
|
for (Object object : multiMasterList) {
|
|
|
|
|
Map mapInfo = (Map)object;
|
|
|
|
|
sqlParamMap.put("targetObjId", mapInfo.get("OBJID"));
|
|
|
|
|
//sqlParamMap.put("status", "approvalComplete");
|
|
|
|
|
purchaseOrderService.afterApprovalCompleteRouteInfo(sqlSession, routeMap, targetMap, sqlParamMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}else if("DEFECT_ACTION".equals(targetType)){ //부적합품 통보서
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Route의 상태를 reject로 변경한다.
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void rejectRouteInfo(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("completeStatus", "reject");
|
|
|
|
|
sqlParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
|
|
|
|
|
//Route를 반려오 상태를 변경한다.
|
|
|
|
|
sqlSession.update("approval.completeRoute", sqlParamMap);
|
|
|
|
|
|
|
|
|
|
//Route에 해당하는 정보를 가져온다.
|
|
|
|
|
HashMap routeInfoMap = new HashMap();
|
|
|
|
|
routeInfoMap = (HashMap)sqlSession.selectOne("approval.getRouteInfo", sqlParamMap);
|
|
|
|
|
|
|
|
|
|
String sendEmail = CommonUtils.checkNull(routeInfoMap.get("EMAIL"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Route에 해당하는 상신인원 정보
|
|
|
|
|
String writer = CommonUtils.checkNull(routeInfoMap.get("WRITER"));
|
|
|
|
|
|
|
|
|
|
//반려 시 작성된 Comment
|
|
|
|
|
String rejectComment = CommonUtils.checkNull(paramMap.get("resultMessage"));
|
|
|
|
|
|
|
|
|
|
//targetType, targetObjectId을 가져와서 상태값 처리(PDM은 EO밖에 없음.)
|
|
|
|
|
Map<String,Object> targetMap = sqlSession.selectOne("approval.getTargetType", paramMap);
|
|
|
|
|
|
|
|
|
|
targetMap = CommonUtils.toUpperCaseMapKey(targetMap);
|
|
|
|
|
|
|
|
|
|
String targetType = CommonUtils.checkNull(targetMap.get("TARGET_TYPE"));
|
|
|
|
|
String targetObjId = CommonUtils.checkNull(targetMap.get("TARGET_OBJID"));
|
|
|
|
|
String mailTitle ="";
|
|
|
|
|
|
|
|
|
|
targetMap.put("routeObjId", CommonUtils.checkNull(routeInfoMap.get("ROUTE_OBJID")));
|
|
|
|
|
targetMap.put("status", "reject");
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
if("EO".equals(targetType)){
|
|
|
|
|
//상태값을 reject(반려)로 변경한다.
|
|
|
|
|
sqlSession.update("approval.changeEOStatus", targetMap);
|
|
|
|
|
|
|
|
|
|
targetMap.put("resultMessage", rejectComment);
|
|
|
|
|
|
|
|
|
|
//상신자에게 반려되었다는 알림메일 발송
|
|
|
|
|
approvalEODistribute(sqlSession, targetMap, writer);
|
|
|
|
|
}else if("PROBLEM".equals(targetType)){
|
|
|
|
|
//상태값을 reject(반려)로 변경한다.
|
|
|
|
|
sqlSession.update("approval.changeProblemApprovalStatus", targetMap);
|
|
|
|
|
}else if("DESIGN_CHECK_LIST".equals(targetType)){
|
|
|
|
|
//상태값을 reject(반려)로 변경한다.
|
|
|
|
|
sqlSession.update("approval.changeDesignCheckListApprovalStatus", targetMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if("MATERIAL_APPLY".equals(targetType)){ //발주
|
|
|
|
|
Map materMap = sqlSession.selectOne("approval.getmaterstatus", targetMap);
|
|
|
|
|
String STATUS_CD = CommonUtils.checkNull(materMap.get("STATUS_CD"));
|
|
|
|
|
if("PURSTCD00200".equals(STATUS_CD)){
|
|
|
|
|
targetMap.put("status", "PURSTCD00100");
|
|
|
|
|
}else if("PURSTCD00500".equals(STATUS_CD)){
|
|
|
|
|
targetMap.put("status", "PURSTCD00400");
|
|
|
|
|
}
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeMaterApprovalStatus", targetMap);
|
|
|
|
|
|
|
|
|
|
mailTitle = "[발주서 반려알림]결재가 반려 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("EXPENSE_APPLY".equals(targetType)){ //경비
|
|
|
|
|
mailTitle = "[경비신청서 반려알림]결재가 반려 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("ISSUE_RELEASE".equals(targetType)){ //통합문제점
|
|
|
|
|
|
|
|
|
|
mailTitle = "[문제점개선대책서 반려알림]결재가 반려 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
|
|
|
|
|
}else if("MATERIAL_SORTAPPLY".equals(targetType)){ //발주
|
|
|
|
|
targetMap.put("status", "PURSTCD00100");
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeMaterApprovalStatus", targetMap);
|
|
|
|
|
|
|
|
|
|
mailTitle = "[발주서 반려알림]결재가 반려 되었습니다.";
|
|
|
|
|
MailUtil.sendMail("plm_admin", "master@hongsungeng.co.kr", writer, sendEmail, "", "", "", mailTitle, mailTitle, "ISSUE_RELEASE");
|
|
|
|
|
}else if("USED_MNG".equals(targetType)){ //중고관리
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("statusName", "반려");
|
|
|
|
|
targetMap.put("statusCommCD", Constants.USED_MNG_STATUS_CD);
|
|
|
|
|
sqlSession.update("approval.changeUsedMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("CUSTOMER_MNG".equals(targetType)){ //중고관리
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("statusName", "반려");
|
|
|
|
|
targetMap.put("statusCommCD", Constants.CUSTOMER_MNG_STATUS_CD);
|
|
|
|
|
sqlSession.update("approval.changeCustomerMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("CHECK_REPORT_MNG".equals(targetType)){ //검수관리
|
|
|
|
|
targetMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
targetMap.put("status", "reject");
|
|
|
|
|
sqlSession.update("approval.checkReportMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("EO_MNG".equals(targetType)){ //검수관리
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("status", "reject");
|
|
|
|
|
sqlSession.update("approval.eoMngApprovalStatus", targetMap);
|
|
|
|
|
}else if("MOLD_DEV_REQUEST".equals(targetType)){ //금형제작의뢰
|
|
|
|
|
targetMap.put("targetObjId", targetObjId);
|
|
|
|
|
targetMap.put("status", "reject");
|
|
|
|
|
sqlSession.update("approval.moldDevRequestApprovalStatus", targetMap);
|
|
|
|
|
}else if("ECR_MNG".equals(targetType)){ //ECR
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "0000107");
|
|
|
|
|
sqlSession.update("approval.EcrMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("AS_MNG".equals(targetType)){ //ECR
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "0000107");
|
|
|
|
|
sqlSession.update("approval.ASMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("CSM".equals(targetType)){ //customer_service_mgmt
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "0000107");
|
|
|
|
|
sqlSession.update("approval.CSMApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("SALES_REQUEST".equals(targetType)){ //구매의뢰
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "reject");
|
|
|
|
|
sqlSession.update("approval.salesRequestApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("PURCHASE_ORDER".equals(targetType)){ //구매의뢰
|
|
|
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
|
|
|
sqlParamMap.put("status", "reject");
|
|
|
|
|
sqlSession.update("approval.purchaseOrderApprovalStatus", sqlParamMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 이전 결재자가 반려를 했기때문에, 대기상태의 모든 inboxtask를 cancel로 변경시킨다.
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void setInboxtaskCancel(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
//반려가 되었기때문에 남은 인원에 대하여 반려알림 메일발송 (개발필요)
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.cancelInboxtask", paramMap);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 결재상신시 target의 상태값을 변경한다.
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
*/
|
|
|
|
|
public void setTargetStatus(SqlSession sqlSession, Map paramMap){
|
|
|
|
|
String targetType = CommonUtils.checkNull(paramMap.get("targetType"));
|
|
|
|
|
if("EO".equals(targetType)){
|
|
|
|
|
//상태값을 complete로 변경한다.
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("status", "approval");
|
|
|
|
|
sqlParamMap.put("TARGET_OBJID", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlSession.update("approval.changeEOStatus", sqlParamMap);
|
|
|
|
|
}else if("PROBLEM".equals(targetType)){
|
|
|
|
|
//결재상태를 create로 입력한다.
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("status", "approval");
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
sqlSession.update("approval.changeProblemApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("DESIGN_CHECK_LIST".equals(targetType)){
|
|
|
|
|
//결재상태를 create로 입력한다.
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("status", "approval");
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("routeObjId", CommonUtils.checkNull(paramMap.get("routeObjId")));
|
|
|
|
|
sqlSession.update("approval.changeDesignCheckListApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("ISSUE_RELEASE".equals(targetType)){ //통합문제점
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("status", "WPS01000");
|
|
|
|
|
sqlParamMap.put("targetObjId",CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
|
|
|
|
|
sqlSession.update("approval.changeIssueMgmtApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("USED_MNG".equals(targetType)){ //중고관리
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("statusName", "결재중");
|
|
|
|
|
sqlParamMap.put("statusCommCD", Constants.USED_MNG_STATUS_CD);
|
|
|
|
|
sqlSession.update("approval.changeUsedMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("CUSTOMER_MNG".equals(targetType)){ //중고관리
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("statusName", "결재중");
|
|
|
|
|
sqlParamMap.put("statusCommCD", Constants.CUSTOMER_MNG_STATUS_CD);
|
|
|
|
|
sqlSession.update("approval.changeCustomerMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("CHECK_REPORT_MNG".equals(targetType)){ //검수관리
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "approvalRequest");
|
|
|
|
|
sqlSession.update("approval.checkReportMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("EO_MNG".equals(targetType)){ //검수관리
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "approvalRequest");
|
|
|
|
|
sqlSession.update("approval.eoMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("MOLD_DEV_REQUEST".equals(targetType)){ //금형제작의뢰
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "approvalRequest");
|
|
|
|
|
sqlSession.update("approval.moldDevRequestApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("ECR_MNG".equals(targetType)){ //금형제작의뢰
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "0000101");
|
|
|
|
|
sqlSession.update("approval.EcrMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("AS_MNG".equals(targetType)){ //금형제작의뢰
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "0000101");
|
|
|
|
|
sqlSession.update("approval.ASMngApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("CSM".equals(targetType)){ //customer_service_mgmt
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "0000101");
|
|
|
|
|
sqlSession.update("approval.CSMApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("SALES_REQUEST".equals(targetType)){ //구매의뢰
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "approvalRequest");
|
|
|
|
|
sqlSession.update("approval.salesRequestApprovalStatus", sqlParamMap);
|
|
|
|
|
}else if("PURCHASE_ORDER".equals(targetType)){ //구매의뢰
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("targetObjId", CommonUtils.checkNull(paramMap.get("targetObjId")));
|
|
|
|
|
sqlParamMap.put("status", "approvalRequest");
|
|
|
|
|
sqlSession.update("approval.purchaseOrderApprovalStatus", sqlParamMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 결재상신 후 EO 배포처에 해당하는 인원들에게 EO 갑지내용을 배포한다.
|
|
|
|
|
* type : approval(결재 상신 시 1번째 인원 또는 다음 결재인원에게 메일 발송)
|
|
|
|
|
* type : release(모든 인원이 결재 완료하여 배포처 및 결재상신 인원에게 메일발송)
|
|
|
|
|
* @param sqlSession
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @param type
|
|
|
|
|
*/
|
|
|
|
|
public void approvalEODistribute(SqlSession sqlSession, Map paramMap,String userId){
|
|
|
|
|
ArrayList distributeMemberList = new ArrayList();
|
|
|
|
|
ArrayList connectedPartList = new ArrayList();
|
|
|
|
|
ArrayList connectedDrawPartList = new ArrayList();
|
|
|
|
|
HashMap eoInfoMap = new HashMap();
|
|
|
|
|
|
|
|
|
|
System.out.println("approvalEODistribute(paramMap):"+paramMap);
|
|
|
|
|
System.out.println("approvalEODistribute(userId):"+userId);
|
|
|
|
|
|
|
|
|
|
//EO의 ObjectId
|
|
|
|
|
String targetObjid = CommonUtils.checkNull(paramMap.get("targetObjId"));
|
|
|
|
|
|
|
|
|
|
//Route의 ObjectId
|
|
|
|
|
String routeObjId = CommonUtils.checkNull(paramMap.get("routeObjId"));
|
|
|
|
|
|
|
|
|
|
String status = CommonUtils.checkNull(paramMap.get("status"));
|
|
|
|
|
|
|
|
|
|
if(!"".equals(targetObjid)){
|
|
|
|
|
//EO 정보를 가져온다.
|
|
|
|
|
HashMap eoSqlMap = new HashMap();
|
|
|
|
|
eoSqlMap.put("objId", targetObjid);
|
|
|
|
|
eoInfoMap = sqlSession.selectOne("eo.getEOInfo",eoSqlMap);
|
|
|
|
|
//EO에 연결된 정보를 가져온다.
|
|
|
|
|
connectedPartList = (ArrayList)sqlSession.selectList("eo.getConnectPartList", eoSqlMap);
|
|
|
|
|
|
|
|
|
|
eoSqlMap.put("drawingType", "draw");
|
|
|
|
|
connectedDrawPartList = (ArrayList)sqlSession.selectList("eo.getConnectPartList", eoSqlMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String eoNo = CommonUtils.checkNull(eoInfoMap.get("EO_NO"));
|
|
|
|
|
String eoDate = CommonUtils.checkNull(eoInfoMap.get("EO_ISSUE_DATE"));
|
|
|
|
|
String carName = CommonUtils.checkNull(eoInfoMap.get("CAR_NAME"));
|
|
|
|
|
String carCode = CommonUtils.checkNull(eoInfoMap.get("CAR_CODE"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//결재 상신 후 결재 순으로 인원에게 메일발송
|
|
|
|
|
if("ready".equals(status) || "complete".equals(status)){
|
|
|
|
|
|
|
|
|
|
//제목에 사용할 EO정보
|
|
|
|
|
String mailSubject = "[EO 결재요청] "+carCode+"_"+eoNo+"("+eoDate+")_"+connectedDrawPartList.size()+"건";
|
|
|
|
|
|
|
|
|
|
HashMap userSqlMap = new HashMap();
|
|
|
|
|
userSqlMap.put("userId",userId);
|
|
|
|
|
|
|
|
|
|
System.out.println("approvalEODistribute(userSqlMap):"+userSqlMap);
|
|
|
|
|
|
|
|
|
|
HashMap userMap = sqlSession.selectOne("admin.selectUserInfo", userSqlMap);
|
|
|
|
|
String userEmail = CommonUtils.checkNull(userMap.get("EMAIL"));
|
|
|
|
|
|
|
|
|
|
HashMap routeMap = (HashMap)getRouteInfo(paramMap);
|
|
|
|
|
|
|
|
|
|
String routeTitle = "";
|
|
|
|
|
String writer = "";
|
|
|
|
|
String comment = "";
|
|
|
|
|
if(null == routeMap || routeMap.isEmpty()){
|
|
|
|
|
routeTitle = CommonUtils.checkNull(paramMap.get("approvalTitle"));
|
|
|
|
|
|
|
|
|
|
HashMap writerSqlMap = new HashMap();
|
|
|
|
|
writerSqlMap.put("userId",CommonUtils.checkNull(paramMap.get("writer")));
|
|
|
|
|
HashMap writerMap = sqlSession.selectOne("admin.selectUserInfo", writerSqlMap);
|
|
|
|
|
|
|
|
|
|
writer = CommonUtils.checkNull(writerMap.get("DEPT_NAME"))+" "+CommonUtils.checkNull(writerMap.get("USER_NAME"));
|
|
|
|
|
comment = CommonUtils.checkNull(paramMap.get("approvalDescription"));
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
routeTitle = CommonUtils.checkNull(routeMap.get("APPROVAL_TITLE"));
|
|
|
|
|
writer = CommonUtils.checkNull(routeMap.get("WRITER_DEPT_NAME"))+" "+CommonUtils.checkNull(routeMap.get("WRITER_USER_NAME"));
|
|
|
|
|
comment = CommonUtils.checkNull(routeMap.get("APPROVAL_DESC"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//결재 상신 시 문구
|
|
|
|
|
HashMap mailMap = new HashMap();
|
|
|
|
|
mailMap.put("approvalType", "EO");
|
|
|
|
|
mailMap.put("routeTitle", routeTitle);
|
|
|
|
|
mailMap.put("approvalUser", writer);
|
|
|
|
|
mailMap.put("comment", comment);
|
|
|
|
|
mailMap.put("userType", "상신자");
|
|
|
|
|
mailMap.put("mailUrl", Constants.SYSTEM_URL);
|
|
|
|
|
|
|
|
|
|
String mailContents = MailUtil.getHTMLContents("eoApprovalMailTemplate", mailMap);
|
|
|
|
|
|
|
|
|
|
System.out.println("approvalEODistribute(status):"+status);
|
|
|
|
|
System.out.println("approvalEODistribute(userEmail):"+userEmail);
|
|
|
|
|
System.out.println("approvalEODistribute(mailContents):"+mailContents);
|
|
|
|
|
System.out.println("approvalEODistribute(mailSubject):"+mailSubject);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "bestcw8388@iljitech.co.kr", userId, userEmail, "", "", "", mailSubject, mailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "", userId, "don38317@gmail.com", "", "", "", mailSubject, mailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
|
|
|
|
|
//결재 인원 모두 결재 완료된 경우
|
|
|
|
|
}else if("release".equals(status)){
|
|
|
|
|
|
|
|
|
|
HashMap mailMap = new HashMap();
|
|
|
|
|
mailMap.put("oem", CommonUtils.checkNull(eoInfoMap.get("OEM_NAME")));
|
|
|
|
|
mailMap.put("car", CommonUtils.checkNull(eoInfoMap.get("CAR_CODE")));
|
|
|
|
|
mailMap.put("eoType", CommonUtils.checkNull(eoInfoMap.get("EO_TYPE_STR")));
|
|
|
|
|
mailMap.put("designTeam", CommonUtils.checkNull(eoInfoMap.get("DESIGN_TEAM")));
|
|
|
|
|
mailMap.put("eoNo", CommonUtils.checkNull(eoInfoMap.get("EO_NO")));
|
|
|
|
|
mailMap.put("eoDate", CommonUtils.checkNull(eoInfoMap.get("EO_ISSUE_DATE")));
|
|
|
|
|
mailMap.put("urgentDegree", CommonUtils.checkNull(eoInfoMap.get("URGENT_DEGREE_STR")));
|
|
|
|
|
mailMap.put("hkmcDate", CommonUtils.checkNull(eoInfoMap.get("HKMC_DISTRIBUTE_DATE")));
|
|
|
|
|
mailMap.put("approvalDesc", CommonUtils.checkNull(paramMap.get("approvalDescription")));
|
|
|
|
|
|
|
|
|
|
if(0 < connectedDrawPartList.size()){
|
|
|
|
|
|
|
|
|
|
String appendHtlm = "";
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<connectedDrawPartList.size();i++){
|
|
|
|
|
HashMap connectPartMap = (HashMap)connectedDrawPartList.get(i);
|
|
|
|
|
|
|
|
|
|
String rnum = CommonUtils.checkNull(connectPartMap.get("RNUM"));
|
|
|
|
|
String partNo = CommonUtils.checkNull(connectPartMap.get("PART_NO"));
|
|
|
|
|
String partName = CommonUtils.checkNull(connectPartMap.get("PART_NAME"));
|
|
|
|
|
String changeItems = CommonUtils.checkNull(connectPartMap.get("CHANGE_ITEM_TITLE"));
|
|
|
|
|
String rev = CommonUtils.checkNull(connectPartMap.get("REV"));
|
|
|
|
|
String ecdFlag = CommonUtils.checkNull(connectPartMap.get("ECD_OBJID"));
|
|
|
|
|
|
|
|
|
|
if("".equals(ecdFlag)){
|
|
|
|
|
ecdFlag = "N";
|
|
|
|
|
}else{
|
|
|
|
|
ecdFlag = "Y";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String mngItemFlag = CommonUtils.checkNull(connectPartMap.get("MNG_ITEM_TYPE_TITLE"),"-");
|
|
|
|
|
String applyPointName = CommonUtils.checkNull(connectPartMap.get("APPLY_POINT_NAME"));
|
|
|
|
|
|
|
|
|
|
appendHtlm += "<tr>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+rnum+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+partNo+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+partName+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+changeItems+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+rev+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+ecdFlag+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+mngItemFlag+"</td>";
|
|
|
|
|
appendHtlm += " <td align='center' style= 'height:30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid #ccc'>"+applyPointName+"</td>";
|
|
|
|
|
appendHtlm += "</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("".equals(appendHtlm)){
|
|
|
|
|
appendHtlm += "<tr>";
|
|
|
|
|
appendHtlm += " <td colspan='8'>연결된 파트 정보가 없습니다.</td>";
|
|
|
|
|
appendHtlm += "</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//파트에 해당하는 영역에 Part 정보를 append 한다.
|
|
|
|
|
mailMap.put("connectedPartList", appendHtlm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//모든 결재 완료 시 문구
|
|
|
|
|
//제목에 사용할 EO정보
|
|
|
|
|
String mailSubject = "[EO 결재완료] "+carCode+"_"+eoNo+"("+eoDate+")_"+connectedDrawPartList.size()+"건";
|
|
|
|
|
|
|
|
|
|
HashMap approvalMap = new HashMap();
|
|
|
|
|
approvalMap.put("objId", targetObjid);
|
|
|
|
|
ArrayList eoApprovalList = (ArrayList)sqlSession.selectList("eo.getEOApprovalList",approvalMap);
|
|
|
|
|
|
|
|
|
|
String approvalMembers = "";
|
|
|
|
|
|
|
|
|
|
for(int j=0;j<eoApprovalList.size();j++){
|
|
|
|
|
HashMap eoApprovalMap = (HashMap)eoApprovalList.get(j);
|
|
|
|
|
|
|
|
|
|
String memberName = CommonUtils.checkNull(eoApprovalMap.get("USER_NAME"));
|
|
|
|
|
String deptName = CommonUtils.checkNull(eoApprovalMap.get("DEPT_NAME"));
|
|
|
|
|
|
|
|
|
|
approvalMembers+="<tr>";
|
|
|
|
|
approvalMembers+="<td style='height:15px; border:1px solid #a3a3a3; font-size: 12px; line-height: 15px; text-align: center;'>"+(j+1)+"</td>";
|
|
|
|
|
approvalMembers+="<td style='height:15px; border:1px solid #a3a3a3; font-size: 12px; line-height: 15px; text-align: center;'>"+deptName+"</td>";
|
|
|
|
|
approvalMembers+="<td style='height:15px; border:1px solid #a3a3a3; font-size: 12px; line-height: 15px; text-align: center;'>"+memberName+"</td>";
|
|
|
|
|
approvalMembers+="</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mailMap.put("approvalMembers", approvalMembers);
|
|
|
|
|
|
|
|
|
|
HashMap distributeSqlMap = new HashMap();
|
|
|
|
|
|
|
|
|
|
distributeSqlMap.put("targetObjId", targetObjid);
|
|
|
|
|
|
|
|
|
|
distributeMemberList = (ArrayList)sqlSession.selectList("approval.getEODistributeMemberList", distributeSqlMap);
|
|
|
|
|
|
|
|
|
|
String releaseMembers = "";
|
|
|
|
|
|
|
|
|
|
for(int k=0;k<distributeMemberList.size();k++){
|
|
|
|
|
HashMap resultMap = (HashMap)distributeMemberList.get(k);
|
|
|
|
|
String deptName = CommonUtils.checkNull(resultMap.get("DEPT_NAME"));
|
|
|
|
|
String userName = CommonUtils.checkNull(resultMap.get("USER_NAME"));
|
|
|
|
|
|
|
|
|
|
if(null != distributeMemberList && k == (distributeMemberList.size()-1)){
|
|
|
|
|
releaseMembers += deptName+' '+userName;
|
|
|
|
|
}else{
|
|
|
|
|
releaseMembers += deptName+' '+userName+",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mailMap.put("releaseMembers", releaseMembers);
|
|
|
|
|
|
|
|
|
|
String mailContents = MailUtil.getHTMLContents("eoMailTemplate", mailMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//차종에 해당하는 배포터 인원에게 메일을 배포한다.
|
|
|
|
|
for(int l=0;l<distributeMemberList.size();l++){
|
|
|
|
|
HashMap resultMap = (HashMap)distributeMemberList.get(l);
|
|
|
|
|
String email = CommonUtils.checkNull(resultMap.get("EMAIL"));
|
|
|
|
|
String receptionUserId = CommonUtils.checkNull(resultMap.get("MEMBER_USER_ID"));
|
|
|
|
|
|
|
|
|
|
System.out.println("배포처 mailContents:"+mailContents);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "bestcw8388@iljitech.co.kr", receptionUserId, email, "", "", "", mailSubject, mailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "", receptionUserId, "don38317@gmail.com", "", "", "", mailSubject, mailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//결재완료 후 상신자에게 결재완료 메일을 발송한다.
|
|
|
|
|
HashMap userSqlMap = new HashMap();
|
|
|
|
|
userSqlMap.put("userId",userId);
|
|
|
|
|
HashMap userMap = sqlSession.selectOne("admin.selectUserInfo", userSqlMap);
|
|
|
|
|
HashMap routeMap = (HashMap)getRouteInfo(paramMap);
|
|
|
|
|
|
|
|
|
|
String userEmail = CommonUtils.checkNull(userMap.get("EMIL"));
|
|
|
|
|
|
|
|
|
|
HashMap writerMailMap = new HashMap();
|
|
|
|
|
writerMailMap.put("approvalType", "EO");
|
|
|
|
|
writerMailMap.put("routeTitle", CommonUtils.checkNull(routeMap.get("APPROVAL_TITLE")));
|
|
|
|
|
writerMailMap.put("approvalUser", CommonUtils.checkNull(routeMap.get("WRITER_DEPT_NAME"))+" "+CommonUtils.checkNull(routeMap.get("WRITER_USER_NAME")));
|
|
|
|
|
writerMailMap.put("comment", CommonUtils.checkNull(paramMap.get("resultMessage")));
|
|
|
|
|
writerMailMap.put("userType", "상신자");
|
|
|
|
|
writerMailMap.put("mailUrl", Constants.SYSTEM_URL);
|
|
|
|
|
writerMailMap.put("releaseMembers", releaseMembers);
|
|
|
|
|
String writerMailContents = MailUtil.getHTMLContents("eoApprovalMailTemplate", writerMailMap);
|
|
|
|
|
|
|
|
|
|
System.out.println("상신자 mailContents:"+writerMailContents);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "bestcw8388@iljitech.co.kr", userId, userEmail, "", "", "", mailSubject, writerMailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "", userId, "don38317@gmail.com", "", "", "", mailSubject, writerMailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
//반려된 경우
|
|
|
|
|
}else if("reject".equals(status)){
|
|
|
|
|
//반려 시 작성된 Comment
|
|
|
|
|
HashMap userSqlMap = new HashMap();
|
|
|
|
|
userSqlMap.put("userId",userId);
|
|
|
|
|
HashMap userMap = sqlSession.selectOne("admin.selectUserInfo", userSqlMap);
|
|
|
|
|
HashMap routeMap = (HashMap)getRouteInfo(paramMap);
|
|
|
|
|
String userEmail = CommonUtils.checkNull(userMap.get("EMIL"));
|
|
|
|
|
|
|
|
|
|
String writerMailSubject = "[EO 반려] "+carCode+"_"+eoNo+"("+eoDate+")_"+connectedPartList.size()+"건";
|
|
|
|
|
|
|
|
|
|
HashMap writerMailMap = new HashMap();
|
|
|
|
|
writerMailMap.put("approvalType", "EO");
|
|
|
|
|
writerMailMap.put("routeTitle", CommonUtils.checkNull(routeMap.get("APPROVAL_TITLE")));
|
|
|
|
|
writerMailMap.put("approvalUser", CommonUtils.checkNull(routeMap.get("WRITER_DEPT_NAME"))+" "+CommonUtils.checkNull(routeMap.get("WRITER_USER_NAME")));
|
|
|
|
|
writerMailMap.put("comment", CommonUtils.checkNull(paramMap.get("resultMessage")));
|
|
|
|
|
writerMailMap.put("userType", "상신자");
|
|
|
|
|
writerMailMap.put("mailUrl", Constants.SYSTEM_URL);
|
|
|
|
|
String writerMailContents = MailUtil.getHTMLContents("eoApprovalMailTemplate", writerMailMap);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "bestcw8388@iljitech.co.kr", userId, userEmail, "", "", "", writerMailSubject, writerMailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
|
|
|
|
|
MailUtil.sendMail(CommonUtils.checkNull(paramMap.get("writer")), "", userId, "don38317@gmail.com", "", "", "", writerMailSubject, writerMailContents, Constants.MAIL_TYPE_RELEASE_EO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 접속자의 결재건수를 가져온다.
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map getApprovalCnt(HttpServletRequest request, Map paramMap){
|
|
|
|
|
Map<String,Object> resultMap = new HashMap();
|
|
|
|
|
SqlSession sqlSession = null;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
|
|
|
|
|
String userId = CommonUtils.checkNull(paramMap.get("userId"));
|
|
|
|
|
System.out.println("userId : "+userId);
|
|
|
|
|
if(!"".equals(userId)){
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("userId", userId);
|
|
|
|
|
sqlParamMap.put("systemType", "PMS");
|
|
|
|
|
resultMap = sqlSession.selectOne("approval.getApprovalCnt", sqlParamMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultMap);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-10 15:26:26 +09:00
|
|
|
/**
|
|
|
|
|
* Amaranth10 전자결재 건수 조회
|
|
|
|
|
* 세션에서 empseq를 가져와 서버 인증으로 직접 결재함 조회
|
|
|
|
|
* @param request
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map getAmaranthApprovalCnt(HttpServletRequest request, Map paramMap){
|
|
|
|
|
Map<String,Object> resultMap = new HashMap();
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
// 파라미터에서 empseq 가져오기 (header.jsp에서 전달)
|
|
|
|
|
String empSeq = CommonUtils.checkNull(paramMap.get("empseq"));
|
|
|
|
|
String userId = CommonUtils.checkNull(paramMap.get("userId"));
|
|
|
|
|
String compSeq = "1000"; // 회사 시퀀스
|
|
|
|
|
|
|
|
|
|
System.out.println("=== Amaranth 결재 건수 조회 ===");
|
|
|
|
|
System.out.println("userId: " + userId);
|
|
|
|
|
System.out.println("empSeq: " + empSeq);
|
|
|
|
|
|
|
|
|
|
// empSeq가 비어있으면 에러 처리
|
|
|
|
|
if(empSeq == null || empSeq.isEmpty()){
|
|
|
|
|
System.err.println("empSeq가 비어있습니다. LoginId 업데이트 배치를 먼저 실행하세요.");
|
|
|
|
|
resultMap.put("CNT", "0");
|
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Amaranth10 결재함 조회 (서버 인증 - 인증 토큰 불필요)
|
|
|
|
|
com.pms.api.AmaranthApprovalApiClient apiClient = new com.pms.api.AmaranthApprovalApiClient();
|
|
|
|
|
String baseUrl = "https://erp.rps-korea.com";
|
|
|
|
|
|
|
|
|
|
String boxListJson = apiClient.getApprovalBoxListDirect(baseUrl, empSeq, compSeq);
|
|
|
|
|
|
|
|
|
|
// 미결 건수 추출 (boxCode = "20")
|
|
|
|
|
int pendingCnt = extractPendingCount(boxListJson);
|
|
|
|
|
|
|
|
|
|
resultMap.put("CNT", String.valueOf(pendingCnt));
|
|
|
|
|
resultMap.put("AMARANTH_CNT", String.valueOf(pendingCnt));
|
|
|
|
|
|
|
|
|
|
System.out.println("Amaranth 미결 건수: " + pendingCnt);
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
System.err.println("Amaranth 결재 건수 조회 오류: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultMap.put("CNT", "0");
|
|
|
|
|
resultMap.put("ERROR", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* JSON에서 미결 건수 추출 (boxCode = "20" 미결문서)
|
|
|
|
|
* 응답 구조: resultData.result.boxList[].boxCode, docCnt
|
|
|
|
|
*/
|
|
|
|
|
private int extractPendingCount(String jsonResponse){
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
System.out.println("=== 미결 건수 파싱 시작 ===");
|
|
|
|
|
System.out.println("응답 내용: " + jsonResponse);
|
|
|
|
|
|
|
|
|
|
// boxCode "20" 찾기 (미결문서)
|
|
|
|
|
// "boxCode":"20" 또는 "boxCode": "20" 형태
|
|
|
|
|
int searchFrom = 0;
|
|
|
|
|
while(true) {
|
|
|
|
|
int boxCodeIndex = jsonResponse.indexOf("\"boxCode\"", searchFrom);
|
|
|
|
|
if(boxCodeIndex == -1) break;
|
|
|
|
|
|
|
|
|
|
// "boxCode" 뒤의 값 추출
|
|
|
|
|
int colonIndex = jsonResponse.indexOf(":", boxCodeIndex + 9);
|
|
|
|
|
if(colonIndex == -1) break;
|
|
|
|
|
|
|
|
|
|
int valueStart = jsonResponse.indexOf("\"", colonIndex);
|
|
|
|
|
if(valueStart == -1) break;
|
|
|
|
|
|
|
|
|
|
int valueEnd = jsonResponse.indexOf("\"", valueStart + 1);
|
|
|
|
|
if(valueEnd == -1) break;
|
|
|
|
|
|
|
|
|
|
String boxCodeValue = jsonResponse.substring(valueStart + 1, valueEnd);
|
|
|
|
|
|
|
|
|
|
if("20".equals(boxCodeValue)) {
|
|
|
|
|
// boxCode "20" 객체의 시작 위치 찾기 (이전 { 찾기)
|
|
|
|
|
int objStart = jsonResponse.lastIndexOf("{", boxCodeIndex);
|
|
|
|
|
if(objStart >= 0) {
|
|
|
|
|
String objStr = jsonResponse.substring(objStart, boxCodeIndex);
|
|
|
|
|
|
|
|
|
|
// docCnt 추출
|
|
|
|
|
int docCntIndex = objStr.indexOf("\"docCnt\"");
|
|
|
|
|
if(docCntIndex >= 0) {
|
|
|
|
|
int dcColonIndex = objStr.indexOf(":", docCntIndex + 8);
|
|
|
|
|
int dcValueStart = objStr.indexOf("\"", dcColonIndex);
|
|
|
|
|
int dcValueEnd = objStr.indexOf("\"", dcValueStart + 1);
|
|
|
|
|
|
|
|
|
|
if(dcValueStart >= 0 && dcValueEnd > dcValueStart) {
|
|
|
|
|
String docCntStr = objStr.substring(dcValueStart + 1, dcValueEnd);
|
|
|
|
|
count = Integer.parseInt(docCntStr.trim());
|
|
|
|
|
System.out.println("미결문서(boxCode=20) docCnt: " + count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchFrom = valueEnd + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println("미결 건수 추출 오류: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-10 17:01:35 +09:00
|
|
|
/**
|
|
|
|
|
* Amaranth10 전자결재 문서 목록 조회 - JSON 문자열 반환 (AJAX 전용)
|
|
|
|
|
* approvalList.jsp 전용 엔드포인트에서 호출
|
|
|
|
|
* @param request HttpServletRequest
|
|
|
|
|
* @param paramMap 검색 파라미터
|
|
|
|
|
* @return JSON 문자열
|
|
|
|
|
*/
|
|
|
|
|
public String getAmaranthApprovalDocListJson(HttpServletRequest request, Map paramMap){
|
|
|
|
|
Map<String, Object> resultMap = getAmaranthApprovalDocList(request, paramMap);
|
|
|
|
|
return buildApprovalDocListJson(resultMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Amaranth10 결재 문서 상세 조회
|
|
|
|
|
* @param request HttpServletRequest
|
|
|
|
|
* @param paramMap docId, deptSeq 필수
|
|
|
|
|
* @return API 응답 JSON 원본 (contents HTML 포함)
|
|
|
|
|
*/
|
|
|
|
|
public String getAmaranthApprovalDocDetail(HttpServletRequest request, Map paramMap){
|
|
|
|
|
try {
|
|
|
|
|
// 세션에서 사원 정보 가져오기
|
|
|
|
|
HttpSession session = request.getSession();
|
|
|
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
|
|
|
String empSeq = CommonUtils.checkNull(person.getEmpseq());
|
|
|
|
|
String compSeq = "1000";
|
|
|
|
|
|
|
|
|
|
String docId = CommonUtils.checkNull(paramMap.get("docId"));
|
|
|
|
|
String deptSeq = CommonUtils.checkNull(paramMap.get("deptSeq"));
|
|
|
|
|
|
|
|
|
|
System.out.println("=== Amaranth 결재 문서 상세 조회 ===");
|
|
|
|
|
System.out.println("empSeq: " + empSeq + ", docId: " + docId + ", deptSeq: " + deptSeq);
|
|
|
|
|
|
|
|
|
|
if(empSeq == null || empSeq.isEmpty()){
|
|
|
|
|
System.err.println("empSeq가 비어있습니다.");
|
|
|
|
|
return "{\"resultCode\":-1,\"resultMsg\":\"empSeq가 비어있습니다.\"}";
|
|
|
|
|
}
|
|
|
|
|
if(docId == null || docId.isEmpty()){
|
|
|
|
|
System.err.println("docId가 비어있습니다.");
|
|
|
|
|
return "{\"resultCode\":-1,\"resultMsg\":\"docId가 비어있습니다.\"}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// API 호출
|
|
|
|
|
com.pms.api.AmaranthApprovalApiClient apiClient = new com.pms.api.AmaranthApprovalApiClient();
|
|
|
|
|
String baseUrl = "https://erp.rps-korea.com";
|
|
|
|
|
|
|
|
|
|
String apiResponse = apiClient.getApprovalDocDetail(baseUrl, empSeq, compSeq, deptSeq, docId);
|
|
|
|
|
|
|
|
|
|
System.out.println("상세 조회 API 응답 길이: " + (apiResponse != null ? apiResponse.length() : 0) + " bytes");
|
|
|
|
|
|
|
|
|
|
return apiResponse;
|
|
|
|
|
|
|
|
|
|
} catch(Exception e){
|
|
|
|
|
System.err.println("Amaranth 결재 문서 상세 조회 오류: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return "{\"resultCode\":-1,\"resultMsg\":\"" + escapeJsonValue(e.getMessage()) + "\"}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 결재 문서 목록 결과를 JSON 문자열로 변환
|
|
|
|
|
*/
|
|
|
|
|
private String buildApprovalDocListJson(Map<String, Object> resultMap){
|
|
|
|
|
StringBuilder json = new StringBuilder();
|
|
|
|
|
json.append("{");
|
|
|
|
|
|
|
|
|
|
// 페이징 정보
|
|
|
|
|
json.append("\"totalCount\":").append(resultMap.get("TOTAL_COUNT")).append(",");
|
|
|
|
|
json.append("\"maxPage\":").append(resultMap.get("MAX_PAGE_SIZE")).append(",");
|
|
|
|
|
json.append("\"nextPage\":").append(resultMap.get("NEXT_PAGE")).append(",");
|
|
|
|
|
json.append("\"prevPage\":").append(resultMap.get("PREV_PAGE")).append(",");
|
|
|
|
|
|
|
|
|
|
// 문서 리스트
|
|
|
|
|
json.append("\"list\":[");
|
|
|
|
|
ArrayList<HashMap<String, Object>> list = (ArrayList<HashMap<String, Object>>) resultMap.get("LIST");
|
|
|
|
|
if(list != null){
|
|
|
|
|
for(int i = 0; i < list.size(); i++){
|
|
|
|
|
if(i > 0) json.append(",");
|
|
|
|
|
HashMap<String, Object> doc = list.get(i);
|
|
|
|
|
json.append("{");
|
|
|
|
|
json.append("\"RNUM\":\"").append(escapeJsonValue(String.valueOf(doc.get("RNUM")))).append("\",");
|
|
|
|
|
json.append("\"DOC_ID\":\"").append(escapeJsonValue(String.valueOf(doc.get("DOC_ID")))).append("\",");
|
|
|
|
|
json.append("\"DOC_TITLE\":\"").append(escapeJsonValue(String.valueOf(doc.get("DOC_TITLE")))).append("\",");
|
|
|
|
|
json.append("\"FORM_NAME\":\"").append(escapeJsonValue(String.valueOf(doc.get("FORM_NAME")))).append("\",");
|
|
|
|
|
json.append("\"EMP_NAME\":\"").append(escapeJsonValue(String.valueOf(doc.get("EMP_NAME")))).append("\",");
|
|
|
|
|
json.append("\"DEPT_NAME\":\"").append(escapeJsonValue(String.valueOf(doc.get("DEPT_NAME")))).append("\",");
|
|
|
|
|
json.append("\"DOC_STS_NAME\":\"").append(escapeJsonValue(String.valueOf(doc.get("DOC_STS_NAME")))).append("\",");
|
|
|
|
|
json.append("\"REP_DT\":\"").append(escapeJsonValue(String.valueOf(doc.get("REP_DT")))).append("\",");
|
|
|
|
|
json.append("\"DOC_STS\":\"").append(escapeJsonValue(String.valueOf(doc.get("DOC_STS")))).append("\",");
|
|
|
|
|
json.append("\"DEPT_SEQ\":\"").append(escapeJsonValue(String.valueOf(doc.get("DEPT_SEQ")))).append("\"");
|
|
|
|
|
json.append("}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
json.append("]");
|
|
|
|
|
json.append("}");
|
|
|
|
|
|
|
|
|
|
return json.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* JSON 값 이스케이프 (서비스 내부용)
|
|
|
|
|
*/
|
|
|
|
|
private String escapeJsonValue(String value){
|
|
|
|
|
if(value == null || "null".equals(value)) return "";
|
|
|
|
|
return value.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Amaranth10 전자결재 문서 목록 조회 (서버 인증 방식)
|
|
|
|
|
* @param request HttpServletRequest
|
|
|
|
|
* @param paramMap 검색 파라미터 (search_approvalTitle, search_fromDate, search_toDate, page 등)
|
|
|
|
|
* @return 결재 문서 목록 및 페이징 정보
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getAmaranthApprovalDocList(HttpServletRequest request, Map paramMap){
|
|
|
|
|
Map<String, Object> resultMap = new HashMap();
|
|
|
|
|
ArrayList<HashMap<String, Object>> resultList = new ArrayList();
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
// 세션에서 사원 정보 가져오기
|
|
|
|
|
HttpSession session = request.getSession();
|
|
|
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
|
|
|
String empSeq = CommonUtils.checkNull(person.getEmpseq());
|
|
|
|
|
String compSeq = "1000"; // 회사 시퀀스
|
|
|
|
|
|
|
|
|
|
System.out.println("=== Amaranth 결재 문서 목록 조회 ===");
|
|
|
|
|
System.out.println("empSeq: " + empSeq);
|
|
|
|
|
|
|
|
|
|
if(empSeq == null || empSeq.isEmpty()){
|
|
|
|
|
System.err.println("empSeq가 비어있습니다. LoginId 업데이트 배치를 먼저 실행하세요.");
|
|
|
|
|
resultMap.put("LIST", resultList);
|
|
|
|
|
resultMap.put("TOTAL_COUNT", 0);
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 검색 조건 매핑
|
|
|
|
|
String keyWord = CommonUtils.checkNull(paramMap.get("search_approvalTitle"));
|
|
|
|
|
String fromDt = CommonUtils.checkNull(paramMap.get("search_fromDate"));
|
|
|
|
|
String toDt = CommonUtils.checkNull(paramMap.get("search_toDate"));
|
|
|
|
|
String page = CommonUtils.checkNull(paramMap.get("page"), "1");
|
|
|
|
|
String pageSize = "20";
|
|
|
|
|
|
|
|
|
|
// menuId: 기안함(1000400) - 결재 전체 목록 조회용
|
|
|
|
|
String menuId = CommonUtils.checkNull(paramMap.get("menuId"), "1000400");
|
|
|
|
|
|
|
|
|
|
// API 호출
|
|
|
|
|
com.pms.api.AmaranthApprovalApiClient apiClient = new com.pms.api.AmaranthApprovalApiClient();
|
|
|
|
|
String baseUrl = "https://erp.rps-korea.com";
|
|
|
|
|
|
|
|
|
|
String apiResponse = apiClient.getApprovalDocList(
|
|
|
|
|
baseUrl, empSeq, compSeq, menuId, fromDt, toDt, keyWord, page, pageSize);
|
|
|
|
|
|
|
|
|
|
System.out.println("API 응답 길이: " + (apiResponse != null ? apiResponse.length() : 0) + " bytes");
|
|
|
|
|
|
|
|
|
|
// JSON 파싱
|
|
|
|
|
resultList = parseApprovalDocList(apiResponse);
|
|
|
|
|
int totalCnt = extractTotalCnt(apiResponse);
|
|
|
|
|
|
|
|
|
|
// 번호 매기기 (RNUM)
|
|
|
|
|
int startNum = (Integer.parseInt(page) - 1) * Integer.parseInt(pageSize);
|
|
|
|
|
for(int i = 0; i < resultList.size(); i++){
|
|
|
|
|
resultList.get(i).put("RNUM", String.valueOf(startNum + i + 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 페이징 정보 설정
|
|
|
|
|
int currentPage = Integer.parseInt(page);
|
|
|
|
|
int pageSizeInt = Integer.parseInt(pageSize);
|
|
|
|
|
int maxPage = (int) Math.ceil((double) totalCnt / pageSizeInt);
|
|
|
|
|
if(maxPage < 1) maxPage = 1;
|
|
|
|
|
|
|
|
|
|
resultMap.put("LIST", resultList);
|
|
|
|
|
resultMap.put("TOTAL_COUNT", totalCnt);
|
|
|
|
|
resultMap.put("MAX_PAGE_SIZE", maxPage);
|
|
|
|
|
resultMap.put("NEXT_PAGE", Math.min(currentPage + 1, maxPage));
|
|
|
|
|
resultMap.put("PREV_PAGE", Math.max(currentPage - 1, 1));
|
|
|
|
|
|
|
|
|
|
System.out.println("결재 문서 수: " + resultList.size() + ", 전체: " + totalCnt);
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
System.err.println("Amaranth 결재 문서 목록 조회 오류: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultMap.put("LIST", resultList);
|
|
|
|
|
resultMap.put("TOTAL_COUNT", 0);
|
|
|
|
|
resultMap.put("MAX_PAGE_SIZE", 1);
|
|
|
|
|
resultMap.put("NEXT_PAGE", 1);
|
|
|
|
|
resultMap.put("PREV_PAGE", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API 응답에서 eaDocList 배열 파싱
|
|
|
|
|
* 응답 구조: {"resultData":{"eaDocList":[{...},{...}],"totalCnt":94}}
|
|
|
|
|
*/
|
|
|
|
|
private ArrayList<HashMap<String, Object>> parseApprovalDocList(String jsonResponse){
|
|
|
|
|
ArrayList<HashMap<String, Object>> list = new ArrayList();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// eaDocList 배열 찾기
|
|
|
|
|
int eaDocListIndex = jsonResponse.indexOf("\"eaDocList\"");
|
|
|
|
|
if(eaDocListIndex == -1){
|
|
|
|
|
System.err.println("eaDocList를 찾을 수 없습니다.");
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eaDocList 다음의 [ 찾기
|
|
|
|
|
int arrayStart = jsonResponse.indexOf("[", eaDocListIndex);
|
|
|
|
|
if(arrayStart == -1){
|
|
|
|
|
System.err.println("eaDocList 배열 시작을 찾을 수 없습니다.");
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 대응하는 ] 찾기
|
|
|
|
|
int bracketCount = 0;
|
|
|
|
|
int arrayEnd = -1;
|
|
|
|
|
for(int i = arrayStart; i < jsonResponse.length(); i++){
|
|
|
|
|
char c = jsonResponse.charAt(i);
|
|
|
|
|
if(c == '[') bracketCount++;
|
|
|
|
|
else if(c == ']') bracketCount--;
|
|
|
|
|
|
|
|
|
|
if(bracketCount == 0){
|
|
|
|
|
arrayEnd = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(arrayEnd == -1){
|
|
|
|
|
System.err.println("eaDocList 배열 끝을 찾을 수 없습니다.");
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String arrayStr = jsonResponse.substring(arrayStart + 1, arrayEnd);
|
|
|
|
|
|
|
|
|
|
// 각 문서 객체 파싱
|
|
|
|
|
int searchFrom = 0;
|
|
|
|
|
while(searchFrom < arrayStr.length()){
|
|
|
|
|
int objStart = arrayStr.indexOf("{", searchFrom);
|
|
|
|
|
if(objStart == -1) break;
|
|
|
|
|
|
|
|
|
|
// 중첩 { } 처리
|
|
|
|
|
int braceCount = 0;
|
|
|
|
|
int objEnd = -1;
|
|
|
|
|
for(int i = objStart; i < arrayStr.length(); i++){
|
|
|
|
|
char c = arrayStr.charAt(i);
|
|
|
|
|
if(c == '{') braceCount++;
|
|
|
|
|
else if(c == '}') braceCount--;
|
|
|
|
|
|
|
|
|
|
if(braceCount == 0){
|
|
|
|
|
objEnd = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(objEnd == -1) break;
|
|
|
|
|
|
|
|
|
|
String objStr = arrayStr.substring(objStart, objEnd + 1);
|
|
|
|
|
HashMap<String, Object> doc = parseDocObject(objStr);
|
|
|
|
|
if(!doc.isEmpty()){
|
|
|
|
|
list.add(doc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchFrom = objEnd + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("파싱된 문서 수: " + list.size());
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println("eaDocList 파싱 오류: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 개별 문서 JSON 객체 파싱
|
|
|
|
|
*/
|
|
|
|
|
private HashMap<String, Object> parseDocObject(String objStr){
|
|
|
|
|
HashMap<String, Object> doc = new HashMap();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
doc.put("DOC_ID", extractJsonStringValue(objStr, "docId"));
|
|
|
|
|
doc.put("DOC_TITLE", extractJsonStringValue(objStr, "docTitle"));
|
|
|
|
|
doc.put("FORM_NAME", extractJsonStringValue(objStr, "formName"));
|
|
|
|
|
doc.put("EMP_NAME", extractJsonStringValue(objStr, "empName"));
|
|
|
|
|
doc.put("DEPT_NAME", extractJsonStringValue(objStr, "deptName"));
|
|
|
|
|
doc.put("DOC_STS", extractJsonStringValue(objStr, "docSts"));
|
|
|
|
|
doc.put("DOC_STS_NAME", extractJsonStringValue(objStr, "docStsName"));
|
|
|
|
|
doc.put("POSITION_NAME", extractJsonStringValue(objStr, "positionName"));
|
|
|
|
|
doc.put("DUTY_NAME", extractJsonStringValue(objStr, "dutyName"));
|
|
|
|
|
doc.put("LINE_NAME", extractJsonStringValue(objStr, "lineName"));
|
|
|
|
|
doc.put("ATTACH_CNT", extractJsonStringValue(objStr, "attachCnt"));
|
|
|
|
|
doc.put("COMMENT_CNT", extractJsonStringValue(objStr, "commentCnt"));
|
|
|
|
|
doc.put("EMERGENCY_FLAG", extractJsonStringValue(objStr, "emergencyFlag"));
|
|
|
|
|
doc.put("DELAY_FLAG", extractJsonStringValue(objStr, "delayFlag"));
|
|
|
|
|
doc.put("READ_YN", extractJsonStringValue(objStr, "readYN"));
|
|
|
|
|
doc.put("APP_YN", extractJsonStringValue(objStr, "appYN"));
|
|
|
|
|
doc.put("COMP_SEQ", extractJsonStringValue(objStr, "compSeq"));
|
|
|
|
|
doc.put("EMP_SEQ", extractJsonStringValue(objStr, "empSeq"));
|
|
|
|
|
doc.put("DEPT_SEQ", extractJsonStringValue(objStr, "deptSeq"));
|
|
|
|
|
|
|
|
|
|
// 상신일(repDt) 포맷팅: YYYYMMDDHHMISS → YYYY-MM-DD
|
|
|
|
|
String repDt = extractJsonStringValue(objStr, "repDt");
|
|
|
|
|
if(repDt != null && repDt.length() >= 8){
|
|
|
|
|
doc.put("REP_DT", repDt.substring(0, 4) + "-" + repDt.substring(4, 6) + "-" + repDt.substring(6, 8));
|
|
|
|
|
} else {
|
|
|
|
|
doc.put("REP_DT", repDt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 생성일(createdDt) 포맷팅
|
|
|
|
|
String createdDt = extractJsonStringValue(objStr, "createdDt");
|
|
|
|
|
if(createdDt != null && createdDt.length() >= 8){
|
|
|
|
|
doc.put("CREATED_DT", createdDt.substring(0, 4) + "-" + createdDt.substring(4, 6) + "-" + createdDt.substring(6, 8));
|
|
|
|
|
} else {
|
|
|
|
|
doc.put("CREATED_DT", createdDt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println("문서 객체 파싱 오류: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* JSON 문자열에서 특정 키의 문자열 값 추출
|
|
|
|
|
*/
|
|
|
|
|
private String extractJsonStringValue(String json, String key){
|
|
|
|
|
String searchKey = "\"" + key + "\"";
|
|
|
|
|
int keyIndex = json.indexOf(searchKey);
|
|
|
|
|
if(keyIndex == -1) return "";
|
|
|
|
|
|
|
|
|
|
int colonIndex = json.indexOf(":", keyIndex + searchKey.length());
|
|
|
|
|
if(colonIndex == -1) return "";
|
|
|
|
|
|
|
|
|
|
// 콜론 뒤의 공백 건너뛰기
|
|
|
|
|
int valueStart = colonIndex + 1;
|
|
|
|
|
while(valueStart < json.length() && json.charAt(valueStart) == ' '){
|
|
|
|
|
valueStart++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(valueStart >= json.length()) return "";
|
|
|
|
|
|
|
|
|
|
// null 값 체크
|
|
|
|
|
if(json.substring(valueStart).startsWith("null")){
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 숫자 값 체크 (따옴표 없는 경우)
|
|
|
|
|
char firstChar = json.charAt(valueStart);
|
|
|
|
|
if(firstChar != '"'){
|
|
|
|
|
// 숫자나 boolean 값
|
|
|
|
|
int valueEnd = valueStart;
|
|
|
|
|
while(valueEnd < json.length()){
|
|
|
|
|
char c = json.charAt(valueEnd);
|
|
|
|
|
if(c == ',' || c == '}' || c == ']') break;
|
|
|
|
|
valueEnd++;
|
|
|
|
|
}
|
|
|
|
|
return json.substring(valueStart, valueEnd).trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 문자열 값 (따옴표 있는 경우)
|
|
|
|
|
int quoteStart = valueStart; // 이미 '"' 위치
|
|
|
|
|
int quoteEnd = json.indexOf("\"", quoteStart + 1);
|
|
|
|
|
if(quoteEnd == -1) return "";
|
|
|
|
|
|
|
|
|
|
return json.substring(quoteStart + 1, quoteEnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API 응답에서 totalCnt 추출
|
|
|
|
|
*/
|
|
|
|
|
private int extractTotalCnt(String jsonResponse){
|
|
|
|
|
try {
|
|
|
|
|
String searchKey = "\"totalCnt\"";
|
|
|
|
|
int keyIndex = jsonResponse.indexOf(searchKey);
|
|
|
|
|
if(keyIndex == -1) return 0;
|
|
|
|
|
|
|
|
|
|
int colonIndex = jsonResponse.indexOf(":", keyIndex + searchKey.length());
|
|
|
|
|
if(colonIndex == -1) return 0;
|
|
|
|
|
|
|
|
|
|
int valueStart = colonIndex + 1;
|
|
|
|
|
while(valueStart < jsonResponse.length() && jsonResponse.charAt(valueStart) == ' '){
|
|
|
|
|
valueStart++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int valueEnd = valueStart;
|
|
|
|
|
while(valueEnd < jsonResponse.length()){
|
|
|
|
|
char c = jsonResponse.charAt(valueEnd);
|
|
|
|
|
if(c == ',' || c == '}' || c == ']') break;
|
|
|
|
|
valueEnd++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String cntStr = jsonResponse.substring(valueStart, valueEnd).trim();
|
|
|
|
|
return Integer.parseInt(cntStr);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println("totalCnt 추출 오류: " + e.getMessage());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-29 15:46:08 +09:00
|
|
|
public ArrayList getApprovalLine(HttpServletRequest request, Map paramMap){
|
|
|
|
|
ArrayList<HashMap<String,Object>> resultList = new ArrayList();
|
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
try{
|
|
|
|
|
resultList = (ArrayList)sqlSession.selectList("approval.getApprovalLine",paramMap);
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
throw e;
|
|
|
|
|
}finally{
|
|
|
|
|
sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-03 17:19:22 +09:00
|
|
|
/**
|
|
|
|
|
* 결재완료 여부 확인 (견적서 메일 발송용)
|
|
|
|
|
* @param paramMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map checkApprovalComplete(Map paramMap){
|
|
|
|
|
Map<String,Object> resultMap = new HashMap();
|
|
|
|
|
SqlSession sqlSession = null;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
|
|
|
|
|
|
String approvalObjId = CommonUtils.checkNull(paramMap.get("approvalObjId"));
|
|
|
|
|
|
|
|
|
|
if(!"".equals(approvalObjId)){
|
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
|
|
|
sqlParamMap.put("approvalObjId", approvalObjId);
|
|
|
|
|
|
|
|
|
|
// 결재 정보 조회
|
|
|
|
|
Map approvalInfo = sqlSession.selectOne("approval.getApprovalInfo", sqlParamMap);
|
|
|
|
|
|
|
|
|
|
if(approvalInfo != null) {
|
|
|
|
|
approvalInfo = CommonUtils.toUpperCaseMapKey(approvalInfo);
|
|
|
|
|
String status = CommonUtils.checkNull(approvalInfo.get("STATUS"));
|
|
|
|
|
String targetType = CommonUtils.checkNull(approvalInfo.get("TARGET_TYPE"));
|
|
|
|
|
String targetObjId = CommonUtils.checkNull(approvalInfo.get("TARGET_OBJID"));
|
|
|
|
|
|
|
|
|
|
// 결재완료 상태인지 확인
|
|
|
|
|
if("complete".equals(status)) {
|
|
|
|
|
resultMap.put("isComplete", "Y");
|
|
|
|
|
|
|
|
|
|
// CONTRACT_ESTIMATE인 경우 CONTRACT_OBJID 조회
|
|
|
|
|
if("CONTRACT_ESTIMATE".equals(targetType)) {
|
|
|
|
|
Map estParam = new HashMap();
|
|
|
|
|
estParam.put("estObjId", targetObjId);
|
|
|
|
|
Map estInfo = sqlSession.selectOne("approval.getEstimateContractObjId", estParam);
|
|
|
|
|
|
|
|
|
|
if(estInfo != null) {
|
|
|
|
|
estInfo = CommonUtils.toUpperCaseMapKey(estInfo);
|
|
|
|
|
resultMap.put("contractObjId", CommonUtils.checkNull(estInfo.get("CONTRACT_OBJID")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("isComplete", "N");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("isComplete", "N");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
resultMap.put("isComplete", "N");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultMap.put("isComplete", "N");
|
|
|
|
|
}finally{
|
|
|
|
|
if(sqlSession != null) sqlSession.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-29 15:46:08 +09:00
|
|
|
}
|