767 lines
23 KiB
Java
767 lines
23 KiB
Java
|
|
package com.pms.service;
|
||
|
|
|
||
|
|
import java.io.File;
|
||
|
|
import java.io.FileInputStream;
|
||
|
|
import java.io.FileOutputStream;
|
||
|
|
import java.net.URLDecoder;
|
||
|
|
import java.net.URLEncoder;
|
||
|
|
import java.text.SimpleDateFormat;
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.Calendar;
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
import java.util.zip.ZipEntry;
|
||
|
|
import java.util.zip.ZipOutputStream;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpSession;
|
||
|
|
|
||
|
|
import org.apache.ibatis.session.SqlSession;
|
||
|
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||
|
|
import org.apache.pdfbox.text.PDFTextStripper;
|
||
|
|
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;
|
||
|
|
|
||
|
|
@Service
|
||
|
|
public class EOService {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
CommonService commonService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EO 정보를 merge 한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
*/
|
||
|
|
public void mergeEO(HttpServletRequest request, Map paramMap){
|
||
|
|
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
|
||
|
|
String objid = CommonUtils.checkNull(paramMap.get("objId"));
|
||
|
|
String actionType = CommonUtils.checkNull(paramMap.get("actionType"));
|
||
|
|
//EO 정보를 Merge 한다.
|
||
|
|
sqlSession.update("eo.mergeEO",paramMap);
|
||
|
|
|
||
|
|
//EO의 object id를 가진 Part의 EO 정보를 Update 한다.
|
||
|
|
sqlSession.update("eo.updateConnectedPartEOInfo",paramMap);
|
||
|
|
|
||
|
|
sqlSession.commit();
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* part를 연결한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
*/
|
||
|
|
public void connectPart(HttpServletRequest request, Map paramMap){
|
||
|
|
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
String objId = CommonUtils.checkNull(paramMap.get("eoObjId"));
|
||
|
|
String partObjIdList[] = request.getParameterValues("partObjId");
|
||
|
|
|
||
|
|
HttpSession session = request.getSession();
|
||
|
|
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||
|
|
String personId = CommonUtils.checkNull(person.getUserId());
|
||
|
|
|
||
|
|
HashMap eoMap = new HashMap();
|
||
|
|
paramMap.put("objId", objId);
|
||
|
|
eoMap = getEOInfo(request, paramMap);
|
||
|
|
|
||
|
|
if(null != partObjIdList && 0 < partObjIdList.length){
|
||
|
|
for(int i=0;i<partObjIdList.length;i++){
|
||
|
|
String partObjId = CommonUtils.checkNull(partObjIdList[i]);
|
||
|
|
if(!"".equals(partObjId)){
|
||
|
|
HashMap sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("objId", CommonUtils.createObjId());
|
||
|
|
sqlParamMap.put("eoObjId", objId);
|
||
|
|
sqlParamMap.put("partObjId", partObjId);
|
||
|
|
sqlParamMap.put("writer", personId);
|
||
|
|
sqlParamMap.put("eoNo", CommonUtils.checkNull(eoMap.get("EO_NO")));
|
||
|
|
sqlParamMap.put("eoIssueDate", CommonUtils.checkNull(eoMap.get("EO_ISSUE_DATE")));
|
||
|
|
sqlSession.update("eo.connectPart",sqlParamMap);
|
||
|
|
sqlSession.update("eo.updateEOObjId",sqlParamMap);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
sqlSession.commit();
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* part 연결을 해제한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
*/
|
||
|
|
public void disConnectPart(HttpServletRequest request, Map paramMap){
|
||
|
|
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||
|
|
String partObjIdList[] = request.getParameterValues("connectedPart");
|
||
|
|
|
||
|
|
if(null != partObjIdList && 0 < partObjIdList.length){
|
||
|
|
for(int i=0;i<partObjIdList.length;i++){
|
||
|
|
String partObjId = CommonUtils.checkNull(partObjIdList[i]);
|
||
|
|
if(!"".equals(partObjId)){
|
||
|
|
HashMap sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("eoObjId", objId);
|
||
|
|
sqlParamMap.put("partObjId", partObjId);
|
||
|
|
sqlSession.update("eo.disConnectPart",sqlParamMap);
|
||
|
|
sqlParamMap.put("eoObjId", "");
|
||
|
|
sqlParamMap.put("eoNo", "");
|
||
|
|
sqlParamMap.put("eoIssueDate", "");
|
||
|
|
sqlSession.update("eo.updateEOObjId",sqlParamMap);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
sqlSession.commit();
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EO를 삭제한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
*/
|
||
|
|
public void deleteEO(HttpServletRequest request, Map paramMap){
|
||
|
|
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
try{
|
||
|
|
sqlSession.update("eo.deleteEO",paramMap);
|
||
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||
|
|
|
||
|
|
paramMap.put("eoObjId", objId);
|
||
|
|
sqlSession.update("eo.disConnectAllPart",paramMap);
|
||
|
|
sqlSession.update("eo.deleteEORelPartInfo",paramMap);
|
||
|
|
|
||
|
|
sqlSession.commit();
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EO와 연결된 part목록을 가져온다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
*/
|
||
|
|
public ArrayList getConnectPartList(HttpServletRequest request, Map paramMap){
|
||
|
|
ArrayList resultList = new ArrayList();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
try{
|
||
|
|
paramMap.put("isStartDevPart", "1");
|
||
|
|
resultList = (ArrayList)sqlSession.selectList("eo.getConnectPartList",paramMap);
|
||
|
|
}catch(Exception e){
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return resultList;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EO의 목록을 가져온다.(페이징 O)
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public ArrayList getEOListPaging(HttpServletRequest request, Map paramMap){
|
||
|
|
ArrayList eoList = new ArrayList();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
HashMap pageMap = new HashMap();
|
||
|
|
try{
|
||
|
|
|
||
|
|
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("eo.getEOListCnt", 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("eo.getEOListPaging",paramMap);
|
||
|
|
}catch(Exception e){
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return eoList;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EO의 단건 정보를 가져온다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public HashMap getEOInfo(HttpServletRequest request, Map paramMap){
|
||
|
|
HashMap eoMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
try{
|
||
|
|
eoMap = sqlSession.selectOne("eo.getEOInfo",paramMap);
|
||
|
|
}catch(Exception e){
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return eoMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EO의 결재 정보를 가져온다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public ArrayList getEOApprovalList(HttpServletRequest request, Map paramMap){
|
||
|
|
ArrayList resultList = new ArrayList();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
try{
|
||
|
|
resultList = (ArrayList)sqlSession.selectList("eo.getEOApprovalList",paramMap);
|
||
|
|
}catch(Exception e){
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return resultList;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* pdf 파일을 parsing하여 데이터를 추출한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public HashMap pdfDataPatser(HttpServletRequest request, Map paramMap){
|
||
|
|
String content = "";
|
||
|
|
HashMap pdfEOMap = new HashMap();
|
||
|
|
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||
|
|
|
||
|
|
try{
|
||
|
|
|
||
|
|
ArrayList fileList = commonService.getFileList(paramMap);
|
||
|
|
|
||
|
|
String savePath = "";
|
||
|
|
String realFileName = "";
|
||
|
|
String savedFileName = "";
|
||
|
|
String src = "";
|
||
|
|
String fileObjectId = "";
|
||
|
|
String fileExt = "";
|
||
|
|
if(null != fileList && 0 < fileList.size()){
|
||
|
|
for(int i=0;i<fileList.size();i++){
|
||
|
|
HashMap fileMap = new HashMap();
|
||
|
|
fileMap = (HashMap)fileList.get(i);
|
||
|
|
realFileName = CommonUtils.checkNull(fileMap.get("REAL_FILE_NAME"));
|
||
|
|
savedFileName = CommonUtils.checkNull(fileMap.get("SAVED_FILE_NAME"));
|
||
|
|
savePath = CommonUtils.checkNull(fileMap.get("FILE_PATH"));
|
||
|
|
fileObjectId = CommonUtils.checkNull(fileMap.get("OBJID"));
|
||
|
|
fileExt = CommonUtils.checkNull(fileMap.get("FILE_EXT"));
|
||
|
|
}
|
||
|
|
|
||
|
|
if("" != realFileName || "" != savedFileName || "" != savePath){
|
||
|
|
src = savePath+File.separator+savedFileName;
|
||
|
|
}else{
|
||
|
|
return pdfEOMap;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
File file = new File(src);
|
||
|
|
int idx = realFileName.lastIndexOf(".");
|
||
|
|
String designTeam = CommonUtils.checkNull(realFileName.substring(0, idx));
|
||
|
|
|
||
|
|
pdfEOMap.put("designTeam",designTeam);
|
||
|
|
|
||
|
|
PDDocument document = PDDocument.load(file);
|
||
|
|
PDFTextStripper s = new PDFTextStripper();
|
||
|
|
content = s.getText(document);
|
||
|
|
|
||
|
|
content = content.replaceAll("\n", "!!");
|
||
|
|
|
||
|
|
String[] resultList = content.split("!!");
|
||
|
|
|
||
|
|
int eoDateCount = 0;
|
||
|
|
int eoCount = 0;
|
||
|
|
|
||
|
|
for(int i=0;i<resultList.length;i++){
|
||
|
|
String listVal = resultList[i].toString();
|
||
|
|
|
||
|
|
//EO 부분에 개행안된 경우
|
||
|
|
if(listVal.contains("EO NO :") && listVal.contains("(EO") && 0 == eoCount){
|
||
|
|
listVal = listVal.replaceAll("EO NO :", "");
|
||
|
|
int symbolIdx = listVal.indexOf("(");
|
||
|
|
|
||
|
|
String putVal = "";
|
||
|
|
putVal = listVal.substring(0, symbolIdx);
|
||
|
|
|
||
|
|
pdfEOMap.put("eoNo", CommonUtils.checkNull(putVal.trim()));
|
||
|
|
|
||
|
|
eoCount++;
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
//EO 부분이 개행된 경우
|
||
|
|
if(listVal.contains("EO NO :") && !listVal.contains("(EO") && 0 == eoCount){
|
||
|
|
pdfEOMap.put("eoNo", CommonUtils.checkNull(resultList[i+1].toString().trim()));
|
||
|
|
eoCount++;
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
SimpleDateFormat sdfOrg = new SimpleDateFormat("yyyyMMdd");
|
||
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
|
|
|
||
|
|
if(listVal.contains("DATE :") && listVal.contains("(") && (0 == eoDateCount)){
|
||
|
|
listVal = listVal.replaceAll("DATE :", "");
|
||
|
|
listVal = listVal.replaceFirst(" ", "");
|
||
|
|
String eoDate = listVal.substring(0, 8);
|
||
|
|
|
||
|
|
Date tempEODate = sdfOrg.parse(eoDate);
|
||
|
|
|
||
|
|
pdfEOMap.put("carCode", listVal.replaceAll(eoDate, ""));
|
||
|
|
|
||
|
|
if("" != CommonUtils.checkNull(eoDate)){
|
||
|
|
eoDate = sdf.format(tempEODate);
|
||
|
|
}
|
||
|
|
|
||
|
|
pdfEOMap.put("eoDate", eoDate);
|
||
|
|
|
||
|
|
if(resultList[i+2].toString().contains("○")){
|
||
|
|
pdfEOMap.put("emergencyLvl", "normal");
|
||
|
|
}
|
||
|
|
|
||
|
|
if(resultList[i+2].toString().contains("●")){
|
||
|
|
pdfEOMap.put("emergencyLvl", "emergency");
|
||
|
|
}
|
||
|
|
|
||
|
|
eoDateCount++;
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
if(listVal.contains("DATE :") && !listVal.contains("\\(") && (0 == eoDateCount)){
|
||
|
|
|
||
|
|
String eoDate = CommonUtils.checkNull(resultList[i+1].toString().trim());
|
||
|
|
|
||
|
|
Date tempEODate = sdfOrg.parse(eoDate);
|
||
|
|
|
||
|
|
if("" != CommonUtils.checkNull(eoDate)){
|
||
|
|
eoDate = sdf.format(tempEODate);
|
||
|
|
}
|
||
|
|
|
||
|
|
pdfEOMap.put("eoDate", eoDate);
|
||
|
|
pdfEOMap.put("carCode", CommonUtils.checkNull(resultList[i+2].toString().trim()));
|
||
|
|
|
||
|
|
if(resultList[i+4].toString().contains("○")){
|
||
|
|
pdfEOMap.put("emergencyLvl", "normal");
|
||
|
|
}
|
||
|
|
|
||
|
|
if(resultList[i+4].toString().contains("●")){
|
||
|
|
pdfEOMap.put("emergencyLvl", "emergency");
|
||
|
|
}
|
||
|
|
|
||
|
|
eoDateCount++;
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
String carCode = CommonUtils.checkNull(pdfEOMap.get("carCode"));
|
||
|
|
String[] carCodeList = carCode.split("\\)");
|
||
|
|
|
||
|
|
for(int j=0;j<carCodeList.length;j++){
|
||
|
|
String carCodeVal = (String)carCodeList[j];
|
||
|
|
|
||
|
|
if(carCodeVal.contains("●")){
|
||
|
|
pdfEOMap.put("eoType", "regular");
|
||
|
|
}else if(carCodeVal.contains("○")){
|
||
|
|
pdfEOMap.put("eoType", "tempApp");
|
||
|
|
}else{
|
||
|
|
carCodeVal = carCodeVal.replaceAll("\\(", "");
|
||
|
|
pdfEOMap.put("carCode", CommonUtils.checkNull(carCodeVal.trim()));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(null != pdfEOMap){
|
||
|
|
String pdfEONO = CommonUtils.checkNull(pdfEOMap.get("eoNo"));
|
||
|
|
String pdfEOIssueDate = CommonUtils.checkNull(pdfEOMap.get("eoDate"));
|
||
|
|
String pdfCarCode = CommonUtils.checkNull(pdfEOMap.get("carCode"));
|
||
|
|
|
||
|
|
String renamePDFFileName = pdfCarCode+"_"+pdfEONO+"_"+pdfEOIssueDate+"."+fileExt;
|
||
|
|
HashMap pdfFileSqlMap = new HashMap();
|
||
|
|
pdfFileSqlMap.put("realFileName",renamePDFFileName);
|
||
|
|
pdfFileSqlMap.put("fileObjId",fileObjectId);
|
||
|
|
sqlSession.update("eo.updateEOPdfFileName", pdfFileSqlMap);
|
||
|
|
}
|
||
|
|
|
||
|
|
sqlSession.commit();
|
||
|
|
|
||
|
|
}catch(Exception e){
|
||
|
|
sqlSession.rollback();
|
||
|
|
e.printStackTrace();
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return pdfEOMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 체크박스 선택한 파트 첨부파일 일괄 다운로드
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public HashMap packgeingCheckedPartFile(HttpServletRequest request, Map paramMap){
|
||
|
|
HashMap fileMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
try{
|
||
|
|
|
||
|
|
List docTypeList = new ArrayList();
|
||
|
|
docTypeList.add(Constants.FILE_DOC_TYPE_PART_SHAPE_CODE); //형상
|
||
|
|
docTypeList.add(Constants.FILE_DOC_TYPE_PART_2D_CODE); //2D 도면
|
||
|
|
docTypeList.add(Constants.FILE_DOC_TYPE_PART_2D_PDF_CODE); //2D PDF
|
||
|
|
docTypeList.add(Constants.FILE_DOC_TYPE_PART_3D_CODE); //3D 도면
|
||
|
|
|
||
|
|
String connectedParts[] = request.getParameterValues("connectedPart");
|
||
|
|
if(null != connectedParts && 0 < connectedParts.length){
|
||
|
|
|
||
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_kkmmss");
|
||
|
|
Calendar cal = Calendar.getInstance();
|
||
|
|
|
||
|
|
String timeStamp = sdf.format(cal.getTime());
|
||
|
|
|
||
|
|
//다운받을 zip 파일 set
|
||
|
|
String zipFileName = "test_"+timeStamp+".zip";
|
||
|
|
String zipFilePath = Constants.PART_ATTACH_FILE_PAKEGE+File.separator+zipFileName;
|
||
|
|
|
||
|
|
ZipOutputStream zout = null;
|
||
|
|
zout = new ZipOutputStream(new FileOutputStream(zipFilePath));
|
||
|
|
|
||
|
|
byte[] buf = new byte[1024];
|
||
|
|
|
||
|
|
//선택된 파트의 첨부파일 정보를 가져온다.
|
||
|
|
for(int i=0;i<connectedParts.length;i++){
|
||
|
|
|
||
|
|
String targetObjId = CommonUtils.checkNull(connectedParts[i]);
|
||
|
|
if(!"".equals(targetObjId)){
|
||
|
|
|
||
|
|
ArrayList fileList = new ArrayList();
|
||
|
|
|
||
|
|
HashMap sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
||
|
|
sqlParamMap.put("docTypeList", docTypeList);
|
||
|
|
fileList = (ArrayList)sqlSession.selectList("common.getFileList", sqlParamMap);
|
||
|
|
|
||
|
|
if(null != fileList && 0 < fileList.size()){
|
||
|
|
for(int j=0;j<fileList.size();j++){
|
||
|
|
HashMap fileListMap = (HashMap)fileList.get(j);
|
||
|
|
String savedFileName = CommonUtils.checkNull(fileListMap.get("SAVED_FILE_NAME"));
|
||
|
|
String saveFilePath = CommonUtils.checkNull(fileListMap.get("FILE_PATH"));
|
||
|
|
String realFileName = CommonUtils.checkNull(fileListMap.get("REAL_FILE_NAME"));
|
||
|
|
String targetFilePath = saveFilePath+File.separator+savedFileName;
|
||
|
|
|
||
|
|
FileInputStream fis = new FileInputStream(targetFilePath);
|
||
|
|
|
||
|
|
zout.putNextEntry(new ZipEntry(realFileName));
|
||
|
|
|
||
|
|
int len;
|
||
|
|
while((len = fis.read(buf)) > 0){
|
||
|
|
zout.write(buf, 0, len);
|
||
|
|
}
|
||
|
|
zout.closeEntry();
|
||
|
|
fis.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
zout.close();
|
||
|
|
|
||
|
|
fileMap.put("SAVED_FILE_NAME", zipFileName);
|
||
|
|
fileMap.put("REAL_FILE_NAME", zipFileName);
|
||
|
|
fileMap.put("FILE_PATH", Constants.PART_ATTACH_FILE_PAKEGE);
|
||
|
|
}
|
||
|
|
}catch(Exception e){
|
||
|
|
try {
|
||
|
|
throw e;
|
||
|
|
} catch (Exception e1) {
|
||
|
|
// TODO Auto-generated catch block
|
||
|
|
e1.printStackTrace();
|
||
|
|
}
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return fileMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 전체 파트 첨부파일 일괄 다운로드
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public HashMap packgeingPartFile(HttpServletRequest request, Map paramMap){
|
||
|
|
HashMap fileMap = new HashMap();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
try{
|
||
|
|
|
||
|
|
String batchType = CommonUtils.checkNull(paramMap.get("fileType"));
|
||
|
|
|
||
|
|
List docTypeList = new ArrayList();
|
||
|
|
|
||
|
|
if("etc".equals(batchType)){
|
||
|
|
docTypeList.add("PART_MNG_ITEM"); //관리항목
|
||
|
|
docTypeList.add("PART_ECD"); //ECD
|
||
|
|
}else{
|
||
|
|
docTypeList.add("PART_SHAPE"); //형상
|
||
|
|
docTypeList.add("PART_2D"); //2D 도면
|
||
|
|
docTypeList.add("PART_2D_PDF"); //2D PDF
|
||
|
|
docTypeList.add("PART_3D"); //3D 도면
|
||
|
|
}
|
||
|
|
|
||
|
|
//압푹파일 정보로 사용될 EO 정보를 가져온다.
|
||
|
|
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||
|
|
HashMap eoMap = new HashMap();
|
||
|
|
|
||
|
|
eoMap = getEOInfo(request, paramMap);
|
||
|
|
|
||
|
|
String eoNo = CommonUtils.checkNull(eoMap.get("EO_NO")).replaceAll("/", "");
|
||
|
|
String eoDate = CommonUtils.checkNull(eoMap.get("EO_ISSUE_DATE")).replaceAll("/", "");
|
||
|
|
String carName = CommonUtils.checkNull(eoMap.get("CAR_NAME")).replaceAll("/", "");
|
||
|
|
String carCode = CommonUtils.checkNull(eoMap.get("CAR_CODE")).replaceAll("/", "");
|
||
|
|
|
||
|
|
File zipStorage = new File(Constants.PART_ATTACH_FILE_PAKEGE);
|
||
|
|
if(!zipStorage.exists()) zipStorage.mkdirs();
|
||
|
|
|
||
|
|
//선택된 part 목록
|
||
|
|
String connectedParts[] = request.getParameterValues("connectedPart");
|
||
|
|
if(null != connectedParts && 0 < connectedParts.length && null != eoMap){
|
||
|
|
|
||
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_kkmmss");
|
||
|
|
Calendar cal = Calendar.getInstance();
|
||
|
|
|
||
|
|
String timeStamp = sdf.format(cal.getTime());
|
||
|
|
|
||
|
|
//다운받을 zip 파일 set
|
||
|
|
String zipFileName = eoNo+"_"+eoDate+"_"+carName+"_"+carCode+"_"+timeStamp+".zip";
|
||
|
|
String zipFilePath = Constants.PART_ATTACH_FILE_PAKEGE+File.separator+zipFileName;
|
||
|
|
|
||
|
|
ZipOutputStream zout = null;
|
||
|
|
zout = new ZipOutputStream(new FileOutputStream(zipFilePath));
|
||
|
|
|
||
|
|
byte[] buf = new byte[1024];
|
||
|
|
|
||
|
|
//선택된 파트의 첨부파일 정보를 가져온다.
|
||
|
|
for(int i=0;i<connectedParts.length;i++){
|
||
|
|
|
||
|
|
String targetObjId = CommonUtils.checkNull(connectedParts[i]);
|
||
|
|
if(!"".equals(targetObjId)){
|
||
|
|
|
||
|
|
ArrayList fileList = new ArrayList();
|
||
|
|
|
||
|
|
HashMap sqlParamMap = new HashMap();
|
||
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
||
|
|
sqlParamMap.put("docTypeList", docTypeList);
|
||
|
|
fileList = (ArrayList)sqlSession.selectList("eo.getPartFileList", sqlParamMap);
|
||
|
|
|
||
|
|
if(null != fileList && 0 < fileList.size()){
|
||
|
|
for(int j=0;j<fileList.size();j++){
|
||
|
|
HashMap fileListMap = (HashMap)fileList.get(j);
|
||
|
|
String savedFileName = CommonUtils.checkNull(fileListMap.get("SAVED_FILE_NAME"));
|
||
|
|
String saveFilePath = CommonUtils.checkNull(fileListMap.get("FILE_PATH"));
|
||
|
|
String docType = CommonUtils.checkNull(fileListMap.get("DOC_TYPE"));
|
||
|
|
String partNo = CommonUtils.checkNull(fileListMap.get("PART_NO"));
|
||
|
|
String partRevision = CommonUtils.checkNull(fileListMap.get("REV"));
|
||
|
|
String realFileName = CommonUtils.checkNull(fileListMap.get("REAL_FILE_NAME"));
|
||
|
|
String targetFilePath = saveFilePath+File.separator+savedFileName;
|
||
|
|
|
||
|
|
FileInputStream fis = new FileInputStream(targetFilePath);
|
||
|
|
|
||
|
|
//ZIP 파일에 들어갈 파일명을 '품번_revision_문서타입_실제업로드 파일명' 형식으로 지정한다.
|
||
|
|
zout.putNextEntry(new ZipEntry(partNo+"_"+partRevision+"_"+docType+"_"+realFileName));
|
||
|
|
|
||
|
|
int len;
|
||
|
|
while((len = fis.read(buf)) > 0){
|
||
|
|
zout.write(buf, 0, len);
|
||
|
|
}
|
||
|
|
zout.closeEntry();
|
||
|
|
fis.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
zout.close();
|
||
|
|
|
||
|
|
fileMap.put("SAVED_FILE_NAME", zipFileName);
|
||
|
|
fileMap.put("REAL_FILE_NAME", zipFileName);
|
||
|
|
fileMap.put("FILE_PATH", Constants.PART_ATTACH_FILE_PAKEGE);
|
||
|
|
}
|
||
|
|
}catch(Exception e){
|
||
|
|
try {
|
||
|
|
throw e;
|
||
|
|
} catch (Exception e1) {
|
||
|
|
// TODO Auto-generated catch block
|
||
|
|
e1.printStackTrace();
|
||
|
|
}
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return fileMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 결재 상신 전 EO의 유효성을 검사한다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public HashMap checkEOValidate(HttpServletRequest request, Map paramMap){
|
||
|
|
HashMap resultMap = new HashMap();
|
||
|
|
HashMap eoMap = new HashMap();
|
||
|
|
ArrayList partList = new ArrayList();
|
||
|
|
try{
|
||
|
|
eoMap = getEOInfo(request, paramMap);
|
||
|
|
|
||
|
|
if(!eoMap.isEmpty()){
|
||
|
|
|
||
|
|
String eoNo = CommonUtils.checkNull(eoMap.get("EO_NO"));
|
||
|
|
String oemObjId = CommonUtils.checkNull(eoMap.get("OEM_OBJID"));
|
||
|
|
String carObjId = CommonUtils.checkNull(eoMap.get("CAR_OBJID"));
|
||
|
|
String eoType = CommonUtils.checkNull(eoMap.get("EO_TYPE"));
|
||
|
|
String designTeam = CommonUtils.checkNull(eoMap.get("DESIGN_TEAM"));
|
||
|
|
String eoIssuDate = CommonUtils.checkNull(eoMap.get("EO_ISSUE_DATE"));
|
||
|
|
String urgentDegree = CommonUtils.checkNull(eoMap.get("URGENT_DEGREE"));
|
||
|
|
String hkmcDate = CommonUtils.checkNull(eoMap.get("HKMC_DISTRIBUTE_DATE"));
|
||
|
|
|
||
|
|
//EO No 검사
|
||
|
|
if("".equals(eoNo)){
|
||
|
|
//EO No가 비어있음
|
||
|
|
resultMap.put("eoNo", "empty");
|
||
|
|
}else if(eoNo.toUpperCase().replaceAll(" ", "").contains("NEWEO")){
|
||
|
|
//EO No가 수정되지 않았음
|
||
|
|
resultMap.put("eoNo", "default");
|
||
|
|
}else{
|
||
|
|
resultMap.put("eoNo", "ok");
|
||
|
|
}
|
||
|
|
|
||
|
|
//고객사 검사
|
||
|
|
if("".equals(oemObjId)){
|
||
|
|
//선택된 고객사 정보 없음
|
||
|
|
resultMap.put("oem", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("oem", "ok");
|
||
|
|
}
|
||
|
|
|
||
|
|
//차종 검사
|
||
|
|
if("".equals(carObjId)){
|
||
|
|
//선택된 차종 정보 없음
|
||
|
|
resultMap.put("car", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("car", "ok");
|
||
|
|
}
|
||
|
|
|
||
|
|
//EO 종류
|
||
|
|
if("".equals(eoType)){
|
||
|
|
//선택된 EO 종류 없음
|
||
|
|
resultMap.put("eoType", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("eoType", "ok");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
//고객사 설계팀
|
||
|
|
if("".equals(designTeam)){
|
||
|
|
resultMap.put("designTeam", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("designTeam", "ok");
|
||
|
|
}
|
||
|
|
|
||
|
|
//EO Issue Date
|
||
|
|
if("".equals(eoIssuDate)){
|
||
|
|
resultMap.put("eoIssuDate", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("eoIssuDate", "ok");
|
||
|
|
}
|
||
|
|
|
||
|
|
//긴급도
|
||
|
|
if("".equals(urgentDegree)){
|
||
|
|
resultMap.put("urgentDegree", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("urgentDegree", "ok");
|
||
|
|
}
|
||
|
|
|
||
|
|
//구매배포일
|
||
|
|
if("".equals(hkmcDate)){
|
||
|
|
resultMap.put("hkmcDate", "empty");
|
||
|
|
}else{
|
||
|
|
resultMap.put("hkmcDate", "ok");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
partList = getConnectPartList(request, paramMap);
|
||
|
|
|
||
|
|
if(0 < partList.size()){
|
||
|
|
resultMap.put("connectPart", "ok");
|
||
|
|
}else{
|
||
|
|
resultMap.put("connectPart", "empty");
|
||
|
|
}
|
||
|
|
|
||
|
|
}catch(Exception e){
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
|
||
|
|
return resultMap;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* SOP 적용 먼 기준 상위차종 5개의 EO 발행현황을 보여준다.
|
||
|
|
* @param request
|
||
|
|
* @param paramMap
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public ArrayList getEOReleaseList(HttpServletRequest request, Map paramMap){
|
||
|
|
ArrayList eoList = new ArrayList();
|
||
|
|
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||
|
|
try{
|
||
|
|
eoList = (ArrayList)sqlSession.selectList("eo.getDistantSOPCarEORelease",paramMap);
|
||
|
|
}catch(Exception e){
|
||
|
|
throw e;
|
||
|
|
}finally{
|
||
|
|
sqlSession.close();
|
||
|
|
}
|
||
|
|
return eoList;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|