From c9927c06a608b4baf85669d9cbe570d7fffc361d Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期二, 08 八月 2023 16:14:49 +0800 Subject: [PATCH] 获取fileID的方法进行修改 --- ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java | 33 +++++++++++++++++++++++++-------- 1 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java index 2ffa53f..bd69001 100644 --- a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java +++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java @@ -19,6 +19,7 @@ import com.ruoyi.project.service.IServiceReimbursementdetailSharedService; import com.ruoyi.project.service.IServiceReimbursementpayeeSharedService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -117,10 +118,11 @@ @Override public List<ServiceReimbursementdetailVO> getRBDetailList(Long id) { + log.info("getRBDetailList鐨勫叆鍙�:{}", id); List<ServiceReimbursementdetailVO> serviceReimbursementdetailVOS = new ArrayList<>(); List<ServiceReimbursementdetail> rbDetailList = serviceReimbursementdetailMapper.getRBDetailList(id); + log.info("getRBDetailList鐨勫叆鍙�:{}", CollectionUtils.isEmpty(rbDetailList) ? null : rbDetailList.size()); for (int j = 0; j < rbDetailList.size(); j++) { - ServiceReimbursementdetail serviceReimbursementdetail = rbDetailList.get(j); String annexfiles = serviceReimbursementdetail.getAnnexfiles(); ServiceReimbursementdetailVO serviceReimbursementdetailVO = DtoConversionUtils.sourceToTarget(serviceReimbursementdetail, ServiceReimbursementdetailVO.class); @@ -141,13 +143,16 @@ @Override @Transactional public Boolean addSharedData(Long id) { + log.info("addSharedData鏂规硶鐨勫叆鍙俰d :{}", id); ServiceReimbursement serviceReimbursement = serviceReimbursementMapper.selectById(id); Map<String, Object> columnMap = new HashMap<>(); columnMap.put("rbid", id); //鑾峰彇璇︽儏鏁版嵁 List<ServiceReimbursementdetail> details = serviceReimbursementdetailMapper.selectByMap(columnMap); + log.info("serviceReimbursementdetailMapper.selectByMap鏂规硶鐨勮繑鍙傚弬 :{}", CollectionUtils.isEmpty(details) ? null : details.size()); //鑾峰彇鏀粯鏁版嵁 List<ServiceReimbursementpayee> serviceReimbursementpayees = reimbursementpayeeMapper.selectByMap(columnMap); + log.info("reimbursementpayeeMapper.selectByMap鏂规硶鐨勮繑鍙傚弬 :{}", CollectionUtils.isEmpty(serviceReimbursementpayees) ? null : serviceReimbursementpayees.size()); //鏁版嵁缁勮 ServiceReimbursementShared serviceReimbursementShared = DtoConversionUtils.sourceToTarget(serviceReimbursement, ServiceReimbursementShared.class); serviceReimbursementShared.setReimid(id); @@ -164,6 +169,7 @@ serviceReimbursementdetailShareds.get(i).setRbid(serviceReimbursementShared.getId()); serviceReimbursementdetailShareds.get(i).setId(null); //涓婁紶OA鏂囦欢 + log.info("涓婁紶OA鏂囦欢鏂规硶鐨勫叆鍙�:{}", serviceReimbursementdetailShareds.get(i)); uploadOAFileAndUpdateDb(serviceReimbursementdetailShareds.get(i)); } @@ -205,7 +211,10 @@ return serviceReimbursementMapper.getRDInfoByItem(serviceReimbursementEo); } + public int uploadOAFileAndUpdateDb(ServiceReimbursementdetailShared remShare) { + log.info("uploadOAFileAndUpdate鏂规硶鐨勫叆鍙�:{}", remShare); + System.out.println("uploadOAFileAndUpdate鏂规硶鐨勫叆鍙�:" + remShare); //涓婁紶OA鏂囦欢 //String strUrl = "http://129.88.242.39:8899/seeyon/rest/token?userName=opo&password=127814f8-84e8-4304-84a5-a71573567efd&loginName=demo3"; String strUrl = "http://129.88.242.39:8899/seeyon/rest/token"; @@ -220,12 +229,11 @@ JSONObject jsonObj = new JSONObject(map); System.out.println("uploadOAFileAndUpdateDb + jsonObject" + jsonObj.toString() + "\r\n" + jsonObj.toJSONString()); - String strRes = HttpClientKit.postOpr(strUrl, jsonObj.toString());// - //String strRes = HttpClientKit.postMsg(strUrl,jsonObj);//寰楀埌杩斿洖鐨則oken? + String strRes = HttpClientKit.postOpr(strUrl, jsonObj.toString()); JSONObject json1 = JSONObject.parseObject(strRes); strRes = json1.get("id").toString(); - + log.info("strRes鐨勫�� : {}", strRes); String filePath = RuoYiConfig.getUploadPath(); String strFUrl = "http://129.88.242.39:8899/seeyon/rest/attachment?token=" + strRes; @@ -233,18 +241,27 @@ List<RbDetailFile> parseArray = JSON.parseArray(remShare.getAnnexfiles(), RbDetailFile.class); for (int i = 0; i < parseArray.size(); i++) { RbDetailFile rbDetailFile = parseArray.get(i); - String strFile = rbDetailFile.getUrl().replaceAll("/profile/upload", filePath); - File filetest = new File(strFile); + + log.info("filePath鐨勪慨鏀�:{}", filePath); + String url = rbDetailFile.getUrl(); + //file鐢ㄧ殑鏄粷瀵逛綅缃� + String substring = url.substring(url.indexOf("/profile/upload") + "/profile/upload".length()); + String strFile = rbDetailFile.getUrl().replace(filePath, "/profile/upload"); + File filetest = new File(filePath + substring); try { + log.info("璇锋眰绗笁鏂圭殑鍏ュ弬strFile : {}, strFUrl : {}", strFile, filePath); + System.out.println("璇锋眰绗笁鏂圭殑鍏ュ弬:" + filePath + substring); String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl); + log.info("绗笁鏂逛紶鍥炵殑鏁版嵁: {}", struploadResult); if (StringUtils.isEmpty(struploadResult)) { - log.info("HttpClientKit.sendPostWithFile 璇锋眰涓虹┖浜� filetest:{}, strFUrl:{} ",filetest,strFUrl); + log.info("HttpClientKit.sendPostWithFile 璇锋眰涓虹┖浜� filetest:{}, strFUrl:{} ", filetest, strFUrl); return 0; } //鑾峰彇fileid JSONObject jsonR = JSONObject.parseObject(struploadResult); JSONArray jsonArr = jsonR.getJSONArray("atts"); + log.info("绗笁鏂逛紶鍥炵殑鏁版嵁鑾峰彇鐨刟tts : {}", jsonArr); for (int j = 0; j < jsonArr.size(); j++) { JSONObject jsonRet = jsonArr.getJSONObject(j); rbDetailFile.setFileid(jsonRet.get("fileUrl").toString()); @@ -256,7 +273,7 @@ parseArray2.add(rbDetailFile); } remShare.setAnnexfiles(JSON.toJSONString(parseArray2)); - log.info("ServiceReimbursementdetailShared 鏄惁鍔犱笂浜唂ileid : {}",remShare); + log.info("ServiceReimbursementdetailShared 鏄惁鍔犱笂浜唂ileid : {}", remShare); return 0; } -- Gitblit v1.9.3