| | |
| | | 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; |
| | |
| | | |
| | | @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); |
| | |
| | | @Override |
| | | @Transactional |
| | | public Boolean addSharedData(Long id) { |
| | | log.info("addSharedData方法的入参id :{}", 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); |
| | |
| | | serviceReimbursementdetailShareds.get(i).setRbid(serviceReimbursementShared.getId()); |
| | | serviceReimbursementdetailShareds.get(i).setId(null); |
| | | //上传OA文件 |
| | | log.info("上传OA文件方法的入参:{}", serviceReimbursementdetailShareds.get(i)); |
| | | uploadOAFileAndUpdateDb(serviceReimbursementdetailShareds.get(i)); |
| | | } |
| | | |
| | |
| | | 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"; |
| | |
| | | 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);//得到返回的token? |
| | | 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; |
| | | |
| | |
| | | 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("第三方传回的数据获取的atts : {}", jsonArr); |
| | | for (int j = 0; j < jsonArr.size(); j++) { |
| | | JSONObject jsonRet = jsonArr.getJSONObject(j); |
| | | rbDetailFile.setFileid(jsonRet.get("fileUrl").toString()); |
| | |
| | | parseArray2.add(rbDetailFile); |
| | | } |
| | | remShare.setAnnexfiles(JSON.toJSONString(parseArray2)); |
| | | log.info("ServiceReimbursementdetailShared 是否加上了fileid : {}",remShare); |
| | | log.info("ServiceReimbursementdetailShared 是否加上了fileid : {}", remShare); |
| | | return 0; |
| | | } |
| | | |