diff --git a/src/main/java/com/dbnt/faisp/config/FileController.java b/src/main/java/com/dbnt/faisp/config/FileController.java index de8773c9..6b49c312 100644 --- a/src/main/java/com/dbnt/faisp/config/FileController.java +++ b/src/main/java/com/dbnt/faisp/config/FileController.java @@ -2,6 +2,7 @@ package com.dbnt.faisp.config; import com.dbnt.faisp.fpiMgt.affair.service.AffairService; import com.dbnt.faisp.fpiMgt.affairPlan.service.PlanService; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.service.BoardInvestigationService; import com.dbnt.faisp.publicBoard.service.PublicBoardService; import lombok.RequiredArgsConstructor; import org.springframework.util.FileCopyUtils; @@ -20,6 +21,7 @@ public class FileController { private final PlanService planService; private final PublicBoardService publicBoardService; private final AffairService affairService; + private final BoardInvestigationService boardInvestigationService; @GetMapping("/file/fileDownload") public void fileDownload(HttpServletRequest request, @@ -38,6 +40,9 @@ public class FileController { case "affair": downloadFile = affairService.selectAffairFile(parentKey, fileSeq); break; + case "ivsgt": + downloadFile = boardInvestigationService.selectIvsgtFile(parentKey, fileSeq); + break; } BufferedInputStream in; diff --git a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java index 63715cdf..ed39d559 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java @@ -5,6 +5,7 @@ import com.dbnt.faisp.authMgt.service.AuthMgtService; import com.dbnt.faisp.fipTarget.model.PartInfo; import com.dbnt.faisp.fipTarget.model.PartInfoFile; import com.dbnt.faisp.fipTarget.model.PartWork; +import com.dbnt.faisp.fipTarget.model.PartWorkFile; import com.dbnt.faisp.fipTarget.service.FipTargetService; import com.dbnt.faisp.organMgt.service.OrganConfigService; import com.dbnt.faisp.userInfo.model.UserInfo; @@ -175,15 +176,12 @@ public class FipTargetController { } @GetMapping("/partInfoFileDownload") - public void fileDownload(HttpServletRequest request, + public void partInfoFileDownload(HttpServletRequest request, HttpServletResponse response, Integer fileSeq, Integer piSeq, Integer versionNo) { - PartInfoFile downloadFile = null; - - downloadFile = fipTargetService.selectPartInfoFileDown(fileSeq, piSeq,versionNo); - + PartInfoFile downloadFile = fipTargetService.selectPartInfoFileDown(fileSeq, piSeq,versionNo); BufferedInputStream in; BufferedOutputStream out; @@ -257,11 +255,26 @@ public class FipTargetController { public ModelAndView partWorkList(@AuthenticationPrincipal UserInfo loginUser,PartWork partWork, HttpServletResponse response) { ModelAndView mav = new ModelAndView("fipTarget/partWorkList"); partWork.setDownOrganCdList(loginUser.getDownOrganCdList()); - - //메뉴권한 확인 + //엑셀다운 + if(partWork.getExcel() != null && partWork.getExcel().equals("Y")){ + String[] headers = { "terminal_nm", "wrt_nm", "work_dt", "work_type_ch", "work_type_poci", "work_type_sri", "work_type_ji", "work_type_mt", "work_type_etc", "description", "file_cnt","wrt_dt"}; + String[] headerNames = { "외사 터미널명", "작성자","일시", "종류", "", "", "", "", "", "비고", "첨부파일", "최근수정일"}; + String[] headerNames2 = { "", "","", "사건처리", "범죄첩보제공", "SRI", "합동점검", "회의", "기타", "", "", ""}; + String[] columnType = { "String", "String","String", "String", "String", "String", "String", "String", "String", "String", "String","String"}; + String sheetName = "외사분실 실적"; + String excelFileName = "외사분실 실적"; + List partWorkList= fipTargetService.selectPartWorkList(partWork); + + try { + Utils.partWorkListToExcel(partWorkList, response, headers, headerNames,headerNames2, columnType, sheetName, excelFileName); + } catch (IOException e) { + + } + return null; + } + //메뉴권한 확인 String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/target/partWorkList").get(0).getAccessAuth(); mav.addObject("accessAuth", accessAuth); - partWork.setQueryInfo(); mav.addObject("partWorkList", fipTargetService.selectPartWorkList(partWork)); partWork.setContentCnt(fipTargetService.selectPartWorkListCnt(partWork)); @@ -313,15 +326,43 @@ public class FipTargetController { MultipartHttpServletRequest request, @RequestParam(value = "fileSeq", required = false) List < Integer > deleteFileSeq){ partWork.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); - partWork.setWrtNm(loginUser.getUserId()); - partWork.setWrtPart(loginUser.getOfcCd()); - partWork.setWrtUserSeq(loginUser.getUserSeq()); - partWork.setWrtOrgan(loginUser.getOgCd()); partWork.setWrtDt(LocalDateTime.now()); fipTargetService.updatePartWork(partWork,deleteFileSeq); return partWork; } + @PostMapping("/deletePartWork") + @ResponseBody + public void deletePartWork(@RequestBody PartWork partWork) { + fipTargetService.deletePartWork(partWork); + } + + @GetMapping("/partWorkFileDownload") + public void partWorkFileDownload(HttpServletRequest request, + HttpServletResponse response, + Integer fileSeq, + Integer pwSeq, + Integer piSeq) { + PartWorkFile downloadFile = fipTargetService.selectPartWorkFileDown(fileSeq, pwSeq,piSeq); + + BufferedInputStream in; + BufferedOutputStream out; + try { + File file = new File(downloadFile.getFilePath(), downloadFile.getConvNm()); + + setDisposition(downloadFile.getOrigNm()+'.'+downloadFile.getFileExtn(), request, response); + in = new BufferedInputStream(new FileInputStream(file)); + out = new BufferedOutputStream(response.getOutputStream()); + FileCopyUtils.copy(in, out); + out.flush(); + if(out!=null) out.close(); + if(in!=null )in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +//외사분실실적 끝 + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java index 811c1db5..d47c1d2f 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkFileRepository.java @@ -1,9 +1,8 @@ package com.dbnt.faisp.fipTarget.repository; -import com.dbnt.faisp.fipTarget.model.PartInfoFile; import com.dbnt.faisp.fipTarget.model.PartWorkFile; -import com.dbnt.faisp.publicBoard.model.PublicFile; + import java.util.List; @@ -19,6 +18,10 @@ public interface PartWorkFileRepository extends JpaRepository findByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq); + void deleteByPwSeqAndPiSeq(Integer pwSeq, Integer piSeq); + + List findByPiSeq(Integer piSeq); + diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java index 8a5363ad..2fb186be 100644 --- a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartWorkRepository.java @@ -11,6 +11,10 @@ public interface PartWorkRepository extends JpaRepository partWorkFileList = partWorkFileRepository.findByPiSeq(partInfo.getPiSeq()); + if(partWorkFileList != null) { + for(PartWorkFile file: partWorkFileList){ + deleteStoredFile(new File(file.getFilePath(), file.getConvNm())); + partWorkFileRepository.deleteByPwSeqAndPiSeq(file.getPwSeq(),file.getPiSeq()); + } + } + partWorkRepository.deleteByPiSeq(partInfo.getPiSeq()); + //외사분실운영현황파일삭제 List partInfoFileList= selectPartInfoFile(partInfo); for(PartInfoFile file: partInfoFileList){ if(file.getOrigNm() != null){ @@ -276,6 +285,11 @@ public class FipTargetService extends BaseService { @Transactional public void updatePartWork(PartWork partWork, List deleteFileSeq) { + PartWork dbParkWork = partWorkRepository.findById(new PartWorkId(partWork.getPwSeq(),partWork.getPiSeq())).orElse(null); + partWork.setWrtNm(dbParkWork.getWrtNm()); + partWork.setWrtOrgan(dbParkWork.getWrtOrgan()); + partWork.setWrtPart(dbParkWork.getWrtPart()); + partWork.setWrtUserSeq(dbParkWork.getWrtUserSeq()); partWorkRepository.save(partWork); if(deleteFileSeq!=null && deleteFileSeq.size()>0){ deletePartWorkFile(partWork, deleteFileSeq); @@ -294,6 +308,23 @@ public class FipTargetService extends BaseService { } } } + + @Transactional + public void deletePartWork(PartWork partWork) { + //파일삭제 + List partWorkFileList= partWorkFileRepository.findByPwSeqAndPiSeq(partWork.getPwSeq(),partWork.getPiSeq()); + if(partWorkFileList != null) { + for(PartWorkFile file: partWorkFileList){ + deleteStoredFile(new File(file.getFilePath(), file.getConvNm())); + } + } + partWorkFileRepository.deleteByPwSeqAndPiSeq(partWork.getPwSeq(),partWork.getPiSeq()); + partWorkRepository.deleteByPwSeqAndPiSeq(partWork.getPwSeq(),partWork.getPiSeq()); + } + + public PartWorkFile selectPartWorkFileDown(Integer fileSeq, Integer pwSeq, Integer piSeq) { + return partWorkFileRepository.findById(new PartWorkFileId(fileSeq, pwSeq,piSeq)).orElse(null); + } diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/IvsgtController.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/IvsgtController.java new file mode 100644 index 00000000..ecb158f8 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/IvsgtController.java @@ -0,0 +1,79 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation; + +import com.dbnt.faisp.authMgt.service.AuthMgtService; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.ArrestType; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.BoardInvestigation; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.service.BoardInvestigationService; +import com.dbnt.faisp.userInfo.model.UserInfo; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; + +import java.time.LocalDateTime; +import java.util.List; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/ivsgt") +public class IvsgtController { + + private final AuthMgtService authMgtService; + private final BoardInvestigationService boardInvestigationService; + + @GetMapping("/arrest") + public ModelAndView ivsgt(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation) { + ModelAndView mav = new ModelAndView("ivsgt/arrest"); + + //메뉴권한 확인 + String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/ivsgt/arrest").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + + mav.addObject("boardInvestigationList", boardInvestigationService.selectBoardInvestigationList(boardInvestigation)); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + + boardInvestigation.setQueryInfo(); + boardInvestigation.setContentCnt(boardInvestigationService.selectBoardInvestigationListCnt(boardInvestigation)); + boardInvestigation.setPaginationInfo(); + mav.addObject("searchParams", boardInvestigation); + return mav; + } + + @GetMapping("/arrestEditModal") + public ModelAndView arrestEditModal(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation){ + ModelAndView mav = new ModelAndView("ivsgt/arrestEditModal"); + if(boardInvestigation.getIvsgtKey()!=null){ + boardInvestigation = boardInvestigationService.selectBoardInvestigation(boardInvestigation.getIvsgtKey()); + System.out.println(boardInvestigation.toString()); + }else{ + boardInvestigation.setWrtOrgan(loginUser.getOgCd()); + boardInvestigation.setWrtNm(loginUser.getUserNm()); + boardInvestigation.setWrtDt(LocalDateTime.now()); + } + mav.addObject("boardInvestigation", boardInvestigation); + return mav; + } + + @GetMapping("/arrestViewModal") + public ModelAndView arrestViewModal(@AuthenticationPrincipal UserInfo loginUser, BoardInvestigation boardInvestigation){ + ModelAndView mav = new ModelAndView("ivsgt/arrestViewModal"); + boardInvestigation = boardInvestigationService.selectBoardInvestigation(boardInvestigation.getIvsgtKey()); + mav.addObject("boardInvestigation", boardInvestigation); + mav.addObject("userSeq",loginUser.getUserSeq()); + //메뉴권한 확인 + mav.addObject("accessAuth", authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/ivsgt/arrest").get(0).getAccessAuth()); + return mav; + } + + @PostMapping("/saveBoardInvestigation") + public Integer saveBoardInvestigation(@AuthenticationPrincipal UserInfo loginUser, + BoardInvestigation boardInvestigation, + ArrestType arrestType, + MultipartHttpServletRequest request, + @RequestParam(value = "fileSeq", required = false) List deleteFileSeq){ + boardInvestigation.setWrtUserSeq(loginUser.getUserSeq()); + boardInvestigation.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); + return boardInvestigationService.saveBoardInvestigation(boardInvestigation, arrestType, deleteFileSeq); + } +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/mapper/BoardInvestigationMapper.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/mapper/BoardInvestigationMapper.java new file mode 100644 index 00000000..2da33b82 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/mapper/BoardInvestigationMapper.java @@ -0,0 +1,15 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.mapper; + +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.ArrestType; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.BoardInvestigation; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface BoardInvestigationMapper { + List selectBoardInvestigationList(BoardInvestigation boardInvestigation); + Integer selectBoardInvestigationListCnt(BoardInvestigation boardInvestigation); + String selectHashTags(Integer ivsgtKey); + ArrestType selectArrestType(Integer ivsgtKey); +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/ArrestType.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/ArrestType.java new file mode 100644 index 00000000..3ac3fdea --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/ArrestType.java @@ -0,0 +1,35 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.model; + +import com.dbnt.faisp.config.BaseModel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "arrest_type") +public class ArrestType extends BaseModel { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "arrest_type_key") + private Integer arrestTypeKey; + @Column(name = "ivsgt_key") + private Integer ivsgtKey; + @Column(name = "arrest_cd") + private String arrestCd; + @Column(name = "arrest_cd2") + private String arrestCd2; + + @Transient + private String arrestCdName; + @Transient + private String arrestCd2Name; +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/BoardInvestigation.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/BoardInvestigation.java new file mode 100644 index 00000000..698694b3 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/BoardInvestigation.java @@ -0,0 +1,68 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.model; + +import com.dbnt.faisp.config.BaseModel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.multipart.MultipartFile; + +import javax.persistence.*; +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "board_investigation") +public class BoardInvestigation extends BaseModel { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ivsgt_key") + private Integer ivsgtKey; + @Column(name = "ivsgt_type") + private String ivsgtType; + @Column(name = "content_title") + private String contentTitle; + @Column(name = "content_info") + private String contentInfo; + @Column(name = "content_main") + private String contentMain; + @Column(name = "content_status") + private String contentStatus; + @Column(name = "wrt_organ") + private String wrtOrgan; + @Column(name = "wrt_user_seq") + private Integer wrtUserSeq; + @Column(name = "wrt_nm") + private String wrtNm; + @Column(name = "wrt_dt") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + private LocalDateTime wrtDt; + + @Transient + private Integer fileCnt; + @Transient + private List fileList; + @Transient + private List multipartFileList; + @Transient + private List contentInfos; + @Transient + private String hashTags; + @Transient + private ArrestType arrestType; + @Transient + private String arrestCd; + @Transient + private String arrestCd2; + @Transient + private String arrestCdName; + @Transient + private String arrestCd2Name; +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/HashTagLinkIvsgt.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/HashTagLinkIvsgt.java new file mode 100644 index 00000000..de1aee93 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/HashTagLinkIvsgt.java @@ -0,0 +1,36 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.model; + +import lombok.*; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "hash_tag_link_ivsgt") +@IdClass(HashTagLinkIvsgt.HashTagLinkIvsgtId.class) +public class HashTagLinkIvsgt { + @Id + @Column(name = "ivsgt_key") + private Integer ivsgtKey; + @Id + @Column(name = "tag_key") + private Integer tagKey; + + + @Embeddable + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class HashTagLinkIvsgtId implements Serializable { + private Integer ivsgtKey; + private Integer tagKey; + } + +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/IvsgtFile.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/IvsgtFile.java new file mode 100644 index 00000000..86b7beed --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/IvsgtFile.java @@ -0,0 +1,47 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.model; + +import com.dbnt.faisp.config.FileInfo; +import lombok.*; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "ivsgt_file") +@IdClass(IvsgtFile.IvsgtFileId.class) +public class IvsgtFile extends FileInfo { + @Id + @Column(name = "ivsgt_key") + private Integer ivsgtKey; + @Id + @Column(name = "file_seq") + private Integer fileSeq; + @Column(name = "orig_nm") + private String origNm; + @Column(name = "conv_nm") + private String convNm; + @Column(name = "file_extn") + private String fileExtn; + @Column(name = "file_size") + private String fileSize; + @Column(name = "save_path") + private String savePath; + + + @Embeddable + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class IvsgtFileId implements Serializable { + private Integer ivsgtKey; + private Integer fileSeq; + } + +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/parentIvsgt.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/parentIvsgt.java new file mode 100644 index 00000000..1554ca5c --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/model/parentIvsgt.java @@ -0,0 +1,26 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.model; + +import com.dbnt.faisp.config.BaseModel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@Table(name = "parent_ivsgt") +public class parentIvsgt extends BaseModel { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "parent_ivsgt") + private Integer parentIvsgt; + @Column(name = "ivsgt_key") + private String ivsgtKey; +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/ArrestTypeRepository.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/ArrestTypeRepository.java new file mode 100644 index 00000000..cd59d916 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/ArrestTypeRepository.java @@ -0,0 +1,8 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository; + +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.ArrestType; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ArrestTypeRepository extends JpaRepository { + +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/BoardInvestigationRepository.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/BoardInvestigationRepository.java new file mode 100644 index 00000000..5c2304c1 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/BoardInvestigationRepository.java @@ -0,0 +1,8 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository; + +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.BoardInvestigation; +import org.springframework.data.jpa.repository.JpaRepository; + + +public interface BoardInvestigationRepository extends JpaRepository { +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/HashTagLinkIvsgtRepository.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/HashTagLinkIvsgtRepository.java new file mode 100644 index 00000000..d6e406b7 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/HashTagLinkIvsgtRepository.java @@ -0,0 +1,9 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository; + +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.HashTagLinkIvsgt; +import org.springframework.data.jpa.repository.JpaRepository; + + +public interface HashTagLinkIvsgtRepository extends JpaRepository { + void deleteByIvsgtKey(Integer ivsgtKey); +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/IvsgtFileRepository.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/IvsgtFileRepository.java new file mode 100644 index 00000000..f2c767f7 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/repository/IvsgtFileRepository.java @@ -0,0 +1,13 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository; + +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.IvsgtFile; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; +import java.util.Optional; + + +public interface IvsgtFileRepository extends JpaRepository { + List findByIvsgtKey(Integer ivsgtKey); + Optional findTopByIvsgtKeyOrderByFileSeqDesc(Integer ivsgtKey); +} diff --git a/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/service/BoardInvestigationService.java b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/service/BoardInvestigationService.java new file mode 100644 index 00000000..ee767bd6 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/ivsgtMgt/boardInvestigation/service/BoardInvestigationService.java @@ -0,0 +1,126 @@ +package com.dbnt.faisp.ivsgtMgt.boardInvestigation.service; + + +import com.dbnt.faisp.config.BaseService; +import com.dbnt.faisp.config.FileInfo; +import com.dbnt.faisp.fpiMgt.affair.model.HashTag; +import com.dbnt.faisp.fpiMgt.affair.repository.HashTagRepository; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.mapper.BoardInvestigationMapper; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.ArrestType; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.BoardInvestigation; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.HashTagLinkIvsgt; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.model.IvsgtFile; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository.ArrestTypeRepository; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository.BoardInvestigationRepository; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository.HashTagLinkIvsgtRepository; +import com.dbnt.faisp.ivsgtMgt.boardInvestigation.repository.IvsgtFileRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.util.List; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class BoardInvestigationService extends BaseService { + private final BoardInvestigationRepository boardInvestigationRepository; + private final IvsgtFileRepository ivsgtFileRepository; + private final ArrestTypeRepository arrestTypeRepository; + private final HashTagRepository hashTagRepository; + private final HashTagLinkIvsgtRepository hashTagLinkIvsgtRepository; + private final BoardInvestigationMapper boardInvestigationMapper; + + public List selectBoardInvestigationList(BoardInvestigation boardInvestigation) { + return boardInvestigationMapper.selectBoardInvestigationList(boardInvestigation); + } + + public Integer selectBoardInvestigationListCnt(BoardInvestigation boardInvestigation) { + return boardInvestigationMapper.selectBoardInvestigationListCnt(boardInvestigation); + } + + public BoardInvestigation selectBoardInvestigation(Integer ivsgtKey) { + BoardInvestigation savedBoardInvestigation = boardInvestigationRepository.findById(ivsgtKey).orElse(null); + if (savedBoardInvestigation != null) { + savedBoardInvestigation.setFileList(ivsgtFileRepository.findByIvsgtKey(ivsgtKey)); + savedBoardInvestigation.setHashTags(boardInvestigationMapper.selectHashTags(ivsgtKey)); + savedBoardInvestigation.setArrestType(boardInvestigationMapper.selectArrestType(ivsgtKey)); + } + return savedBoardInvestigation; + } + + @Transactional + public Integer saveBoardInvestigation(BoardInvestigation boardInvestigation, ArrestType arrestType, List deleteFileSeq) { + Integer ivsgtKey = boardInvestigationRepository.save(boardInvestigation).getIvsgtKey(); + String[] hashTagAry = boardInvestigation.getHashTags().split(" "); + if(hashTagAry.length>0){ + saveHashTagLink(ivsgtKey, hashTagAry); + } + arrestType.setIvsgtKey(ivsgtKey); + arrestTypeRepository.save(arrestType); + if(deleteFileSeq != null && deleteFileSeq.size()>0){ + deletePlanFile(ivsgtKey, deleteFileSeq); + } + if(boardInvestigation.getMultipartFileList()!=null){ + saveUploadFiles(ivsgtKey, boardInvestigation.getMultipartFileList()); + } + return ivsgtKey; + } + + private void saveUploadFiles(Integer ivsgtKey, List multipartFileList){ + IvsgtFile lastFileInfo = ivsgtFileRepository.findTopByIvsgtKeyOrderByFileSeqDesc(ivsgtKey).orElse(null); + int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1); + for(MultipartFile file : multipartFileList){ + String saveName = UUID.randomUUID().toString(); + String path = locationPath+ File.separator+"monthPlan"+File.separator; + saveFile(file, new File(path+File.separator+saveName)); + + String originalFilename = file.getOriginalFilename(); + int extnIdx = originalFilename.lastIndexOf("."); + IvsgtFile fileInfo = new IvsgtFile(); + fileInfo.setIvsgtKey(ivsgtKey); + fileInfo.setFileSeq(fileSeq++); + fileInfo.setOrigNm(originalFilename.substring(0, extnIdx)); + fileInfo.setFileExtn(originalFilename.substring(extnIdx+1)); + fileInfo.setConvNm(saveName); + fileInfo.setFileSize(calculationSize(file.getSize())); + fileInfo.setSavePath(path); + ivsgtFileRepository.save(fileInfo); + } + } + + private void deletePlanFile(Integer ivsgtKey, List deleteFileSeq) { + List ivsgtFileList = ivsgtFileRepository.findByIvsgtKey(ivsgtKey); + for(IvsgtFile file: ivsgtFileList){ + if(deleteFileSeq.contains(file.getFileSeq())){ + deleteStoredFile(new File(file.getSavePath(), file.getConvNm())); + ivsgtFileRepository.delete(file); + } + } + } + + private void saveHashTagLink(Integer ivsgtKey, String[] hashTagAry){ + hashTagLinkIvsgtRepository.deleteByIvsgtKey(ivsgtKey); + for(String tagNm : hashTagAry){ + HashTag savedTag = hashTagRepository.findByTagNm(tagNm).orElse(null); + Integer tagKey; + if(savedTag==null){ + HashTag tag = new HashTag(); + tag.setTagNm(tagNm); + tagKey = hashTagRepository.save(tag).getTagKey(); + }else{ + tagKey = savedTag.getTagKey(); + } + HashTagLinkIvsgt hashTagLinkIvsgt = new HashTagLinkIvsgt(); + hashTagLinkIvsgt.setIvsgtKey(ivsgtKey); + hashTagLinkIvsgt.setTagKey(tagKey); + hashTagLinkIvsgtRepository.save(hashTagLinkIvsgt); + } + } + + public FileInfo selectIvsgtFile(Integer parentKey, Integer fileSeq) { + return ivsgtFileRepository.findById(new IvsgtFile.IvsgtFileId(parentKey, fileSeq)).orElse(null); + } +} diff --git a/src/main/java/com/dbnt/faisp/util/Utils.java b/src/main/java/com/dbnt/faisp/util/Utils.java index dfbc54cf..5d881c19 100644 --- a/src/main/java/com/dbnt/faisp/util/Utils.java +++ b/src/main/java/com/dbnt/faisp/util/Utils.java @@ -26,6 +26,7 @@ import org.apache.poi.xssf.usermodel.XSSFDataFormat; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.dbnt.faisp.fipTarget.model.PartInfo; +import com.dbnt.faisp.fipTarget.model.PartWork; public class Utils { @@ -513,6 +514,137 @@ public class Utils { out.close(); } } + + public static void partWorkListToExcel(List partWorkList, HttpServletResponse response, String[] headers, + String[] headerNames, String[] headerNames2, String[] columnType, String sheetName, String excelFileName) throws IOException { + if(Utils.isNotEmpty(partWorkList)) { + // 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다. + XSSFWorkbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet(sheetName); + Row headerRow = sheet.createRow(0); + Row headerRow2 = sheet.createRow(1); + CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식 + CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식 + CellStyle headerStyle = wb.createCellStyle(); //숫자양식 + CellStyle headerStyle2 = wb.createCellStyle(); + CellStyle headerStyle3 = wb.createCellStyle(); + + XSSFDataFormat format = wb.createDataFormat(); + cellStyle1.setAlignment(HorizontalAlignment.CENTER); + cellStyle2.setDataFormat(format.getFormat("#,##0")); + cellStyle2.setAlignment(HorizontalAlignment.CENTER); + headerStyle2.setBorderTop(BorderStyle.THIN); + headerStyle2.setBorderBottom(BorderStyle.THIN); + headerStyle2.setBorderLeft(BorderStyle.THIN); + headerStyle2.setBorderRight(BorderStyle.THIN); + headerStyle2.setAlignment(HorizontalAlignment.CENTER); + headerStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle2.setFillForegroundColor((short)3); + headerStyle2.setFillForegroundColor(IndexedColors.LIME.getIndex()); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle.setFillForegroundColor((short)3); + headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex()); + headerStyle3.setBorderTop(BorderStyle.THIN); + headerStyle3.setBorderBottom(BorderStyle.THIN); + headerStyle3.setBorderLeft(BorderStyle.THIN); + headerStyle3.setBorderRight(BorderStyle.THIN); + headerStyle3.setAlignment(HorizontalAlignment.CENTER); + headerStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle3.setFillForegroundColor((short)3); + headerStyle3.setFillForegroundColor(IndexedColors.LIME.getIndex()); + //로우그리기 + for(int i=0; i 0) { + rowData.set("file_cnt", "●"); + }else { + rowData.set("file_cnt", ""); + } + rowData.set("wrt_dt", partWorkList.get(i).getWrtDt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))); + for(int j=0; j"); + out.write(""); + out.write(""); + out.write(""); + out.write(""); + out.write(""); + + out.flush(); + out.close(); + } + + } diff --git a/src/main/resources/mybatisMapper/BoardInvestigationMapper.xml b/src/main/resources/mybatisMapper/BoardInvestigationMapper.xml new file mode 100644 index 00000000..f572db08 --- /dev/null +++ b/src/main/resources/mybatisMapper/BoardInvestigationMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + AND a.wrt_nm LIKE '%'||#{wrtNm}||'%' + + + AND a.wrt_organ = #{wrtOrgan} + + + AND a.content_title LIKE '%'||#{contentTitle}||'%' + + + + And a.wrt_dt >= #{startDate}::DATE + + + AND a.wrt_dt <= #{endDate}::DATE+1 + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatisMapper/FipTarget.xml b/src/main/resources/mybatisMapper/FipTarget.xml index 9ae3dac0..723f18d8 100644 --- a/src/main/resources/mybatisMapper/FipTarget.xml +++ b/src/main/resources/mybatisMapper/FipTarget.xml @@ -376,7 +376,9 @@ #{item} order by wrt_dt desc - limit #{rowCnt} offset #{firstIndex} + + limit #{rowCnt} offset #{firstIndex} + ") +}); + +$(document).on('click', '#saveArrestBtn', function (){ + saveBoardInvestigation('N') +}); + +$(document).on('click', '#saveTempBtn', function (){ + saveBoardInvestigation('Y') +}); + +$(document).on('click', '.tr', function (){ + getArrestViewModal($(this).data('key')); +}); + +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko" + }); +}); + + +function getArrestViewModal(ivsgtKey){ + $.ajax({ + url: '/ivsgt/arrestViewModal', + data: {ivsgtKey: ivsgtKey}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#arrestViewBody").empty().append(html) + $("#arrestViewModal").modal('show'); + }, + error:function(){ + + } + }); +} + +function getArrestEditModal(ivsgtKey){ + $.ajax({ + url: '/ivsgt/arrestEditModal', + data: {ivsgtKey: ivsgtKey}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#arrestEditModalContent").empty().append(html) + $("#arrestEditModal").modal('show'); + $("[name='contentInfo']").summernote({ + lang:'ko-KR', + height: 120, + disableDragAndDrop: true, + toolbar: [ + ['style', ['style']], + ['font', ['bold', 'underline', 'clear']], + ['color', ['color']], + ['para', ['ul', 'ol', 'paragraph']], + ['table', ['table']] + ] + }); + $("[name='contentMain']").summernote({ + lang:'ko-KR', + height: 120, + disableDragAndDrop: true, + toolbar: [ + ['style', ['style']], + ['font', ['bold', 'underline', 'clear']], + ['color', ['color']], + ['para', ['ul', 'ol', 'paragraph']], + ['table', ['table']] + ] + }); + setUploadDiv(); + }, + error:function(){ + + } + }); +} + +function saveBoardInvestigation(contentState){ + if(contentCheck()){ + if(confirm("저장하시겠습니까?")){ + $("#contentStatus").val(contentState); + contentFade("in"); + const formData = new FormData($("#arrestEditForm")[0]); + for(const file of files) { + if(!file.isDelete) + formData.append('uploadFiles', file, file.name); + } + $(".text-decoration-line-through").each(function (idx, el){ + formData.append('fileSeq', $(el).attr("data-fileseq")); + }) + $.ajax({ + type : 'POST', + data : formData, + url : "/ivsgt/saveBoardInvestigation", + processData: false, + contentType: false, + success : function(result) { + alert("저장되었습니다."); + contentFade("out"); + $("#arrestEditModal").modal('hide'); + getArrestViewModal(result); + }, + error : function(xhr, status) { + alert("저장에 실패하였습니다.") + contentFade("out"); + } + }) + } + } +} + +function contentCheck(){ + let flag = true; + if(!$("#contentTitle").val()){ + alert("제목을 입력해주세요.") + flag = false; + } + else if(!$("#arrestCd").val()){ + alert("검거유형1을 선택해주세요.") + flag = false; + } + else if(!$("#arrestCd2").val()){ + alert("검거유형2를 선택해주세요.") + flag = false; + } + + flag = fileCheck(flag, files); + return flag; +} \ No newline at end of file diff --git a/src/main/resources/templates/fipTarget/partInfoEditModal.html b/src/main/resources/templates/fipTarget/partInfoEditModal.html index f75cff82..9d315120 100644 --- a/src/main/resources/templates/fipTarget/partInfoEditModal.html +++ b/src/main/resources/templates/fipTarget/partInfoEditModal.html @@ -2,7 +2,7 @@