src/main/java/com/dji/sample/patches/service/GetPatchesService.java
@@ -43,4 +43,6 @@ LotInfo getLotinfo(String dkbh,String workspaceId); List<LotInfo>listLotinfo(); void insertLotinfo(List<LotInfo> list); } src/main/java/com/dji/sample/patches/service/ShpToDataSourceService.java
@@ -31,5 +31,5 @@ * 将List<TbDkjbxxEntity>类型的数据批量插入到数据库中。 * @param list 需要保存到数据库的TbDkjbxxEntity实体列表。 */ void savaInMysql(List<TbDkjbxxEntity> list); void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId); } src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -84,4 +84,11 @@ public List<LotInfo>listLotinfo(){ return mapper.selectList(null); } @Override public void insertLotinfo(List<LotInfo> list) { for (int i = 0; i < list.size(); i++) { mapper.insert(list.get(i)); } } } src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
@@ -80,10 +80,11 @@ return multipartFile; } @Transactional public void savaInMysql(List<TbDkjbxxEntity> list){ public void savaInMysql(List<TbDkjbxxEntity> list,String workspaceId){ for (int i = 0; i <list.size() ; i++) { LotInfo lotInfo = new LotInfo(); lotInfo=dbConvertToEntity(list.get(i)); lotInfo.setWorkspaceId(workspaceId); lotInfo=dbConvertToEntity(list.get(i),workspaceId); mapper.insert(lotInfo); } } @@ -92,7 +93,7 @@ * @param file 需要转换的DKJBXX对象。 * @return 返回一个构建好的LotInfo对象,包含从数据库实体中转换来的信息。 */ private LotInfo dbConvertToEntity(TbDkjbxxEntity file) { private LotInfo dbConvertToEntity(TbDkjbxxEntity file,String workspaceId) { LotInfo.LotInfoBuilder builder = LotInfo.builder(); if (file != null) { builder.bsm(file.getBsm()) @@ -109,6 +110,7 @@ .yzb(file.getYzb()) .kzxx(file.getKzxx()) .dklx(file.getDklx()) .workspaceId(workspaceId) .build(); } return builder.build(); src/main/java/com/dji/sample/territory/controller/TbDkjbxxController.java
@@ -68,13 +68,13 @@ * @param file 需要上传的文件,通过multipart/form-data方式提交 * @return 返回上传结果的ResponseResult对象,其中包含上传成功的消息 */ @PostMapping("/upload") public ResponseResult<String> uploadFile(@RequestParam("file") MultipartFile file) { tbDkjbxxService.uploadFile(file); List<TbDkjbxxEntity> list = tbDkjbxxService.list(); service.savaInMysql(list); return tbDkjbxxService.uploadFile(file); } // @PostMapping("/upload") // public ResponseResult<String> uploadFile(@RequestParam("file") MultipartFile file) { // tbDkjbxxService.uploadFile(file); // List<TbDkjbxxEntity> list = tbDkjbxxService.list(); //// service.savaInMysql(list); // return tbDkjbxxService.uploadFile(file); // } @PostMapping("/uploadLot") public ResponseResult getGeo(@RequestParam String workspaceId, @@ -82,6 +82,8 @@ @RequestParam double airportLat, @RequestParam double airportLon, HttpServletRequest request) throws Exception { List<TbDkjbxxEntity> list = tbDkjbxxService.list(); service.savaInMysql(list,workspaceId); MultipartFile multipartFile = tbDkjbxxService.listFile(workspaceId, waylineName, airportLat, airportLon); CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); String creator = customClaim.getUsername();