liusheng
2023-08-07 4b6e55140537e4932f4ea46f6c62c72af1ddb40e
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java
@@ -141,13 +141,16 @@
    @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方法的返参参 :{}", details.size());
        //获取支付数据
        List<ServiceReimbursementpayee> serviceReimbursementpayees = reimbursementpayeeMapper.selectByMap(columnMap);
        log.info("reimbursementpayeeMapper.selectByMap方法的返参参 :{}", serviceReimbursementpayees.size());
        //数据组装
        ServiceReimbursementShared serviceReimbursementShared = DtoConversionUtils.sourceToTarget(serviceReimbursement, ServiceReimbursementShared.class);
        serviceReimbursementShared.setReimid(id);
@@ -164,6 +167,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 +209,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,8 +227,7 @@
        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();
@@ -233,18 +239,22 @@
        List<RbDetailFile> parseArray = JSON.parseArray(remShare.getAnnexfiles(), RbDetailFile.class);
        for (int i = 0; i < parseArray.size(); i++) {
            RbDetailFile rbDetailFile = parseArray.get(i);
            log.info("filePath的修改:{}", filePath);
            String strFile = rbDetailFile.getUrl().replaceAll("/profile/upload", filePath);
            File filetest = new File(strFile);
            try {
                log.info("请求第三方的入参strFile : {}, strFUrl : {}", strFile, filePath);
                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());
@@ -256,7 +266,7 @@
            parseArray2.add(rbDetailFile);
        }
        remShare.setAnnexfiles(JSON.toJSONString(parseArray2));
        log.info("ServiceReimbursementdetailShared 是否加上了fileid : {}",remShare);
        log.info("ServiceReimbursementdetailShared 是否加上了fileid : {}", remShare);
        return 0;
    }