생산관리
This commit is contained in:
@@ -957,6 +957,7 @@ public class PartMngController {
|
||||
String sourceBomObjId = CommonUtils.checkNull((String)paramMap.get("sourceBomObjId"));
|
||||
String targetPartNo = CommonUtils.checkNull((String)paramMap.get("targetPartNo"));
|
||||
String targetPartName = CommonUtils.checkNull((String)paramMap.get("targetPartName"));
|
||||
String productCode = CommonUtils.checkNull((String)paramMap.get("productCode")); // 제품구분
|
||||
List<Map<String, Object>> bomData = (List<Map<String, Object>>)paramMap.get("bomData");
|
||||
|
||||
if(bomData == null || bomData.isEmpty()) {
|
||||
@@ -974,16 +975,80 @@ public class PartMngController {
|
||||
saveParam.put("BOM_DATA", bomData);
|
||||
saveParam.put("USER_ID", userId);
|
||||
|
||||
// SqlSession을 통해 직접 실행
|
||||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
// M-BOM 품번 자동 생성
|
||||
// E-BOM 선택 시: M-{E-BOM 품번}-YYMMDD-01
|
||||
// M-BOM 선택 시: 기존 M-BOM 품번에서 YYMMDD-순번만 업데이트
|
||||
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyMMdd");
|
||||
String dateStr = dateFormat.format(new java.util.Date());
|
||||
|
||||
String mbomPartNo = "";
|
||||
String sourceBomType = CommonUtils.checkNull((String)paramMap.get("sourceBomType"));
|
||||
|
||||
// 제품구분 확인 (Machine 여부)
|
||||
// Machine 제품코드: COMM_CODE 테이블에서 확인 필요 (예: 0001807, MACHINE 등)
|
||||
boolean isMachine = productCode != null && (
|
||||
productCode.equals("0001807") ||
|
||||
productCode.toUpperCase().contains("MACHINE")
|
||||
);
|
||||
|
||||
// M-BOM 품번 prefix 생성
|
||||
String mbomPrefix = "";
|
||||
|
||||
if("EBOM".equals(sourceBomType)) {
|
||||
// E-BOM 선택: M-{E-BOM 품번}-YYMMDD-순번
|
||||
mbomPrefix = "M-" + targetPartNo + "-" + dateStr;
|
||||
} else if("MBOM".equals(sourceBomType)) {
|
||||
// M-BOM 선택: 기존 M-BOM 품번에서 날짜-순번만 업데이트
|
||||
String existingMbomPartNo = CommonUtils.checkNull((String)paramMap.get("existingMbomPartNo"));
|
||||
if(!"".equals(existingMbomPartNo) && existingMbomPartNo.startsWith("M-")) {
|
||||
// M-{품번} 부분 추출 (마지막 두 개의 대시 앞부분)
|
||||
int lastDashIndex = existingMbomPartNo.lastIndexOf("-");
|
||||
if(lastDashIndex > 0) {
|
||||
int secondLastDashIndex = existingMbomPartNo.lastIndexOf("-", lastDashIndex - 1);
|
||||
if(secondLastDashIndex > 0) {
|
||||
String partPrefix = existingMbomPartNo.substring(0, secondLastDashIndex);
|
||||
mbomPrefix = partPrefix + "-" + dateStr;
|
||||
} else {
|
||||
mbomPrefix = "M-" + targetPartNo + "-" + dateStr;
|
||||
}
|
||||
} else {
|
||||
mbomPrefix = "M-" + targetPartNo + "-" + dateStr;
|
||||
}
|
||||
} else {
|
||||
mbomPrefix = "M-" + targetPartNo + "-" + dateStr;
|
||||
}
|
||||
} else {
|
||||
// 기본값
|
||||
mbomPrefix = "M-" + targetPartNo + "-" + dateStr;
|
||||
}
|
||||
|
||||
// 같은 날짜의 최대 순번 조회
|
||||
SqlSession sqlSession = null;
|
||||
int maxSeq = 0;
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
Map<String, Object> seqParam = new HashMap<String, Object>();
|
||||
seqParam.put("prefix", mbomPrefix);
|
||||
Integer maxSeqResult = sqlSession.selectOne("productionplanning.getMaxMbomSeqByDate", seqParam);
|
||||
if(maxSeqResult != null) {
|
||||
maxSeq = maxSeqResult.intValue();
|
||||
}
|
||||
|
||||
// 순번 증가
|
||||
int newSeq = maxSeq + 1;
|
||||
mbomPartNo = mbomPrefix + "-" + String.format("%02d", newSeq);
|
||||
|
||||
saveParam.put("MBOM_PART_NO", mbomPartNo);
|
||||
saveParam.put("IS_MACHINE", isMachine ? "Y" : "N");
|
||||
|
||||
// M-BOM 저장 실행
|
||||
sqlSession.insert("productionplanning.saveMbomFromEbom", saveParam);
|
||||
sqlSession.commit();
|
||||
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("message", "M-BOM이 성공적으로 생성되었습니다.");
|
||||
// M-BOM 품번과 저장일 추가 (부모 창 검색 조건에 사용)
|
||||
resultMap.put("mbomPartNo", targetPartNo);
|
||||
resultMap.put("mbomPartNo", mbomPartNo); // 자동 생성된 M-BOM 품번
|
||||
// 현재 날짜를 YYYY-MM-DD 형식으로 반환
|
||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
||||
resultMap.put("saveDate", sdf.format(new java.util.Date()));
|
||||
|
||||
Reference in New Issue
Block a user