1870 lines
62 KiB
Java
1870 lines
62 KiB
Java
package com.pms.service;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.pms.common.Message;
|
|
import com.pms.common.SqlMapConfig;
|
|
import com.pms.common.bean.PersonBean;
|
|
import com.pms.common.service.BaseService;
|
|
import com.pms.common.utils.CommonUtils;
|
|
import com.pms.common.utils.Constants;
|
|
import com.pms.common.JsonUtil;
|
|
|
|
@Service
|
|
public class QualityService extends BaseService{
|
|
|
|
/*jmpark start*/
|
|
/**
|
|
* 품질검사 중복체크
|
|
* 차종, 제품, 검사명, 단계1,2별 한개씩만 등록 가능하다.
|
|
* 반환값 : true (중복), false (중복아님)
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map checkDuplicateQualityTestInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
Map map = sqlSession.selectOne("quality.getDuplicateQualityTestCnt", paramMap);
|
|
if(map != null){
|
|
int cnt = Integer.parseInt(CommonUtils.checkNull(map.get("CNT"), "0"));
|
|
System.out.println("cnt : "+cnt);
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
}else{
|
|
resultMap.put("result", false);
|
|
}
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 갑지 등록
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map saveQualityTestInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
String objId = CommonUtils.checkNull(request.getParameter("objId"));
|
|
|
|
if("".equals(objId)){
|
|
objId = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
}
|
|
paramMap.put("objId", objId);
|
|
paramMap.put("writer", writer);
|
|
|
|
int cnt = sqlSession.insert("quality.insertQualityTestInfo", paramMap);
|
|
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
}else{
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 갑지내용 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map getQualityTestInfo(HttpServletRequest request,Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getQualityTestInfo", paramMap);
|
|
|
|
String writer = CommonUtils.checkNull(resultMap.get("WRITER"));
|
|
//작성자 및 관리자 권한을 확인한다.
|
|
resultMap.put("IS_WRITER", CommonUtils.setWriterChecker(request, writer));
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 임시목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getQualityTestTempList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
Map pageMap = new HashMap();
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
//paging start
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("connectedUserId", person.getUserId());
|
|
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), ""+Constants.COUNT_PER_PAGE+"");
|
|
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
pageMap = (HashMap)sqlSession.selectOne("quality.getQualityTestTempListCnt", paramMap);
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap, countPerPage);
|
|
|
|
paramMap.put("PAGE_END", CommonUtils.checkNull(pageMap.get("PAGE_END")));
|
|
paramMap.put("PAGE_START", CommonUtils.checkNull(pageMap.get("PAGE_START")));
|
|
//paging end
|
|
|
|
resultList = sqlSession.selectList("quality.getQualityTestTempList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 확정목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getQualityTestList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
Map pageMap = new HashMap();
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
//paging start
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
paramMap.put("connectedUserId", person.getUserId());
|
|
|
|
String countPerPage = CommonUtils.checkNull(request.getParameter("countPerPage"), ""+Constants.COUNT_PER_PAGE+"");
|
|
|
|
paramMap.put("COUNT_PER_PAGE", Integer.parseInt(countPerPage));
|
|
|
|
pageMap = (HashMap)sqlSession.selectOne("quality.getQualityTestListCnt", paramMap);
|
|
pageMap = (HashMap)CommonUtils.setPagingInfo(request, pageMap, countPerPage);
|
|
|
|
paramMap.put("PAGE_END", CommonUtils.checkNull(pageMap.get("PAGE_END")));
|
|
paramMap.put("PAGE_START", CommonUtils.checkNull(pageMap.get("PAGE_START")));
|
|
//paging end
|
|
|
|
resultList = sqlSession.selectList("quality.getQualityTestList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 상세 Part 목록조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getQualityTestDetailPartList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getQualityTestDetailPartList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 Part별 정보 저장
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map saveQualityTestPartInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
List partList = sqlSession.selectList("quality.getQualityTestDetailPartList", paramMap);
|
|
|
|
for(int i = 0 ; i < partList.size() ; i++){
|
|
Map partInfo = (HashMap)partList.get(i);
|
|
|
|
String objId = CommonUtils.checkNull(partInfo.get("QUALITY_SLAVE_OBJID"));
|
|
String targetObjId = CommonUtils.checkNull(paramMap.get("targetObjId"));
|
|
String partNo = CommonUtils.checkNull(partInfo.get("PART_NO"));
|
|
String score = CommonUtils.checkNull(paramMap.get("score_"+partNo));
|
|
String result = CommonUtils.checkNull(paramMap.get("result_"+partNo));
|
|
String type1 = CommonUtils.checkNull(paramMap.get("type1_"+partNo));
|
|
String type2 = CommonUtils.checkNull(paramMap.get("type2_"+partNo));
|
|
|
|
|
|
|
|
System.out.println();
|
|
System.out.println("objId : "+objId);
|
|
if("".equals(objId)) objId = CommonUtils.createObjId();
|
|
System.out.println("objId2 : "+objId);
|
|
System.out.println("targetObjId : "+targetObjId);
|
|
System.out.println("partNo : "+partNo);
|
|
System.out.println("score : "+score);
|
|
System.out.println("result : "+result);
|
|
|
|
System.out.println();
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("objId", objId);
|
|
sqlParamMap.put("targetObjId", targetObjId);
|
|
sqlParamMap.put("partNo", partNo);
|
|
sqlParamMap.put("score", score);
|
|
sqlParamMap.put("result", result);
|
|
sqlParamMap.put("type1", type1);
|
|
sqlParamMap.put("type2", type2);
|
|
sqlParamMap.put("writer", writer);
|
|
|
|
int cnt = sqlSession.update("quality.saveQualityTestPartInfo", sqlParamMap);
|
|
|
|
if(cnt == 0){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
sqlSession.commit();
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 품질검사 확정
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map completeQualityTestInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
int cnt = sqlSession.update("quality.completeQualityTestInfo", paramMap);
|
|
if(cnt > 0){
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
}else{
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
}
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
/*jmpark end*/
|
|
|
|
|
|
// =====================================================
|
|
// 품질관리 기초정보관리
|
|
// =====================================================
|
|
|
|
/**
|
|
* 검사구분 목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getInspectionTypeList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getInspectionTypeList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 불량유형 목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getDefectTypeList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getDefectTypeList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 불량원인 목록 조회
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public List getDefectReasonList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getDefectReasonList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 기초정보 저장
|
|
* @param request
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map saveQualityBasicInfo(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
String type = CommonUtils.checkNull(paramMap.get("TYPE"));
|
|
String dataJson = CommonUtils.checkNull(paramMap.get("DATA"));
|
|
|
|
// JSON 파싱
|
|
com.google.gson.Gson gson = new com.google.gson.Gson();
|
|
java.lang.reflect.Type listType = new com.google.gson.reflect.TypeToken<List<Map<String, String>>>(){}.getType();
|
|
List<Map<String, String>> dataList = gson.fromJson(dataJson, listType);
|
|
|
|
for(Map<String, String> data : dataList){
|
|
String objId = CommonUtils.checkNull(data.get("OBJID"));
|
|
String isNew = CommonUtils.checkNull(data.get("IS_NEW"));
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("writer", writer);
|
|
|
|
if("INSPECTION_TYPE".equals(type)){
|
|
// 검사구분 저장
|
|
sqlParamMap.put("INSPECTION_TYPE_NAME", data.get("INSPECTION_TYPE_NAME"));
|
|
sqlParamMap.put("STATUS", data.get("STATUS"));
|
|
|
|
if("Y".equals(isNew)){
|
|
sqlParamMap.put("OBJID", CommonUtils.createObjId());
|
|
sqlSession.insert("quality.insertInspectionType", sqlParamMap);
|
|
} else {
|
|
sqlParamMap.put("OBJID", objId);
|
|
sqlSession.update("quality.updateInspectionType", sqlParamMap);
|
|
}
|
|
} else if("DEFECT_TYPE".equals(type)){
|
|
// 불량유형 저장
|
|
sqlParamMap.put("DEFECT_TYPE_NAME", data.get("DEFECT_TYPE_NAME"));
|
|
sqlParamMap.put("STATUS", data.get("STATUS"));
|
|
|
|
if("Y".equals(isNew)){
|
|
sqlParamMap.put("OBJID", CommonUtils.createObjId());
|
|
sqlSession.insert("quality.insertDefectType", sqlParamMap);
|
|
} else {
|
|
sqlParamMap.put("OBJID", objId);
|
|
sqlSession.update("quality.updateDefectType", sqlParamMap);
|
|
}
|
|
} else if("DEFECT_REASON".equals(type)){
|
|
// 불량원인 저장
|
|
sqlParamMap.put("DEFECT_TYPE_OBJID", data.get("DEFECT_TYPE_OBJID"));
|
|
sqlParamMap.put("DEFECT_REASON_NAME", data.get("DEFECT_REASON_NAME"));
|
|
sqlParamMap.put("STATUS", data.get("STATUS"));
|
|
|
|
if("Y".equals(isNew)){
|
|
sqlParamMap.put("OBJID", CommonUtils.createObjId());
|
|
sqlSession.insert("quality.insertDefectReason", sqlParamMap);
|
|
} else {
|
|
sqlParamMap.put("OBJID", objId);
|
|
sqlSession.update("quality.updateDefectReason", sqlParamMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 기초정보 삭제
|
|
* @param paramMap
|
|
* @return
|
|
*/
|
|
public Map deleteQualityBasicInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String type = CommonUtils.checkNull(paramMap.get("TYPE"));
|
|
String objId = CommonUtils.checkNull(paramMap.get("OBJID"));
|
|
|
|
int cnt = 0;
|
|
|
|
if("INSPECTION_TYPE".equals(type)){
|
|
cnt = sqlSession.delete("quality.deleteInspectionType", paramMap);
|
|
} else if("DEFECT_TYPE".equals(type)){
|
|
// 불량유형 삭제 시 종속된 불량원인도 삭제
|
|
sqlSession.delete("quality.deleteDefectReasonByType", paramMap);
|
|
cnt = sqlSession.delete("quality.deleteDefectType", paramMap);
|
|
} else if("DEFECT_REASON".equals(type)){
|
|
cnt = sqlSession.delete("quality.deleteDefectReason", paramMap);
|
|
}
|
|
|
|
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);
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
// =====================================================
|
|
// 수입검사 관리
|
|
// =====================================================
|
|
|
|
/**
|
|
* 품의서 번호 목록 조회 (검색조건용)
|
|
*/
|
|
public List getProposalNoList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getProposalNoList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 발주서 번호 목록 조회 (검색조건용)
|
|
*/
|
|
public List getPurchaseOrderNoList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getPurchaseOrderNoList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 프로젝트 번호 목록 조회 (검색조건용)
|
|
*/
|
|
public List getProjectNoList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getProjectNoList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 공급업체 목록 조회 (검색조건용)
|
|
*/
|
|
public List getPartnerList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getPartnerList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 검사자 목록 조회 (검색조건용)
|
|
*/
|
|
public List getInspectorList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getInspectorList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 목록 조회
|
|
*/
|
|
public List getIncomingInspectionList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getIncomingInspectionList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 상세 정보 조회
|
|
*/
|
|
public Map getIncomingInspectionInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getIncomingInspectionInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 상세 정보 조회 (발주서 기준 첫번째 검사 정보)
|
|
*/
|
|
public Map getIncomingInspectionDetailInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getIncomingInspectionDetailInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 요청 저장 (검사여부, 요청일, 요청자만 저장)
|
|
*/
|
|
public Map saveIncomingInspectionRequest(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
String requestDate = CommonUtils.checkNull(paramMap.get("REQUEST_DATE"));
|
|
String requestUserId = CommonUtils.checkNull(paramMap.get("REQUEST_USER_ID"));
|
|
String purchaseOrderMasterObjId = CommonUtils.checkNull(paramMap.get("PURCHASE_ORDER_MASTER_OBJID"));
|
|
String dataListJson = CommonUtils.checkNull(paramMap.get("dataListJson"));
|
|
|
|
// JSON 파싱
|
|
com.google.gson.Gson gson = new com.google.gson.Gson();
|
|
java.lang.reflect.Type listType = new com.google.gson.reflect.TypeToken<List<Map<String, String>>>(){}.getType();
|
|
List<Map<String, String>> dataList = gson.fromJson(dataListJson, listType);
|
|
|
|
// 각 행별로 저장 (요청 정보만)
|
|
for(Map<String, String> data : dataList){
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("NEW_OBJID", CommonUtils.createObjId()); // 신규 OBJID 생성
|
|
sqlParamMap.put("OBJID", data.get("OBJID")); // INVENTORY_MGMT_IN.OBJID
|
|
sqlParamMap.put("PURCHASE_ORDER_MASTER_OBJID", purchaseOrderMasterObjId);
|
|
sqlParamMap.put("REQUEST_DATE", requestDate);
|
|
sqlParamMap.put("REQUEST_USER_ID", requestUserId);
|
|
sqlParamMap.put("INSPECTION_YN", data.get("INSPECTION_YN"));
|
|
sqlParamMap.put("WRITER", writer);
|
|
|
|
sqlSession.update("quality.saveIncomingInspectionDetail", sqlParamMap);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 저장 (그리드 데이터 일괄 저장)
|
|
* - 요청일/요청자: 각 행별로 개별 저장
|
|
* - 검사일/검사자: 헤더에서 공통 적용 (진행 팝업에서 사용)
|
|
*/
|
|
public Map saveIncomingInspection(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
// 헤더에서 가져오는 값 (진행 팝업용)
|
|
String inspectionDate = CommonUtils.checkNull(paramMap.get("INSPECTION_DATE"));
|
|
String inspectorId = CommonUtils.checkNull(paramMap.get("INSPECTOR_ID"));
|
|
String purchaseOrderMasterObjId = CommonUtils.checkNull(paramMap.get("PURCHASE_ORDER_MASTER_OBJID"));
|
|
String dataListJson = CommonUtils.checkNull(paramMap.get("dataListJson"));
|
|
|
|
// JSON 파싱
|
|
com.google.gson.Gson gson = new com.google.gson.Gson();
|
|
java.lang.reflect.Type listType = new com.google.gson.reflect.TypeToken<List<Map<String, String>>>(){}.getType();
|
|
List<Map<String, String>> dataList = gson.fromJson(dataListJson, listType);
|
|
|
|
// 각 행별로 저장
|
|
for(Map<String, String> data : dataList){
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("NEW_OBJID", CommonUtils.createObjId()); // 신규 OBJID 생성
|
|
sqlParamMap.put("OBJID", data.get("OBJID")); // INVENTORY_MGMT_IN.OBJID
|
|
sqlParamMap.put("PURCHASE_ORDER_MASTER_OBJID", purchaseOrderMasterObjId);
|
|
|
|
// 검사일/검사자: 헤더 값 사용 (진행 팝업)
|
|
sqlParamMap.put("INSPECTION_DATE", inspectionDate);
|
|
sqlParamMap.put("INSPECTOR_ID", inspectorId);
|
|
|
|
// 요청일/요청자: 각 행별 개별 값 사용 (요청 팝업)
|
|
sqlParamMap.put("REQUEST_DATE", data.get("REQUEST_DATE"));
|
|
sqlParamMap.put("REQUEST_USER_ID", data.get("REQUEST_USER_ID"));
|
|
|
|
sqlParamMap.put("INSPECTION_TYPE", data.get("INSPECTION_TYPE"));
|
|
sqlParamMap.put("INSPECTION_YN", data.get("INSPECTION_YN"));
|
|
sqlParamMap.put("DEFECT_TYPE", data.get("DEFECT_TYPE"));
|
|
sqlParamMap.put("DEFECT_REASON", data.get("DEFECT_REASON"));
|
|
sqlParamMap.put("ACTION_STATUS", data.get("ACTION_STATUS"));
|
|
sqlParamMap.put("INSPECTION_QTY", data.get("INSPECTION_QTY"));
|
|
sqlParamMap.put("DEFECT_QTY", data.get("DEFECT_QTY"));
|
|
sqlParamMap.put("INSPECTION_RESULT", data.get("INSPECTION_RESULT"));
|
|
sqlParamMap.put("ATTACH_FILE_OBJID", data.get("ATTACH_FILE_OBJID"));
|
|
sqlParamMap.put("REMARK", data.get("REMARK"));
|
|
sqlParamMap.put("WRITER", writer);
|
|
|
|
sqlSession.update("quality.saveIncomingInspectionDetail", sqlParamMap);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", Message.SAVE_SUCCESS);
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", Message.SAVE_FAILED);
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 목록 조회 (엑셀용)
|
|
*/
|
|
public List getIncomingInspectionListForExcel(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getIncomingInspectionListForExcel", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
// =====================================================
|
|
// 공정검사 관리
|
|
// =====================================================
|
|
|
|
/**
|
|
* 공정검사 목록 조회
|
|
*/
|
|
public List getProcessInspectionList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getProcessInspectionList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 공정검사 상세 조회
|
|
*/
|
|
public Map getProcessInspectionInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getProcessInspectionInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 공정검사 목록 조회 (엑셀용) - 상세 정보 포함
|
|
*/
|
|
public List getProcessInspectionListForExcel(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getProcessInspectionListForExcel", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 공정검사 저장 (마스터 + 디테일)
|
|
*/
|
|
public Map saveProcessInspection(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = person != null ? person.getUserId() : "";
|
|
|
|
String masterObjId = CommonUtils.checkNull(paramMap.get("MASTER_OBJID"));
|
|
String inspectionDate = CommonUtils.checkNull(paramMap.get("INSPECTION_DATE"));
|
|
String inspectorId = CommonUtils.checkNull(paramMap.get("INSPECTOR_ID"));
|
|
String masterRemark = CommonUtils.checkNull(paramMap.get("MASTER_REMARK"));
|
|
String dataListJson = CommonUtils.checkNull(paramMap.get("dataList"));
|
|
|
|
// 마스터 저장
|
|
Map<String, Object> masterParamMap = new HashMap<String, Object>();
|
|
masterParamMap.put("INSPECTION_DATE", inspectionDate);
|
|
masterParamMap.put("INSPECTOR_ID", inspectorId);
|
|
masterParamMap.put("REMARK", masterRemark);
|
|
masterParamMap.put("WRITER", writer);
|
|
|
|
if(masterObjId.isEmpty()){
|
|
// 신규 등록
|
|
masterObjId = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
masterParamMap.put("OBJID", masterObjId);
|
|
sqlSession.insert("quality.insertProcessInspectionMaster", masterParamMap);
|
|
} else {
|
|
// 수정
|
|
masterParamMap.put("OBJID", masterObjId);
|
|
sqlSession.update("quality.updateProcessInspectionMaster", masterParamMap);
|
|
// 디테일은 삭제하지 않고 UPSERT로 처리 (파일 첨부 연동 유지)
|
|
}
|
|
|
|
// 디테일 저장
|
|
if(dataListJson != null && !dataListJson.isEmpty()){
|
|
com.google.gson.Gson gson = new com.google.gson.Gson();
|
|
java.lang.reflect.Type listType = new com.google.gson.reflect.TypeToken<List<Map<String, Object>>>(){}.getType();
|
|
List<Map<String, Object>> dataList = gson.fromJson(dataListJson, listType);
|
|
|
|
for(Map<String, Object> rowData : dataList){
|
|
Map<String, Object> sqlParamMap = new HashMap<String, Object>();
|
|
|
|
// 클라이언트에서 전달한 OBJID 사용 (파일 첨부 연동을 위해)
|
|
String detailObjId = CommonUtils.checkNull(rowData.get("OBJID"));
|
|
if(detailObjId.isEmpty()) {
|
|
detailObjId = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
}
|
|
|
|
sqlParamMap.put("OBJID", detailObjId);
|
|
sqlParamMap.put("MASTER_OBJID", masterObjId);
|
|
sqlParamMap.put("PROCESS_CD", CommonUtils.checkNull(rowData.get("PROCESS_CD")));
|
|
sqlParamMap.put("PROJECT_OBJID", CommonUtils.checkNull(rowData.get("PROJECT_OBJID")));
|
|
sqlParamMap.put("PART_OBJID", CommonUtils.checkNull(rowData.get("PART_OBJID")));
|
|
sqlParamMap.put("PART_NO", CommonUtils.checkNull(rowData.get("PART_NO")));
|
|
sqlParamMap.put("PART_NAME", CommonUtils.checkNull(rowData.get("PART_NAME")));
|
|
sqlParamMap.put("INSPECTION_QTY", CommonUtils.checkNull(rowData.get("INSPECTION_QTY")));
|
|
sqlParamMap.put("DEFECT_QTY", CommonUtils.checkNull(rowData.get("DEFECT_QTY")));
|
|
sqlParamMap.put("WORK_ENV_STATUS", CommonUtils.checkNull(rowData.get("WORK_ENV_STATUS")));
|
|
sqlParamMap.put("MEASURING_DEVICE", CommonUtils.checkNull(rowData.get("MEASURING_DEVICE")));
|
|
sqlParamMap.put("DEPT_CD", CommonUtils.checkNull(rowData.get("DEPT_CD")));
|
|
sqlParamMap.put("USER_ID", CommonUtils.checkNull(rowData.get("USER_ID")));
|
|
sqlParamMap.put("INSPECTION_DATE", CommonUtils.checkNull(rowData.get("INSPECTION_DATE")));
|
|
sqlParamMap.put("INSPECTOR_ID", CommonUtils.checkNull(rowData.get("INSPECTOR_ID")));
|
|
sqlParamMap.put("REMARK", CommonUtils.checkNull(rowData.get("REMARK")));
|
|
sqlParamMap.put("ACTION_STATUS", CommonUtils.checkNull(rowData.get("ACTION_STATUS")));
|
|
sqlParamMap.put("INSPECTION_RESULT", CommonUtils.checkNull(rowData.get("INSPECTION_RESULT")));
|
|
sqlParamMap.put("WRITER", writer);
|
|
|
|
sqlSession.insert("quality.saveProcessInspectionDetail", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
resultMap.put("RESULT", "SUCCESS");
|
|
resultMap.put("MASTER_OBJID", masterObjId);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
resultMap.put("RESULT", "FAIL");
|
|
resultMap.put("MESSAGE", e.getMessage());
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
// =====================================================
|
|
// 반제품검사 관리
|
|
// =====================================================
|
|
|
|
/**
|
|
* 반제품검사 목록 조회
|
|
*/
|
|
public List getSemiProductInspectionList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductInspectionList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 엑셀 다운로드용 원본 데이터 조회
|
|
*/
|
|
public List getSemiProductInspectionListForExcel(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductInspectionListForExcel", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 상세 조회
|
|
*/
|
|
public Map getSemiProductInspectionInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getSemiProductInspectionInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 상세 조회 (팝업용 - 양품/불량 데이터 분리)
|
|
*/
|
|
public Map getSemiProductInspectionDetail(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
String inspectionGroupId = CommonUtils.checkNull(paramMap.get("INSPECTION_GROUP_ID"));
|
|
String objid = CommonUtils.checkNull(paramMap.get("OBJID"));
|
|
|
|
Map searchMap = new HashMap();
|
|
// INSPECTION_GROUP_ID가 있으면 우선 사용
|
|
if(!inspectionGroupId.equals("")) {
|
|
searchMap.put("INSPECTION_GROUP_ID", inspectionGroupId);
|
|
} else if(!objid.equals("")) {
|
|
// OBJID로 해당 행의 INSPECTION_GROUP_ID 조회
|
|
Map infoMap = sqlSession.selectOne("quality.getSemiProductInspectionInfo", paramMap);
|
|
if(infoMap != null && infoMap.get("inspection_group_id") != null) {
|
|
searchMap.put("INSPECTION_GROUP_ID", CommonUtils.checkNull(infoMap.get("inspection_group_id")));
|
|
} else if(infoMap != null && infoMap.get("INSPECTION_GROUP_ID") != null) {
|
|
searchMap.put("INSPECTION_GROUP_ID", CommonUtils.checkNull(infoMap.get("INSPECTION_GROUP_ID")));
|
|
} else {
|
|
// 그룹 ID가 없으면 OBJID로 단건 조회
|
|
searchMap.put("OBJID", objid);
|
|
}
|
|
}
|
|
|
|
// 양품 데이터 (DATA_TYPE = 'GOOD')
|
|
searchMap.put("DATA_TYPE", "GOOD");
|
|
List leftData = sqlSession.selectList("quality.getSemiProductInspectionByType", searchMap);
|
|
resultMap.put("leftData", leftData);
|
|
|
|
// 불량 데이터 (DATA_TYPE = 'DEFECT')
|
|
searchMap.put("DATA_TYPE", "DEFECT");
|
|
List rightData = sqlSession.selectList("quality.getSemiProductInspectionByType", searchMap);
|
|
resultMap.put("rightData", rightData);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 행 잠금 (IS_LOCKED = 'Y')
|
|
*/
|
|
public Map lockSemiProductInspection(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objIdsJson = CommonUtils.checkNull(paramMap.get("objIds"));
|
|
|
|
if(!objIdsJson.equals("") && !objIdsJson.equals("[]")){
|
|
org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
|
|
org.json.simple.JSONArray objIdArr = (org.json.simple.JSONArray) parser.parse(objIdsJson);
|
|
|
|
for(int i = 0; i < objIdArr.size(); i++){
|
|
String objId = CommonUtils.checkNull(objIdArr.get(i));
|
|
if(!objId.equals("")){
|
|
Map lockParam = new HashMap();
|
|
lockParam.put("OBJID", objId);
|
|
sqlSession.update("quality.lockSemiProductInspection", lockParam);
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", "잠금 처리되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", "잠금 처리에 실패했습니다.");
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 행 잠금 해제 (IS_LOCKED = 'N')
|
|
*/
|
|
public Map unlockSemiProductInspection(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objIdsJson = CommonUtils.checkNull(paramMap.get("objIds"));
|
|
|
|
if(!objIdsJson.equals("") && !objIdsJson.equals("[]")){
|
|
org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
|
|
org.json.simple.JSONArray objIdArr = (org.json.simple.JSONArray) parser.parse(objIdsJson);
|
|
|
|
for(int i = 0; i < objIdArr.size(); i++){
|
|
String objId = CommonUtils.checkNull(objIdArr.get(i));
|
|
if(!objId.equals("")){
|
|
Map unlockParam = new HashMap();
|
|
unlockParam.put("OBJID", objId);
|
|
sqlSession.update("quality.unlockSemiProductInspection", unlockParam);
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", "잠금 해제되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", "잠금 해제에 실패했습니다.");
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 삭제 (OBJID 목록으로 삭제)
|
|
*/
|
|
public Map deleteSemiProductInspection(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
String objIdsJson = CommonUtils.checkNull(paramMap.get("objIds"));
|
|
|
|
if(!objIdsJson.equals("") && !objIdsJson.equals("[]")){
|
|
org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
|
|
org.json.simple.JSONArray objIdArr = (org.json.simple.JSONArray) parser.parse(objIdsJson);
|
|
|
|
for(int i = 0; i < objIdArr.size(); i++){
|
|
String objId = CommonUtils.checkNull(objIdArr.get(i));
|
|
if(!objId.equals("")){
|
|
Map deleteParam = new HashMap();
|
|
deleteParam.put("OBJID", objId);
|
|
sqlSession.delete("quality.deleteSemiProductInspectionByObjId", deleteParam);
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", "삭제되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", "삭제에 실패했습니다.");
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 저장 (새로운 팝업 형식)
|
|
* - 기존 INSPECTION_GROUP_ID가 있으면 수정 모드 (기존 OBJID 유지하면서 UPSERT)
|
|
* - 없으면 신규 등록 모드
|
|
*/
|
|
public Map saveSemiProductInspection(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
|
|
|
PersonBean person = (PersonBean)request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = CommonUtils.checkNull(person.getUserId());
|
|
|
|
// JSON 데이터 파싱
|
|
String leftDataStr = CommonUtils.checkNull(paramMap.get("leftData"));
|
|
String rightDataStr = CommonUtils.checkNull(paramMap.get("rightData"));
|
|
String existingGroupId = CommonUtils.checkNull(paramMap.get("INSPECTION_GROUP_ID"));
|
|
String saveType = CommonUtils.checkNull(paramMap.get("saveType"), "all"); // 저장 타입: left, right, all
|
|
String lockData = CommonUtils.checkNull(paramMap.get("lockData"), "N"); // 잠금 여부: Y, N
|
|
|
|
System.out.println("=== saveSemiProductInspection ===");
|
|
System.out.println("saveType: " + saveType);
|
|
System.out.println("lockData: " + lockData);
|
|
System.out.println("existingGroupId: " + existingGroupId);
|
|
|
|
org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
|
|
|
|
// 검사 그룹 ID 결정 (기존 있으면 유지, 없으면 새로 생성)
|
|
String inspectionGroupId = "";
|
|
java.util.Set existingLeftObjIds = new java.util.HashSet(); // 저장할 좌측 OBJID 목록
|
|
java.util.Set existingRightObjIds = new java.util.HashSet(); // 저장할 우측 OBJID 목록
|
|
|
|
if(!existingGroupId.equals("")){
|
|
// 수정 모드: 기존 그룹 ID 유지
|
|
inspectionGroupId = existingGroupId;
|
|
} else {
|
|
// 신규 등록 모드
|
|
inspectionGroupId = CommonUtils.createObjId();
|
|
}
|
|
|
|
// 양품 정보 (leftData) 저장
|
|
if(leftDataStr != null && !leftDataStr.equals("") && !leftDataStr.equals("[]")){
|
|
org.json.simple.JSONArray leftArr = (org.json.simple.JSONArray) parser.parse(leftDataStr);
|
|
for(int i = 0; i < leftArr.size(); i++){
|
|
org.json.simple.JSONObject item = (org.json.simple.JSONObject) leftArr.get(i);
|
|
|
|
// OBJID 처리
|
|
String existingObjId = CommonUtils.checkNull(item.get("OBJID"));
|
|
String rowId = CommonUtils.checkNull(item.get("ROW_ID"));
|
|
String objId = existingObjId;
|
|
|
|
// OBJID가 비어있거나 임시 ID이면 새로 생성
|
|
if(objId.equals("") || objId.startsWith("NEW_") || objId.startsWith("EXIST_")){
|
|
objId = CommonUtils.createObjId();
|
|
}
|
|
|
|
existingLeftObjIds.add(objId); // 좌측 OBJID 목록에 추가
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("OBJID", objId);
|
|
sqlParamMap.put("MODEL_NAME", CommonUtils.checkNull(item.get("MODEL_NAME")));
|
|
sqlParamMap.put("PRODUCT_TYPE", CommonUtils.checkNull(item.get("PRODUCT_TYPE")));
|
|
sqlParamMap.put("WORK_ORDER_NO", CommonUtils.checkNull(item.get("WORK_ORDER_NO")));
|
|
sqlParamMap.put("PART_NO", CommonUtils.checkNull(item.get("PART_NO")));
|
|
sqlParamMap.put("PART_NAME", CommonUtils.checkNull(item.get("PART_NAME")));
|
|
sqlParamMap.put("RECEIPT_QTY", CommonUtils.checkNull(item.get("RECEIPT_QTY"), "0"));
|
|
sqlParamMap.put("GOOD_QTY", CommonUtils.checkNull(item.get("GOOD_QTY"), "0"));
|
|
sqlParamMap.put("WRITER", writer);
|
|
sqlParamMap.put("DATA_TYPE", "GOOD");
|
|
sqlParamMap.put("INSPECTION_GROUP_ID", inspectionGroupId);
|
|
|
|
// 불량 정보 컬럼은 빈값으로
|
|
sqlParamMap.put("DEFECT_QTY", "0");
|
|
sqlParamMap.put("DEFECT_TYPE", "");
|
|
sqlParamMap.put("DEFECT_CAUSE", "");
|
|
sqlParamMap.put("RESPONSIBLE_DEPT", "");
|
|
sqlParamMap.put("PROCESS_STATUS", "");
|
|
sqlParamMap.put("INSPECTION_DATE", "");
|
|
sqlParamMap.put("INSPECTOR", "");
|
|
sqlParamMap.put("DISPOSITION_TYPE", "");
|
|
sqlParamMap.put("REMARK", "");
|
|
|
|
// 잠금 여부 설정
|
|
sqlParamMap.put("IS_LOCKED", lockData);
|
|
|
|
// UPSERT: UPDATE 시도 후 실패하면 INSERT
|
|
int updateCnt = sqlSession.update("quality.updateSemiProductInspectionData", sqlParamMap);
|
|
if(updateCnt == 0){
|
|
// UPDATE 실패 시 INSERT (신규 데이터)
|
|
sqlSession.insert("quality.insertSemiProductInspectionData", sqlParamMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 양품 데이터를 ROW_ID 기준 Map으로 변환 (불량 데이터 매칭용)
|
|
Map leftDataMap = new HashMap(); // ROW_ID -> leftData 아이템
|
|
if(leftDataStr != null && !leftDataStr.equals("") && !leftDataStr.equals("[]")){
|
|
org.json.simple.JSONArray leftArrForMap = (org.json.simple.JSONArray) parser.parse(leftDataStr);
|
|
for(int i = 0; i < leftArrForMap.size(); i++){
|
|
org.json.simple.JSONObject leftItem = (org.json.simple.JSONObject) leftArrForMap.get(i);
|
|
String rowId = CommonUtils.checkNull(leftItem.get("ROW_ID"));
|
|
if(!rowId.equals("")){
|
|
leftDataMap.put(rowId, leftItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 불량 정보 (rightData) 저장 - PARENT_ROW_ID를 기반으로 해당 양품 정보와 매칭
|
|
if(rightDataStr != null && !rightDataStr.equals("") && !rightDataStr.equals("[]")){
|
|
org.json.simple.JSONArray rightArr = (org.json.simple.JSONArray) parser.parse(rightDataStr);
|
|
for(int i = 0; i < rightArr.size(); i++){
|
|
org.json.simple.JSONObject item = (org.json.simple.JSONObject) rightArr.get(i);
|
|
|
|
// PARENT_ROW_ID로 해당 양품 정보 찾기
|
|
String parentRowId = CommonUtils.checkNull(item.get("PARENT_ROW_ID"));
|
|
org.json.simple.JSONObject parentItem = (org.json.simple.JSONObject) leftDataMap.get(parentRowId);
|
|
|
|
// 부모 양품 정보에서 값 추출
|
|
String workOrderNo = "";
|
|
String modelName = "";
|
|
String productType = "";
|
|
String partNo = "";
|
|
String partName = "";
|
|
|
|
if(parentItem != null){
|
|
// 좌측 데이터가 함께 전송된 경우 (전체 저장)
|
|
workOrderNo = CommonUtils.checkNull(parentItem.get("WORK_ORDER_NO"));
|
|
modelName = CommonUtils.checkNull(parentItem.get("MODEL_NAME"));
|
|
productType = CommonUtils.checkNull(parentItem.get("PRODUCT_TYPE"));
|
|
partNo = CommonUtils.checkNull(parentItem.get("PART_NO"));
|
|
partName = CommonUtils.checkNull(parentItem.get("PART_NAME"));
|
|
} else {
|
|
// 우측만 저장하는 경우: item에 직접 부모 정보가 포함되어 있음
|
|
workOrderNo = CommonUtils.checkNull(item.get("WORK_ORDER_NO"));
|
|
modelName = CommonUtils.checkNull(item.get("MODEL_NAME"));
|
|
productType = CommonUtils.checkNull(item.get("PRODUCT_TYPE"));
|
|
partNo = CommonUtils.checkNull(item.get("PART_NO"));
|
|
partName = CommonUtils.checkNull(item.get("PART_NAME"));
|
|
}
|
|
|
|
// OBJID 처리
|
|
String existingObjId = CommonUtils.checkNull(item.get("OBJID"));
|
|
String objId = existingObjId;
|
|
|
|
// OBJID가 비어있으면 새로 생성
|
|
if(objId.equals("") || objId.startsWith("DEFECT_") || objId.startsWith("NEW_")){
|
|
objId = CommonUtils.createObjId();
|
|
}
|
|
|
|
existingRightObjIds.add(objId); // 우측 OBJID 목록에 추가
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("OBJID", objId);
|
|
sqlParamMap.put("DEFECT_QTY", CommonUtils.checkNull(item.get("DEFECT_QTY"), "0"));
|
|
sqlParamMap.put("DEFECT_TYPE", CommonUtils.checkNull(item.get("DEFECT_TYPE")));
|
|
sqlParamMap.put("DEFECT_CAUSE", CommonUtils.checkNull(item.get("DEFECT_CAUSE")));
|
|
sqlParamMap.put("RESPONSIBLE_DEPT", CommonUtils.checkNull(item.get("RESPONSIBLE_DEPT")));
|
|
sqlParamMap.put("PROCESS_STATUS", CommonUtils.checkNull(item.get("PROCESS_STATUS")));
|
|
sqlParamMap.put("INSPECTION_DATE", CommonUtils.checkNull(item.get("INSPECTION_DATE")));
|
|
sqlParamMap.put("INSPECTOR", CommonUtils.checkNull(item.get("INSPECTOR")));
|
|
sqlParamMap.put("DISPOSITION_TYPE", CommonUtils.checkNull(item.get("DISPOSITION_TYPE")));
|
|
sqlParamMap.put("REMARK", CommonUtils.checkNull(item.get("REMARK")));
|
|
sqlParamMap.put("WRITER", writer);
|
|
sqlParamMap.put("DATA_TYPE", "DEFECT");
|
|
sqlParamMap.put("INSPECTION_GROUP_ID", inspectionGroupId);
|
|
|
|
// 해당 양품 데이터와 연결 (부모 정보 복사)
|
|
sqlParamMap.put("WORK_ORDER_NO", workOrderNo);
|
|
sqlParamMap.put("MODEL_NAME", modelName);
|
|
sqlParamMap.put("PRODUCT_TYPE", productType);
|
|
sqlParamMap.put("PART_NO", partNo);
|
|
sqlParamMap.put("PART_NAME", partName);
|
|
sqlParamMap.put("RECEIPT_QTY", "0");
|
|
sqlParamMap.put("GOOD_QTY", "0");
|
|
|
|
// 잠금 여부 설정
|
|
sqlParamMap.put("IS_LOCKED", lockData);
|
|
|
|
// UPSERT: UPDATE 시도 후 실패하면 INSERT
|
|
int updateCnt = sqlSession.update("quality.updateSemiProductInspectionData", sqlParamMap);
|
|
if(updateCnt == 0){
|
|
// UPDATE 실패 시 INSERT (신규 데이터)
|
|
sqlSession.insert("quality.insertSemiProductInspectionData", sqlParamMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 수정 모드일 때: 자동 삭제 비활성화 (사용자가 직접 삭제 버튼으로만 삭제)
|
|
// 데이터 손실 방지를 위해 자동 삭제 로직 제거
|
|
// 삭제는 사용자가 그리드에서 행을 선택하고 삭제 버튼을 누를 때만 수행
|
|
/*
|
|
if(!existingGroupId.equals("")){
|
|
Map deleteParam = new HashMap();
|
|
deleteParam.put("INSPECTION_GROUP_ID", inspectionGroupId);
|
|
|
|
if("left".equals(saveType)){
|
|
if(existingLeftObjIds.size() > 0){
|
|
deleteParam.put("EXCLUDE_OBJIDS", existingLeftObjIds);
|
|
deleteParam.put("DATA_TYPE", "GOOD");
|
|
sqlSession.delete("quality.deleteSemiProductInspectionByType", deleteParam);
|
|
}
|
|
} else if("right".equals(saveType)){
|
|
if(existingRightObjIds.size() > 0){
|
|
deleteParam.put("EXCLUDE_OBJIDS", existingRightObjIds);
|
|
deleteParam.put("DATA_TYPE", "DEFECT");
|
|
sqlSession.delete("quality.deleteSemiProductInspectionByType", deleteParam);
|
|
}
|
|
} else {
|
|
java.util.Set allObjIds = new java.util.HashSet();
|
|
allObjIds.addAll(existingLeftObjIds);
|
|
allObjIds.addAll(existingRightObjIds);
|
|
deleteParam.put("EXCLUDE_OBJIDS", allObjIds);
|
|
sqlSession.delete("quality.deleteSemiProductInspectionExcludeObjIds", deleteParam);
|
|
}
|
|
}
|
|
*/
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", "저장되었습니다.");
|
|
resultMap.put("inspectionGroupId", inspectionGroupId); // 생성된 그룹 ID 반환
|
|
}catch(Exception e){
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", "저장 중 오류가 발생했습니다: " + e.getMessage());
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 품명(모델명) 드롭박스 목록
|
|
*/
|
|
public List getSemiProductModelNameList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductModelNameList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 부품품번 드롭박스 목록
|
|
*/
|
|
public List getSemiProductPartNoList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductPartNoList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 부품명 드롭박스 목록
|
|
*/
|
|
public List getSemiProductPartNameList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductPartNameList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 검사일 드롭박스 목록
|
|
*/
|
|
public List getSemiProductInspectionDateList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductInspectionDateList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 반제품검사 검사자 드롭박스 목록
|
|
*/
|
|
public List getSemiProductWriterList(Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getSemiProductWriterList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
// =====================================================
|
|
// 고객 CS 관리
|
|
// =====================================================
|
|
|
|
/**
|
|
* 고객 CS 목록 조회
|
|
*/
|
|
public List getCustomerCsList(HttpServletRequest request, Map paramMap){
|
|
List resultList = new ArrayList();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getCustomerCsList", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 고객 CS 상세 조회
|
|
*/
|
|
public Map getCustomerCsInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getCustomerCsInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 고객 불량 저장
|
|
*/
|
|
public Map saveCustomerCsDefect(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = person != null ? person.getUserId() : "";
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("OBJID"));
|
|
String isNew = CommonUtils.checkNull(paramMap.get("IS_NEW"));
|
|
paramMap.put("WRITER", writer);
|
|
|
|
// IS_NEW 플래그로 신규/수정 구분 (JSP에서 전달)
|
|
if("true".equals(isNew)){
|
|
// 신규 등록
|
|
if(objId.isEmpty()){
|
|
objId = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
paramMap.put("OBJID", objId);
|
|
}
|
|
|
|
// 접수번호 생성 (CS-YYYYMMDD-SEQ)
|
|
String today = new java.text.SimpleDateFormat("yyyyMMdd").format(new java.util.Date());
|
|
String receiptNo = "CS-" + today + "-" + String.format("%03d", sqlSession.selectOne("quality.getCustomerCsSeq"));
|
|
paramMap.put("RECEIPT_NO", receiptNo);
|
|
|
|
sqlSession.insert("quality.insertCustomerCs", paramMap);
|
|
} else {
|
|
// 수정
|
|
sqlSession.update("quality.updateCustomerCs", paramMap);
|
|
}
|
|
|
|
resultMap.put("RESULT", "SUCCESS");
|
|
resultMap.put("OBJID", objId);
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
resultMap.put("RESULT", "FAIL");
|
|
resultMap.put("MESSAGE", e.getMessage());
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 조치결과 저장
|
|
*/
|
|
public Map saveCustomerCsAction(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String actionUserId = person != null ? person.getUserId() : "";
|
|
|
|
paramMap.put("ACTION_USER_ID", actionUserId);
|
|
|
|
sqlSession.update("quality.updateCustomerCsAction", paramMap);
|
|
|
|
resultMap.put("RESULT", "SUCCESS");
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
resultMap.put("RESULT", "FAIL");
|
|
resultMap.put("MESSAGE", e.getMessage());
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
// =====================================================
|
|
// ECR 관리
|
|
// =====================================================
|
|
|
|
|
|
/**
|
|
* ECR 상세 조회
|
|
*/
|
|
public Map getEcrInfo(Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultMap = sqlSession.selectOne("quality.getEcrInfo", paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
sqlSession.close();
|
|
}
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* ECR 저장 (등록/수정)
|
|
*/
|
|
public Map saveEcr(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
// 작성자 정보 설정
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = person != null ? person.getUserId() : "";
|
|
|
|
String objId = CommonUtils.checkNull(paramMap.get("OBJID"));
|
|
String isNew = CommonUtils.checkNull(paramMap.get("IS_NEW"));
|
|
paramMap.put("WRITER", writer);
|
|
|
|
// IS_NEW 플래그로 신규/수정 구분
|
|
if("true".equals(isNew)){
|
|
// 신규 등록
|
|
if(objId.isEmpty()){
|
|
objId = CommonUtils.checkNull(CommonUtils.createObjId());
|
|
paramMap.put("OBJID", objId);
|
|
}
|
|
|
|
// ECR_NO 생성 (ECR-YYYYMM-순번) 예) ECR-202512-01
|
|
String yyyymm = new java.text.SimpleDateFormat("yyyyMM").format(new java.util.Date());
|
|
paramMap.put("YYYYMM", yyyymm);
|
|
Integer seq = sqlSession.selectOne("quality.getEcrSeq", paramMap);
|
|
if(seq == null) seq = 1;
|
|
String ecrNo = "ECR-" + yyyymm + "-" + String.format("%02d", seq);
|
|
paramMap.put("ECR_NO", ecrNo);
|
|
paramMap.put("ATTACH_FILE_OBJID", objId);
|
|
|
|
sqlSession.insert("quality.insertEcr", paramMap);
|
|
} else {
|
|
// 수정
|
|
sqlSession.update("quality.updateEcr", paramMap);
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("RESULT", "SUCCESS");
|
|
resultMap.put("MESSAGE", "저장되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
resultMap.put("RESULT", "FAIL");
|
|
resultMap.put("MESSAGE", e.getMessage());
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* ECR 결과 저장
|
|
*/
|
|
public Map saveEcrResult(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
// 작성자 정보 설정
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = person != null ? person.getUserId() : "";
|
|
paramMap.put("MODIFIER", writer);
|
|
|
|
sqlSession.update("quality.updateEcrResult", paramMap);
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("RESULT", "SUCCESS");
|
|
resultMap.put("MESSAGE", "저장되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
resultMap.put("RESULT", "FAIL");
|
|
resultMap.put("MESSAGE", e.getMessage());
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/**
|
|
* 설계변경요청서 저장
|
|
*/
|
|
public Map saveEcrDoc(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
// 작성자 정보 설정
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = person != null ? person.getUserId() : "";
|
|
paramMap.put("MODIFIER", writer);
|
|
|
|
sqlSession.update("quality.updateEcrDoc", paramMap);
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", "success");
|
|
resultMap.put("message", "저장되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
resultMap.put("result", "fail");
|
|
resultMap.put("message", e.getMessage());
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
/*edhwang start*/
|
|
|
|
/*edhwang end*/
|
|
|
|
// =====================================================
|
|
// 수입검사 불량상세 관련
|
|
// =====================================================
|
|
|
|
/**
|
|
* 불량상세 목록 조회
|
|
*/
|
|
public List getIncomingInspectionDefectList(Map paramMap){
|
|
SqlSession sqlSession = null;
|
|
List resultList = new ArrayList();
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
resultList = sqlSession.selectList("quality.getIncomingInspectionDefectList", paramMap);
|
|
resultList = CommonUtils.keyChangeUpperList(resultList);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
/**
|
|
* 수입검사 진행 저장 (입고품목 + 불량상세)
|
|
*/
|
|
public Map saveIncomingInspectionProgress(HttpServletRequest request, Map paramMap){
|
|
Map resultMap = new HashMap();
|
|
SqlSession sqlSession = null;
|
|
|
|
try{
|
|
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
|
|
|
// 작성자 정보 설정
|
|
PersonBean person = (PersonBean) request.getSession().getAttribute(Constants.PERSON_BEAN);
|
|
String writer = person != null ? person.getUserId() : "";
|
|
|
|
String purchaseOrderMasterObjid = CommonUtils.checkNull(paramMap.get("PURCHASE_ORDER_MASTER_OBJID"));
|
|
String inspectionDate = CommonUtils.checkNull(paramMap.get("INSPECTION_DATE"));
|
|
String inspectorId = CommonUtils.checkNull(paramMap.get("INSPECTOR_ID"));
|
|
|
|
// 1. 입고품목 데이터 저장 (검사구분 등)
|
|
String dataListJson = CommonUtils.checkNull(paramMap.get("dataListJson"));
|
|
if(!dataListJson.isEmpty()) {
|
|
List<Map<String, Object>> dataList = JsonUtil.JsonToList(dataListJson);
|
|
|
|
for(Map data : dataList) {
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("NEW_OBJID", CommonUtils.createObjId()); // 신규 OBJID 생성
|
|
sqlParamMap.put("OBJID", CommonUtils.checkNull(data.get("OBJID"))); // INVENTORY_MGMT_IN.OBJID
|
|
sqlParamMap.put("PURCHASE_ORDER_MASTER_OBJID", purchaseOrderMasterObjid);
|
|
sqlParamMap.put("INSPECTION_TYPE", CommonUtils.checkNull(data.get("INSPECTION_TYPE")));
|
|
sqlParamMap.put("INSPECTION_DATE", inspectionDate);
|
|
sqlParamMap.put("INSPECTOR_ID", inspectorId);
|
|
sqlParamMap.put("INSPECTION_QTY", CommonUtils.checkNull(data.get("INSPECTION_QTY"))); // 검사수량
|
|
sqlParamMap.put("DEFECT_QTY", CommonUtils.checkNull(data.get("DEFECT_QTY_SUM"))); // 불량수량 합계
|
|
sqlParamMap.put("WRITER", writer);
|
|
|
|
sqlSession.update("quality.saveIncomingInspectionDetail", sqlParamMap);
|
|
}
|
|
}
|
|
|
|
// 2. 불량상세 데이터 저장
|
|
String defectListJson = CommonUtils.checkNull(paramMap.get("defectListJson"));
|
|
String selectedDetailObjid = CommonUtils.checkNull(paramMap.get("selectedDetailObjid"));
|
|
|
|
if(!defectListJson.isEmpty() && !selectedDetailObjid.isEmpty()) {
|
|
List<Map<String, Object>> defectList = JsonUtil.JsonToList(defectListJson);
|
|
|
|
for(Map defect : defectList) {
|
|
String gridStatus = CommonUtils.checkNull(defect.get("GRID_STATUS"));
|
|
|
|
Map sqlParamMap = new HashMap();
|
|
sqlParamMap.put("OBJID", CommonUtils.checkNull(defect.get("OBJID")));
|
|
sqlParamMap.put("INSPECTION_DETAIL_OBJID", selectedDetailObjid);
|
|
sqlParamMap.put("INSPECTION_TYPE", CommonUtils.checkNull(defect.get("INSPECTION_TYPE")));
|
|
sqlParamMap.put("INSPECTION_DATE", CommonUtils.checkNull(defect.get("INSPECTION_DATE")));
|
|
sqlParamMap.put("INSPECTOR_ID", CommonUtils.checkNull(defect.get("INSPECTOR_ID")));
|
|
sqlParamMap.put("DEFECT_TYPE", CommonUtils.checkNull(defect.get("DEFECT_TYPE")));
|
|
sqlParamMap.put("DEFECT_REASON", CommonUtils.checkNull(defect.get("DEFECT_REASON")));
|
|
sqlParamMap.put("ACTION_STATUS", CommonUtils.checkNull(defect.get("ACTION_STATUS")));
|
|
sqlParamMap.put("ACTION_RESULT", CommonUtils.checkNull(defect.get("ACTION_RESULT")));
|
|
sqlParamMap.put("INSPECTION_QTY", CommonUtils.checkNull(defect.get("INSPECTION_QTY")));
|
|
sqlParamMap.put("DEFECT_QTY", CommonUtils.checkNull(defect.get("DEFECT_QTY")));
|
|
sqlParamMap.put("INSPECTION_RESULT", CommonUtils.checkNull(defect.get("INSPECTION_RESULT")));
|
|
sqlParamMap.put("REMARK", CommonUtils.checkNull(defect.get("REMARK")));
|
|
sqlParamMap.put("WRITER", writer);
|
|
|
|
if("D".equals(gridStatus)) {
|
|
// 삭제
|
|
sqlSession.delete("quality.deleteIncomingInspectionDefect", sqlParamMap);
|
|
} else {
|
|
// 신규/수정
|
|
sqlSession.insert("quality.saveIncomingInspectionDefect", sqlParamMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlSession.commit();
|
|
resultMap.put("result", true);
|
|
resultMap.put("msg", "저장되었습니다.");
|
|
|
|
}catch(Exception e){
|
|
if(sqlSession != null) sqlSession.rollback();
|
|
resultMap.put("result", false);
|
|
resultMap.put("msg", e.getMessage());
|
|
e.printStackTrace();
|
|
}finally{
|
|
if(sqlSession != null) sqlSession.close();
|
|
}
|
|
|
|
return resultMap;
|
|
}
|
|
|
|
}
|