Compare commits

...

2 Commits

Author SHA1 Message Date
강석 최 5757374e02 Merge branch 'master' of http://118.219.150.34:50501/DBNT/FAISP 2022-11-08 09:37:55 +09:00
강석 최 d8fe4f4930 중간저장/ 2022-11-08 09:37:52 +09:00
2 changed files with 25 additions and 56 deletions

View File

@ -96,8 +96,7 @@ public class FishingBoatController {
@PostMapping("/saveFishingBoat") @PostMapping("/saveFishingBoat")
public Integer saveFishingBoat(@AuthenticationPrincipal UserInfo loginUser, CrackdownStatus crackdownStatus){ public Integer saveFishingBoat(@AuthenticationPrincipal UserInfo loginUser, CrackdownStatus crackdownStatus){
return 0; return fishingBoatService.saveCrackdownStatus(crackdownStatus);
// return processResultService.saveProcessResult(processResult);
} }
@GetMapping("/checkCaseNum") @GetMapping("/checkCaseNum")

View File

@ -39,64 +39,34 @@ public class FishingBoatService extends BaseService {
@Transactional @Transactional
public Integer saveCrackdownStatus(CrackdownStatus crackdownStatus) { public Integer saveCrackdownStatus(CrackdownStatus crackdownStatus) {
if (crackdownStatus.getViolationDeleteKeyList() != null) { Integer cdsKey, fbKey;
violationRepository.deleteAllByIdInQuery(crackdownStatus.getViolationDeleteKeyList()); if (crackdownStatus.getCdsKey()==null || crackdownStatus.getCdsKey().equals(0)){
} // 최초 등록시 단속현황, 처리현황, 선원정보를 같이 등록.
if (crackdownStatus.getSailorDeleteKeyList() != null) { cdsKey = crackdownStatusRepository.save(crackdownStatus).getCdsKey();
sailorRepository.deleteAllByIdInQuery(crackdownStatus.getSailorDeleteKeyList()); FishingBoat fishingBoat = crackdownStatus.getFishingBoat();
} fishingBoat.setCdsKey(cdsKey);
fbKey = fishingBoatRepository.save(fishingBoat).getFbKey();
if (crackdownStatus.getCrackdownBoatEtc() != null) { List<Violation> violationList = crackdownStatus.getViolationList();
crackdownStatus.setCrackdownBoat(crackdownStatus.getCrackdownBoatEtc()); int i = 1;
} for(Violation violation: violationList){
if (crackdownStatus.getCrackdownPoliceEtc() != null) { violation.setViolationKey(i++);
crackdownStatus.setCrackdownPolice(crackdownStatus.getCrackdownPoliceEtc()); violation.setFbKey(fbKey);
}
Integer cdsKey = crackdownStatusRepository.save(crackdownStatus).getCdsKey();
if (crackdownStatus.getFishingBoat() != null) {
if (crackdownStatus.getFishingBoat().getBoatMaterialEtc() != null) {
crackdownStatus.getFishingBoat().setBoatMaterial(crackdownStatus.getFishingBoat().getBoatMaterialEtc());
} }
if (crackdownStatus.getFishingBoat().getFisheryTypeEtc() != null) { violationRepository.saveAll(violationList);
crackdownStatus.getFishingBoat().setFisheryType(crackdownStatus.getFishingBoat().getFisheryTypeEtc()); List<Sailor> sailorList = crackdownStatus.getSailorList();
i = 1;
for(Sailor sailor: sailorList){
sailor.setSailorKey(i++);
sailor.setFbKey(fbKey);
} }
sailorRepository.saveAll(sailorList);
}else{
// 업데이트시에는 어선정보만 수정.
cdsKey = crackdownStatus.getCdsKey();
FishingBoat oldInfo = fishingBoatRepository.findById(crackdownStatus.getFishingBoat().getFbKey()).orElse(null);
crackdownStatus.getFishingBoat().setCdsKey(cdsKey); fbKey = fishingBoatRepository.save(crackdownStatus.getFishingBoat()).getFbKey();
Integer fbKey = fishingBoatRepository.save(crackdownStatus.getFishingBoat()).getFbKey();
crackdownStatus.getFishingBoat().setFbKey(fbKey);
} }
if (crackdownStatus.getProcessResult() != null) {
if (crackdownStatus.getProcessResult().getProcessStatusEtc() != null) {
crackdownStatus.getProcessResult().setProcessStatus(crackdownStatus.getProcessResult().getProcessStatusEtc());
}
crackdownStatus.getProcessResult().setCdsKey(cdsKey);
Integer prKey = processResultRepository.save(crackdownStatus.getProcessResult()).getPrKey();
crackdownStatus.getProcessResult().setPrKey(prKey);
}
/*if (internationalCrimeArrest.getDeleteSpiKeyList() != null) {
suspectPersonInfoRepository.deleteAllByIdInQuery(internationalCrimeArrest.getDeleteSpiKeyList());
}*/
if (crackdownStatus.getViolationList() != null) {
for(Violation violation: crackdownStatus.getViolationList()){
if (violation.getViolationEtc() != null) {
violation.setViolation(violation.getViolationEtc());
}
violation.setFbKey(crackdownStatus.getFishingBoat().getFbKey());
}
violationRepository.saveAll(crackdownStatus.getViolationList());
}
if (crackdownStatus.getSailorList() != null) {
for(Sailor sailor: crackdownStatus.getSailorList()){
sailor.setFbKey(crackdownStatus.getFishingBoat().getFbKey());
}
sailorRepository.saveAll(crackdownStatus.getSailorList());
}
return cdsKey; return cdsKey;
} }