liusheng
2023-08-31 d51450c60f95c7e6fb7034451e9c1f7497b2b116
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundServiceImpl.java
@@ -137,6 +137,7 @@
        ServiceFundShared serviceFundShared = DtoConversionUtils.sourceToTarget(serviceFund, ServiceFundShared.class);
        serviceFundShared.setSerfunid(serviceFundShared.getId());
        serviceFundShared.setId(null);
        log.info("数据都插进去了吗? {}", serviceFundShared);
        sharedService.save(serviceFundShared);
        //fundId为主表的ID
@@ -694,6 +695,8 @@
            if (serviceFunddetailVO.getTaxedamount() != null && serviceFunddetailVO.getAmount() != null && serviceFunddetailVO.getTaxedamount() != 0.0 && serviceFunddetailVO.getAmount() != 0.0) {
                // 税前税后都不为空
                ServiceFunddetail serviceFunddetail = DtoConversionUtils.sourceToTarget(serviceFunddetailVO, ServiceFunddetail.class);
                if (serviceFunddetailVO.getId() == null) {
                    serviceFunddetailService.save(serviceFunddetail);
                } else {
@@ -745,6 +748,15 @@
        //将税前、税后金额更新到fund表中
        serviceFundVO.setPretaxcost(taxBefore);
        serviceFundVO.setTaxedcost(taxAfter);
        //申请金额为含税金额
        if (serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) {
            //个税   税前(有税) - 税 = 税后
            serviceFundVO.setAmountrequested(taxBefore);
        } else {
            //采购   税前(无税) + 税 = 税后(含税金额)
            serviceFundVO.setAmountrequested(taxAfter);
        }
        updateById(serviceFundVO);
        return id;
@@ -774,40 +786,41 @@
        String strFUrl = "http://129.88.242.39:8899/seeyon/rest/attachment?token=" + strRes;
        List<RbDetailFile> parseArray2 = new ArrayList<>();
        List<RbDetailFile> parseArray = JSON.parseArray(remShare.getAnnexfiles(), RbDetailFile.class);
        log.info("parseArray的值 : {}",parseArray);
        for (int i = 0; i < parseArray.size(); i++) {
            RbDetailFile rbDetailFile = parseArray.get(i);
            log.info("filePath的修改:{}", filePath);
            String url = rbDetailFile.getUrl();
            //file用的是绝对位置
            String substring = url.substring(url.indexOf("/profile/upload") + "/profile/upload".length());
        log.info("parseArray的值 : {}", parseArray);
        if (!CollectionUtils.isEmpty(parseArray)) {
            for (int i = 0; i < parseArray.size(); i++) {
                RbDetailFile rbDetailFile = parseArray.get(i);
                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");
            System.out.println("fund服务的filePath + substring: " + filePath + substring);
            File filetest = new File(filePath + substring);
                System.out.println("fund服务的filePath + substring: " + filePath + substring);
                File filetest = new File(filePath + substring);
            try {
                String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl);
                log.info("第三方传回的数据: {}", struploadResult);
                if (StringUtils.isEmpty(struploadResult)) {
                    log.info("HttpClientKit.sendPostWithFile 请求为空了 filetest:{},  strFUrl:{} ", filetest, strFUrl);
                    return 0;
                try {
                    String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl);
                    log.info("第三方传回的数据: {}", struploadResult);
                    if (StringUtils.isEmpty(struploadResult)) {
                        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());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //获取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());
                }
            } catch (Exception e) {
                e.printStackTrace();
                parseArray2.add(rbDetailFile);
            }
            parseArray2.add(rbDetailFile);
            remShare.setAnnexfiles(JSON.toJSONString(parseArray2));
            log.info("ServiceReimbursementdetailShared 是否加上了fileid : {}", remShare);
        }
        remShare.setAnnexfiles(JSON.toJSONString(parseArray2));
        log.info("ServiceReimbursementdetailShared 是否加上了fileid : {}", remShare);
        return 0;
    }