/**
* Ajax BOM 등록
*/
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor={Exception.class})
public String insertBomWrite(BomVO bomVO) throws Exception{
//1. 널 체크 및 등록된 자재 코드 확인
if(bomVO.getPcode()==null || StringUtils.isEmpty(bomVO.getProductName())) return "blank";
List<BomVO> list=new ArrayList<BomVO>();
for(BomVO vo : bomVO.getList()) {
if(vo.getMcode()==null || StringUtils.isEmpty(vo.getMcode())) return "blank";
if(vo.getMaterialName()==null || StringUtils.isEmpty(vo.getMaterialName())) return "blank";
if(vo.getMaterialQuantity()==null || StringUtils.isEmpty(vo.getMaterialQuantity())) return "blank";
BomVO bomVoInfo=new BomVO();
//mid 아이디 값 가져오기
bomVoInfo=managementDao.getByMcodeInfo(vo.getMcode());
if(bomVoInfo==null) return "notcode"; //등록 되지 않은 자재 코드
bomVoInfo.setMaterialName(vo.getMaterialName());
bomVoInfo.setMaterialQuantity(vo.getMaterialQuantity());
list.add(bomVoInfo);
}
//2.BOM 제품 등록 , BOM 제품 중복 코드 확인
try {
managementDao.insertBomProduct(bomVO);
}catch(Exception e) {
if(e.getMessage().contains("Duplicate")) return "duplicate";
throw new Exception(); //예외 발생시 롤백 처리
}
try {
//3.BOM 자재 등록
managementDao.insertBomMaterial(list);
return "success";
}catch (Exception e) {
throw new Exception(); //예외 발생시 롤백 처리
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor={Exception.class})
throw new Exception(); //예외 발생시 롤백 처리

















댓글 ( 4)
댓글 남기기