중간저장/

강석 최 2022-11-08 09:37:52 +09:00
parent 80156cacba
commit d8fe4f4930
2 changed files with 25 additions and 56 deletions

View File

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

View File

@ -39,64 +39,34 @@ public class FishingBoatService extends BaseService {
@Transactional
public Integer saveCrackdownStatus(CrackdownStatus crackdownStatus) {
if (crackdownStatus.getViolationDeleteKeyList() != null) {
violationRepository.deleteAllByIdInQuery(crackdownStatus.getViolationDeleteKeyList());
Integer cdsKey, fbKey;
if (crackdownStatus.getCdsKey()==null || crackdownStatus.getCdsKey().equals(0)){
// 최초 등록시 단속현황, 처리현황, 선원정보를 같이 등록.
cdsKey = crackdownStatusRepository.save(crackdownStatus).getCdsKey();
FishingBoat fishingBoat = crackdownStatus.getFishingBoat();
fishingBoat.setCdsKey(cdsKey);
fbKey = fishingBoatRepository.save(fishingBoat).getFbKey();
List<Violation> violationList = crackdownStatus.getViolationList();
int i = 1;
for(Violation violation: violationList){
violation.setViolationKey(i++);
violation.setFbKey(fbKey);
}
if (crackdownStatus.getSailorDeleteKeyList() != null) {
sailorRepository.deleteAllByIdInQuery(crackdownStatus.getSailorDeleteKeyList());
violationRepository.saveAll(violationList);
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);
if (crackdownStatus.getCrackdownBoatEtc() != null) {
crackdownStatus.setCrackdownBoat(crackdownStatus.getCrackdownBoatEtc());
fbKey = fishingBoatRepository.save(crackdownStatus.getFishingBoat()).getFbKey();
}
if (crackdownStatus.getCrackdownPoliceEtc() != null) {
crackdownStatus.setCrackdownPolice(crackdownStatus.getCrackdownPoliceEtc());
}
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) {
crackdownStatus.getFishingBoat().setFisheryType(crackdownStatus.getFishingBoat().getFisheryTypeEtc());
}
crackdownStatus.getFishingBoat().setCdsKey(cdsKey);
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;
}