diff --git a/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java new file mode 100644 index 00000000..09533c20 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/FipTargetController.java @@ -0,0 +1,94 @@ +package com.dbnt.faisp.fipTarget; + + +import com.dbnt.faisp.authMgt.service.AuthMgtService; +import com.dbnt.faisp.equip.model.Equip; +import com.dbnt.faisp.equip.model.EquipLog; +import com.dbnt.faisp.equip.service.EquipService; +import com.dbnt.faisp.fipTarget.model.PartInfo; +import com.dbnt.faisp.fipTarget.service.FipTargetService; +import com.dbnt.faisp.organMgt.service.OrganConfigService; +import com.dbnt.faisp.publicBoard.model.PublicBoard; +import com.dbnt.faisp.translator.model.Translator; +import com.dbnt.faisp.userInfo.model.UserInfo; +import com.dbnt.faisp.util.ParamMap; +import com.dbnt.faisp.util.Utils; + +import lombok.RequiredArgsConstructor; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.time.LocalDateTime; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; + + +@RestController +@RequiredArgsConstructor +@RequestMapping("/target") +public class FipTargetController { + + private final OrganConfigService organConfigService; + private final AuthMgtService authMgtService; + private final FipTargetService fipTargetSevice; + + @GetMapping("/partInfoList") + public ModelAndView partInfoList(@AuthenticationPrincipal UserInfo loginUser,PartInfo partInfo) { + ModelAndView mav = new ModelAndView("fipTarget/partInfoList"); + //메뉴권한 확인 + String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/equipStatus").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + partInfo.setDownOrganCdList(loginUser.getDownOrganCdList()); + partInfo.setQueryInfo(); + mav.addObject("partInfoList", fipTargetSevice.selectPartInfoList(partInfo)); + partInfo.setContentCnt(fipTargetSevice.selectPartInfoListCnt(partInfo)); + partInfo.setPaginationInfo(); + mav.addObject("searchParams", partInfo); + return mav; + } + + @GetMapping("/partInfoEditModal") + public ModelAndView partInfoEditModal(@AuthenticationPrincipal UserInfo loginUser,PartInfo partInfo) { + ModelAndView mav = new ModelAndView("fipTarget/partInfoEditModal"); + mav.addObject("mgtOrganList", loginUser.getDownOrganCdList()); + + return mav; + } + + @GetMapping("/partInfoSelecBox") + public ModelAndView equipTypeSelecBox(String ogCd) { + ModelAndView mav = new ModelAndView("fipTarget/parkInfoSelecBox"); + ParamMap param = new ParamMap(); + param.put("downOrganCdList", organConfigService.selectDownOrganListWhereUserOgCd(ogCd)); + mav.addObject("managerList", fipTargetSevice.selectPartInfoManagerList(param)); + return mav; + } + + @PostMapping("/savePartInfo") + public void savePartInfo (@AuthenticationPrincipal UserInfo loginUser, PartInfo partInfo,MultipartHttpServletRequest request){ + partInfo.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); + partInfo.setWrtNm(loginUser.getUserId()); + partInfo.setWrtPart(loginUser.getOfcCd()); + partInfo.setWrtUserSeq(loginUser.getUserSeq()); + partInfo.setWrtOrgan(loginUser.getOgCd()); + partInfo.setWrtDt(LocalDateTime.now()); + fipTargetSevice.savePartInfo(partInfo); + } + + + + + + + +} diff --git a/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java b/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java new file mode 100644 index 00000000..88f45878 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/mapper/FipTargetMapper.java @@ -0,0 +1,22 @@ +package com.dbnt.faisp.fipTarget.mapper; + +import com.dbnt.faisp.fipTarget.model.PartInfo; +import com.dbnt.faisp.util.ParamMap; + +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface FipTargetMapper { + + List selectPartInfoManagerList(ParamMap param); + + List selectPartInfoList(PartInfo partInfo); + + Integer selectPartInfoListCnt(PartInfo partInfo); + + + + +} diff --git a/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java new file mode 100644 index 00000000..e8ab43e0 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfo.java @@ -0,0 +1,129 @@ +package com.dbnt.faisp.fipTarget.model; + +import com.dbnt.faisp.config.BaseModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +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.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; + + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@IdClass(PartInfo.PartInfoId.class) +@Table(name = "part_info") +public class PartInfo extends BaseModel implements Serializable{ + @Id + @Column(name = "pi_seq") + private Integer piSeq; + @Id + @Column(name = "version_no") + private Integer versionNo; + @Column(name = "mgt_organ") + private String mgtOrgan; + @Column(name = "pi_user_seq") + private Integer piUserSeq; + @Column(name = "land_police") + private String landPolice; + @Column(name = "rent_type") + private String rentType; + @Column(name = "rent_price") + private Integer rentPrice; + @Column(name = "utility_type") + private String utilityType; + @Column(name = "utility_price") + private Integer utilityPrice; + @Column(name = "terminal_nm") + private String terminalNm; + @Column(name = "mp_work_type") + private String mpWorkType; + @Column(name = "mp_people_cnt") + private Integer mpPeopleCnt; + @Column(name = "mp_description") + private String mpDescription; + @Column(name = "pl_work_type") + private String plWorkType; + @Column(name = "pl_people_cnt") + private Integer plPeopleCnt; + @Column(name = "pl_description") + private String plDescription; + @Column(name = "wrt_organ") + private String wrtOrgan; + @Column(name = "wrt_part") + private String wrtPart; + @Column(name = "wrt_user_seq") + private Integer wrtUserSeq; + @Column(name = "wrt_nm") + private String wrtNm; + @Column(name = "wrt_dt") + private LocalDateTime wrtDt; + + @Transient + private List multipartFileList; + + @Transient + private String piManagerName; + + +@Override +public String toString() { + return "PartInfo [piSeq=" + piSeq + ", versionNo=" + versionNo + ", mgtOrgan=" + mgtOrgan + ", piUserSeq=" + + piUserSeq + ", landPolice=" + landPolice + ", rentType=" + rentType + ", rentPrice=" + rentPrice + + ", utilityType=" + utilityType + ", utilityPrice=" + utilityPrice + ", terminalNm=" + terminalNm + + ", mpWorkType=" + mpWorkType + ", mpPeopleCnt=" + mpPeopleCnt + ", mpDescription=" + mpDescription + + ", plWorkType=" + plWorkType + ", plPeopleCnt=" + plPeopleCnt + ", plDescription=" + plDescription + + ", wrtOrgan=" + wrtOrgan + ", wrtPart=" + wrtPart + ", wrtUserSeq=" + wrtUserSeq + ", wrtNm=" + wrtNm + + ", wrtDt=" + wrtDt + ", multipartFileList=" + multipartFileList + "]"; +} + + +@Embeddable +@Data +@NoArgsConstructor +@AllArgsConstructor +public static class PartInfoId implements Serializable { + private Integer piSeq; + private Integer versionNo; +} + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java new file mode 100644 index 00000000..a6131b0c --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/model/PartInfoFile.java @@ -0,0 +1,78 @@ +package com.dbnt.faisp.fipTarget.model; + +import com.dbnt.faisp.config.BaseModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +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 javax.persistence.*; + +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Date; + + +@Getter +@Setter +@Entity +@NoArgsConstructor +@DynamicInsert +@DynamicUpdate +@IdClass(PartInfoFile.PartInfoFileId.class) +@Table(name = "part_info_file") +public class PartInfoFile extends BaseModel implements Serializable{ + @Id + @Column(name = "file_seq") + private Integer fileSeq; + @Id + @Column(name = "pi_seq") + private Integer piSeq; + @Id + @Column(name = "version_no") + private Integer versionNo; + @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 = "file_path") + private String filePath; + + + +@Embeddable +@Data +@NoArgsConstructor +@AllArgsConstructor +public static class PartInfoFileId implements Serializable { + private Integer fileSeq; + private Integer piSeq; + private Integer versionNo; +} + + + + + + + + + + + + + + + + +} diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java new file mode 100644 index 00000000..26d77e08 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoFileRepository.java @@ -0,0 +1,24 @@ +package com.dbnt.faisp.fipTarget.repository; + + +import com.dbnt.faisp.fipTarget.model.PartInfoFile; + +import org.springframework.data.jpa.repository.JpaRepository; + + + +public interface PartInfoFileRepository extends JpaRepository { + + PartInfoFile findTopByPiSeqOrderByFileSeq(Integer piSeq); + + + + + + + + + + + +} diff --git a/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoRepository.java b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoRepository.java new file mode 100644 index 00000000..2292f6e6 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/repository/PartInfoRepository.java @@ -0,0 +1,22 @@ +package com.dbnt.faisp.fipTarget.repository; + + +import com.dbnt.faisp.fipTarget.model.PartInfo; + + +import org.springframework.data.jpa.repository.JpaRepository; + + + +public interface PartInfoRepository extends JpaRepository { + + PartInfo findFirstByOrderByPiSeqDesc(); + + + + + + + + +} diff --git a/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java b/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java new file mode 100644 index 00000000..f011253a --- /dev/null +++ b/src/main/java/com/dbnt/faisp/fipTarget/service/FipTargetService.java @@ -0,0 +1,104 @@ +package com.dbnt.faisp.fipTarget.service; + + + +import com.dbnt.faisp.config.BaseService; +import com.dbnt.faisp.equip.model.Equip; +import com.dbnt.faisp.equip.model.EquipLog; +import com.dbnt.faisp.fipTarget.mapper.FipTargetMapper; +import com.dbnt.faisp.fipTarget.model.PartInfo; +import com.dbnt.faisp.fipTarget.model.PartInfoFile; +import com.dbnt.faisp.fipTarget.repository.PartInfoFileRepository; +import com.dbnt.faisp.fipTarget.repository.PartInfoRepository; +import com.dbnt.faisp.publicBoard.model.PublicFile; +import com.dbnt.faisp.userInfo.model.UserInfo; +import com.dbnt.faisp.util.ParamMap; +import com.dbnt.faisp.util.Utils; + +import lombok.RequiredArgsConstructor; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.FileCopyUtils; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.time.LocalDateTime; +import java.util.*; + +@Service +@RequiredArgsConstructor +public class FipTargetService extends BaseService { + @Value("${spring.servlet.multipart.location}") + protected String locationPath; + + private final PartInfoRepository partInfoRepository; + private final PartInfoFileRepository partInfoFileRepository; + private final FipTargetMapper fipTargetMapper; + + public List selectPartInfoManagerList(ParamMap param) { + return fipTargetMapper.selectPartInfoManagerList(param); + } + + @Transactional + public void savePartInfo(PartInfo partInfo) { + PartInfo dbPart = partInfoRepository.findFirstByOrderByPiSeqDesc(); + if(dbPart == null) { + partInfo.setPiSeq(1); + partInfo.setVersionNo(1); + partInfoRepository.save(partInfo); + } else { + partInfo.setPiSeq(dbPart.getPiSeq()+1); + partInfo.setVersionNo(1); + partInfoRepository.save(partInfo); + } + saveUploadFiles(partInfo.getPiSeq(),partInfo.getVersionNo(), partInfo.getMultipartFileList()); + } + + private void saveUploadFiles(Integer piSeq,Integer versionNo, List multipartFileList) { + PartInfoFile lastFileInfo = partInfoFileRepository.findTopByPiSeqOrderByFileSeq(piSeq); + int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1); + if(multipartFileList == null || multipartFileList.isEmpty()) { + PartInfoFile fileInfo = new PartInfoFile(); + fileInfo.setFileSeq(fileSeq); + fileInfo.setPiSeq(piSeq); + fileInfo.setVersionNo(versionNo); + + partInfoFileRepository.save(fileInfo); + } else { + for(MultipartFile file : multipartFileList){ + String saveName = UUID.randomUUID().toString(); + String path = locationPath+File.separator+"publicFile"+File.separator; + saveFile(file, new File(path+File.separator+saveName)); + + String originalFilename = file.getOriginalFilename(); + int extnIdx = originalFilename.lastIndexOf("."); + PartInfoFile fileInfo = new PartInfoFile(); + fileInfo.setFileSeq(fileSeq++); + fileInfo.setPiSeq(piSeq); + fileInfo.setVersionNo(versionNo); + fileInfo.setOrigNm(originalFilename.substring(0, extnIdx)); + fileInfo.setFileExtn(originalFilename.substring(extnIdx+1)); + fileInfo.setConvNm(saveName); + fileInfo.setFileSize(calculationSize(file.getSize())); + fileInfo.setFilePath(path); + partInfoFileRepository.save(fileInfo); + } + } + + } + + public List selectPartInfoList(PartInfo partInfo) { + return fipTargetMapper.selectPartInfoList(partInfo); + } + + public Integer selectPartInfoListCnt(PartInfo partInfo) { + return fipTargetMapper.selectPartInfoListCnt(partInfo); + } + + + + +} diff --git a/src/main/resources/mybatisMapper/FipTarget.xml b/src/main/resources/mybatisMapper/FipTarget.xml new file mode 100644 index 00000000..657fc389 --- /dev/null +++ b/src/main/resources/mybatisMapper/FipTarget.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/js/fipTarget/partInfo.js b/src/main/resources/static/js/fipTarget/partInfo.js new file mode 100644 index 00000000..162d634a --- /dev/null +++ b/src/main/resources/static/js/fipTarget/partInfo.js @@ -0,0 +1,90 @@ +let files = []; + +$(document).on('click', '#addPartInfo', function (){ + $.ajax({ + url: '/target/partInfoEditModal', + type: 'GET', + dataType:"html", + success: function(html){ + $("#partInfoEditModalEditModalContent").empty().append(html); + $("#partInfoEditModal").modal('show'); + $("#rentPrice").hide(); + $("#utilityPrice").hide(); + setUploadDiv(); + }, + error:function(){ + + } + }); +}) + +$(document).on('change', '#rentType', function (){ + if($("#rentType").val() == 'Y'){ + $("#rentPrice").show(); + }else{ + $("#rentPrice").hide(); + $("#rentPrice").val(''); + } +}); + +$(document).on('change', '#utilityType', function (){ + if($("#utilityType").val() == 'Y'){ + $("#utilityPrice").show(); + }else{ + $("#utilityPrice").hide(); + $("#utilityPrice").val(''); + } +}); + +$(document).on('change', '#mgtOrgan', function (){ + const ogCd = $(this).val(); + if(ogCd != ''){ + $.ajax({ + url: '/target/partInfoSelecBox', + data: { + ogCd, + }, + type: 'GET', + dataType:"html", + success: function(html){ + $("#piUserSeq").empty().append(html); + $("#piUserSeq").prop('disabled',false); + }, + error:function(){ + } + }); + }else{ + $("#piUserSeq").prop('disabled',true); + $("#piUserSeq").val(''); + } +}); + +$(document).on('click', '#savePartInfo', function (){ + if(confirm("저장하시겠습니까?")){ + contentFade("in"); + const formData = new FormData($("#partInfoSave")[0]); + for(const file of files) { + if(!file.isDelete) + formData.append('uploadFiles', file, file.name); + } + $.ajax({ + type : 'POST', + data : formData, + url : "/target/savePartInfo", + processData: false, + contentType: false, + success : function(result) { + alert("저장되었습니다."); + contentFade("out"); + location.reload(); + }, + error : function(xhr, status) { + alert("저장에 실패하였습니다.") + contentFade("out"); + } + }) + } +}) + + + diff --git a/src/main/resources/templates/fipTarget/parkInfoSelecBox.html b/src/main/resources/templates/fipTarget/parkInfoSelecBox.html new file mode 100644 index 00000000..cb36fb68 --- /dev/null +++ b/src/main/resources/templates/fipTarget/parkInfoSelecBox.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/fipTarget/partInfoEditModal.html b/src/main/resources/templates/fipTarget/partInfoEditModal.html new file mode 100644 index 00000000..470f0ee4 --- /dev/null +++ b/src/main/resources/templates/fipTarget/partInfoEditModal.html @@ -0,0 +1,129 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/fipTarget/partInfoList.html b/src/main/resources/templates/fipTarget/partInfoList.html new file mode 100644 index 00000000..a1740031 --- /dev/null +++ b/src/main/resources/templates/fipTarget/partInfoList.html @@ -0,0 +1,139 @@ + + + + + +
+
+

외사 분실 현황

+ + +
+
+
+
+ + +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
해경서육경서해경육경터미널명담당자임차료공공요금최종수정일
근무방법비고근무방법비고
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+
+
+ + + + + +
+ \ No newline at end of file diff --git a/src/main/resources/templates/translator/translatorEditModal.html b/src/main/resources/templates/translator/translatorEditModal.html index 5fe6520c..55680a10 100644 --- a/src/main/resources/templates/translator/translatorEditModal.html +++ b/src/main/resources/templates/translator/translatorEditModal.html @@ -98,8 +98,8 @@