- Add Docker Compose configurations for dev, prod, and standalone environments - Add database initialization scripts (init-db.sh, init-db-docker.sh) - Add enhanced start-docker-linux.sh with DB init support - Add comprehensive database initialization guide - Support for automatic dbexport.pgsql import on first run - Include safety checks for production environment
402 lines
12 KiB
Java
402 lines
12 KiB
Java
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.ibatis.session.SqlSession;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.pms.common.JsonUtil;
|
|
import com.pms.common.Message;
|
|
import com.pms.common.SqlMapConfig;
|
|
import com.pms.common.bean.PersonBean;
|
|
import com.pms.common.utils.CommonUtils;
|
|
import com.pms.common.utils.Constants;
|
|
|
|
@Service
|
|
public class AsService {
|
|
|
|
@Autowired
|
|
CommonService commonService;
|
|
|
|
/**
|
|
* AS 정보를 저장 한다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
// public void mergeAs(HttpServletRequest request, Map paramMap){
|
|
//
|
|
// SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
//
|
|
// List<Map<String, Object>> gridDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("jqGrid")));
|
|
// try{
|
|
// //EO 정보를 Merge 한다.
|
|
// sqlSession.update("as.mergeAS",paramMap);
|
|
// for(int i=0; i<gridDataList.size(); i++){
|
|
// Map insertMap = gridDataList.get(i);
|
|
// insertMap.put("OBJID", insertMap.get("OBJID"));
|
|
// insertMap.put("QTY", insertMap.get("QTY"));
|
|
// insertMap.put("PRICE", insertMap.get("PRICE"));
|
|
// insertMap.put("SUP_PRICE", insertMap.get("SUP_PRICE"));
|
|
// insertMap.put("NOTE", insertMap.get("NOTE"));
|
|
// System.out.println("insertMap--------------------->" +insertMap);
|
|
// sqlSession.update("as.updateAsPart", insertMap);
|
|
// }
|
|
// sqlSession.commit();
|
|
// }catch(Exception e){
|
|
// sqlSession.rollback();
|
|
// throw e;
|
|
// }finally{
|
|
// sqlSession.close();
|
|
// }
|
|
// }
|
|
public void mergeAs_CS(HttpServletRequest request, Map paramMap){
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
String MASTER_OBJID = CommonUtils.nullToEmpty((String)paramMap.get("objId"));
|
|
|
|
List<Map<String, Object>> jqGridPartDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("jqGridPart")));
|
|
List<Map<String, Object>> jqGridWorkDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("jqGridWork")));
|
|
|
|
//CUSTOMER_SERVICE_MGMT
|
|
sqlSession.update("as.mergeCSM",paramMap);
|
|
paramMap.put("PARENT_OBJID", MASTER_OBJID);
|
|
|
|
//CUSTOMER_SERVICE_PART
|
|
sqlSession.delete("as.deleteCSP", paramMap);
|
|
for(int i=0; i<jqGridPartDataList.size(); i++){
|
|
Map insertMap = jqGridPartDataList.get(i);
|
|
insertMap.put("OBJID" , CommonUtils.createObjId());
|
|
insertMap.put("PARENT_OBJID", MASTER_OBJID);
|
|
sqlSession.update("as.mergeCSP", insertMap);
|
|
}
|
|
|
|
//CUSTOMER_SERVICE_WORKINGTIME
|
|
sqlSession.delete("as.deleteCSW", paramMap);
|
|
for(int i=0; i<jqGridWorkDataList.size(); i++){
|
|
Map insertMap = jqGridWorkDataList.get(i);
|
|
insertMap.put("OBJID" , CommonUtils.createObjId());
|
|
insertMap.put("PARENT_OBJID", MASTER_OBJID);
|
|
sqlSession.update("as.mergeCSW", insertMap);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
/**
|
|
* AS의 목록을 가져온다.(페이징 O)
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getAsTotalList(HttpServletRequest request, Map paramMap){
|
|
ArrayList eoList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
|
|
eoList = (ArrayList)sqlSession.selectList("as.getAsTotalList",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return eoList;
|
|
}
|
|
|
|
/**
|
|
* AS의 목록을 가져온다.(페이징 O)
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getAsListPaging(HttpServletRequest request, Map paramMap){
|
|
ArrayList eoList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
HashMap pageMap = new HashMap();
|
|
try{
|
|
|
|
System.out.println("paramMap :: " + paramMap);
|
|
|
|
// String warranty_code = CommonUtils.checkNull(paramMap.get("warranty_code"));
|
|
// if(!"".equals(warranty_code)){
|
|
// if("0000157".equals(warranty_code)){
|
|
// paramMap.put("warranty","Y");
|
|
// }else if("0000158".equals(warranty_code)){
|
|
// paramMap.put("warranty","N");
|
|
// }
|
|
//
|
|
// }
|
|
|
|
|
|
String page = CommonUtils.checkNull(request.getParameter("page"));
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), ""+Constants.ADMIN_COUNT_PER_PAGE+"");
|
|
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
pageMap = (HashMap)sqlSession.selectOne("as.getECRListCnt", 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")));
|
|
|
|
eoList = (ArrayList)sqlSession.selectList("as.getECRListPaging",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return eoList;
|
|
}
|
|
|
|
/**
|
|
* ECR의 단건 정보를 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public HashMap getAsInfo(HttpServletRequest request, Map paramMap){
|
|
HashMap eoMap = new HashMap();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
eoMap = sqlSession.selectOne("as.getECRInfo",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return eoMap;
|
|
}
|
|
|
|
/**
|
|
* ECR의 결재 정보를 가져온다.
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public ArrayList getAsApprovalList(HttpServletRequest request, Map paramMap){
|
|
ArrayList resultList = new ArrayList();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
try{
|
|
resultList = (ArrayList)sqlSession.selectList("as.getEOApprovalList",paramMap);
|
|
}catch(Exception e){
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* ecr 삭제
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
// public Map asDelete(HttpServletRequest request,Map paramMap){
|
|
// Map resultMap = new HashMap();
|
|
// SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
// try{
|
|
// String partCheckBoxList[] = request.getParameter("ecrobjid").split(",");
|
|
// if(null != partCheckBoxList && 0 < partCheckBoxList.length){
|
|
// for(int i=0;i<partCheckBoxList.length;i++){
|
|
// String Objid = CommonUtils.checkNull(partCheckBoxList[i]);
|
|
// HashMap sqlParamMap = new HashMap();
|
|
// sqlParamMap.put("objId", Objid);
|
|
// //제품마스터 삭제
|
|
// sqlSession.delete("as.asDelete",sqlParamMap);
|
|
// }
|
|
// sqlSession.commit();
|
|
// resultMap.put("result", true);
|
|
// resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
// }
|
|
// }catch(Exception e){
|
|
// resultMap.put("result", false);
|
|
// resultMap.put("msg", Message.DELETE_FAILED);
|
|
// sqlSession.rollback();
|
|
// throw e;
|
|
// }finally{
|
|
// sqlSession.close();
|
|
// }
|
|
// return resultMap;
|
|
// }
|
|
public Map asDelete(HttpServletRequest request,Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
String arrObjIds[] = request.getParameter("objIds").split(",");
|
|
if(null != arrObjIds && 0 < arrObjIds.length){
|
|
for(int i=0;i<arrObjIds.length;i++){
|
|
String Objid = CommonUtils.checkNull(arrObjIds[i]);
|
|
HashMap sqlParamMap = new HashMap();
|
|
sqlParamMap.put("OBJID", Objid);
|
|
sqlParamMap.put("PARENT_OBJID", Objid);
|
|
//CUSTOMER_SERVICE_MGMT
|
|
sqlSession.delete("as.deleteCSM", sqlParamMap);
|
|
//CUSTOMER_SERVICE_PART
|
|
sqlSession.delete("as.deleteCSP", sqlParamMap);
|
|
//CUSTOMER_SERVICE_WORKINGTIME
|
|
sqlSession.delete("as.deleteCSW", sqlParamMap);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.DELETE_SUCCESS);
|
|
}
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.DELETE_FAILED);
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* PART 조회및 배포
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getPartMngList(HttpServletRequest request,Map paramMap){
|
|
List<Map<String,Object>> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = (ArrayList)sqlSession.selectList("as.partMngList", paramMap);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return CommonUtils.toUpperCaseMapKey(resultList);
|
|
}
|
|
|
|
|
|
/**
|
|
* part를 연결한다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void addPartMng(HttpServletRequest request, Map paramMap){
|
|
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
try{
|
|
|
|
System.out.println("paramMap:"+paramMap);
|
|
|
|
// sqlSession.update("eoMng.relEOMngPartMngInit",paramMap);
|
|
|
|
|
|
String partObjIdArr[] = request.getParameter("PART_OBJID").split(",");
|
|
String priceObjIdArr[] = request.getParameter("PRICE").split(",");
|
|
|
|
|
|
HttpSession session = request.getSession();
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
|
String personId = CommonUtils.checkNull(person.getUserId());
|
|
|
|
if(null != partObjIdArr && 0 < partObjIdArr.length){
|
|
for(int i=0;i<partObjIdArr.length;i++){
|
|
String partobjid = CommonUtils.checkNull(partObjIdArr[i]);
|
|
String price = CommonUtils.checkNull(priceObjIdArr[i]);
|
|
HashMap sqlParamMap = new HashMap();
|
|
sqlParamMap.put("objId", CommonUtils.createObjId());
|
|
sqlParamMap.put("target_objid", CommonUtils.checkNull(paramMap.get("TARGETOBJID")));
|
|
sqlParamMap.put("part_objid", partobjid);
|
|
sqlParamMap.put("price", price);
|
|
|
|
System.out.println("sqlParamMap : " + sqlParamMap);
|
|
|
|
//Relation에 정보를 입력한다.
|
|
sqlSession.insert("as.insertASPartMng",sqlParamMap);
|
|
}
|
|
sqlSession.commit();
|
|
}
|
|
}catch(Exception e){
|
|
sqlSession.rollback();
|
|
throw e;
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
}
|
|
|
|
|
|
public List searchPartMgmt(HttpServletRequest request,Map paramMap){
|
|
List<Map> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("as.materpartMgmtList", paramMap));
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* ES SPEC에 따른 헤더 구성을 위한 목록을 설정한다.
|
|
* @param request
|
|
* @param paramMap
|
|
*/
|
|
public void getHeaderList(HttpServletRequest request, Map paramMap){
|
|
List<Map> headerList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
|
|
Map param = new HashMap();
|
|
param.put("code", "0000970");
|
|
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
headerList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("as.getHeaderList", param));
|
|
|
|
System.out.println("getHeaderList(headerList):"+headerList);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
paramMap.put("columnList", headerList);
|
|
|
|
request.setAttribute("columnList", headerList);
|
|
}
|
|
|
|
/**
|
|
* 투자비 제품금형비 목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getASDashboardList(HttpServletRequest request,Map paramMap){
|
|
List<Map> resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = CommonUtils.keyChangeUpperList((ArrayList)sqlSession.selectList("as.getASDashboardList", paramMap));
|
|
|
|
System.out.println("getASDashboardList(resultList):"+resultList);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
}
|