liusheng
2024-07-29 0662ed4d69b6270dec5c2214454023dfe8d46308
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundServiceImpl.java
@@ -19,6 +19,7 @@
import com.ruoyi.project.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -74,6 +75,9 @@
    @Autowired
    private VExpertfeeExpertMapper vExpertfeeExpertMapper;
    @Autowired
    private VExpertfeeDonorMapper vExpertfeeDonorMapper;
    @Autowired
    private VExpertfeeTotalMapper vExpertfeeTotalMapper;
@@ -185,7 +189,17 @@
            serviceFunddetailShareds.get(i).setFundid(serviceFundShared.getId());
            serviceFunddetailShareds.get(i).setId(null);
            //数据发送给财务
            uploadOAFileAndUpdateDb(serviceFunddetailShareds.get(i));
            try {
                uploadOAFileAndUpdateDb(serviceFunddetailShareds.get(i));
            } catch (Exception e) {
                e.printStackTrace();
                log.error("Exception中入参的ID为:{},异常信息为 : {}", id, e.getMessage());
                if (id != null) {
                    Boolean aBoolean = sharedService.delfundsharedInfoById(null, id);
                    log.error("fund2分享表里的数据是否删除成功:{}", aBoolean);
                }
                return false;
            }
        }
        boolean result = false;
        for (ServiceFunddetailShared serviceFunddetailShared : serviceFunddetailShareds) {
@@ -694,7 +708,8 @@
    @Override
    public List<SpFinancialExpensesFundOut> getExpertfeeList(SpSelectExpertfee spSelectExpertfee) {
        return serviceFundMapper.getExpertfeeList(spSelectExpertfee.getPaApplyType(), spSelectExpertfee.getDonorname(), spSelectExpertfee.getPacheckno(), spSelectExpertfee.getCheckstatus(), spSelectExpertfee.getPadepartno(), spSelectExpertfee.getPausername());
        log.info("spSelectExpertfee的入参为:{}", spSelectExpertfee);
        return serviceFundMapper.getExpertfeeList(spSelectExpertfee.getPaApplyType(), spSelectExpertfee.getPfundtaxid(), spSelectExpertfee.getDonorname(), spSelectExpertfee.getPadepartid(), spSelectExpertfee.getPausername());
    }
    @Override
@@ -729,7 +744,7 @@
                if (StringUtils.isNotEmpty(serviceFunddetailVO.getIdcardno())) {
                    serviceFunddetailVO.setIdcardno(serviceFunddetailVO.getIdcardno().trim());
                }
                log.info("身份证号为:{}", serviceFunddetailVO.getIdcardno());
                if (StringUtils.isEmpty(serviceFunddetailVO.getBankcardno())) {
                    throw new BaseException("请检查银行卡号是否为空,姓名:" + serviceFunddetailVO.getBeneficiaryname());
                }
@@ -919,13 +934,18 @@
        AjaxResult ajaxResult = util.exportExcel(list, "vExpertfeeTotal");
        String filePath = RuoYiConfig.getDownloadPath() + ajaxResult.get("msg");
        List<VExpertfeeExpert> list2 = vExpertfeeExpertMapper.selectVExpertfeeExpertListByFaxId(faxId);
        ExcelUtil<VExpertfeeExpert> util2 = new ExcelUtil<VExpertfeeExpert>(VExpertfeeExpert.class);
        AjaxResult ajaxResult1 = util2.exportExcel(list2, "vExpertfeeExpert");
        List<VExpertfeeDonor> list2 = vExpertfeeDonorMapper.selectVExpertfeeDonorList2(faxId);
        ExcelUtil<VExpertfeeDonor> util2 = new ExcelUtil<VExpertfeeDonor>(VExpertfeeDonor.class);
        AjaxResult ajaxResult2 = util2.exportExcel(list2, "VExpertfeeDonor");
        List<VExpertfeeExpert> list3 = vExpertfeeExpertMapper.selectVExpertfeeExpertListByFaxId(faxId);
        ExcelUtil<VExpertfeeExpert> util3 = new ExcelUtil<VExpertfeeExpert>(VExpertfeeExpert.class);
        AjaxResult ajaxResult3 = util3.exportExcel(list3, "vExpertfeeExpert");
        List<String> list1 = new ArrayList<>();
        list1.add(ajaxResult.get("msg").toString());
        list1.add(ajaxResult1.get("msg").toString());
        list1.add(ajaxResult2.get("msg").toString());
        list1.add(ajaxResult3.get("msg").toString());
        String name = "专家费汇总单" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".xlsx";
@@ -934,13 +954,13 @@
            new File(RuoYiConfig.getDownloadPath() + path).delete();
        }
        Map<String, Object> map = new HashMap<>();
        map.put("downloadUrl", "/profile/download/wordtemplate/" + name );
        map.put("downloadUrl", "/profile/download/" + name);
        map.put("downloadName", name);
        return map;
    }
    int uploadOAFileAndUpdateDb(ServiceFunddetailShared remShare) {
    int uploadOAFileAndUpdateDb(ServiceFunddetailShared remShare) throws Exception {
        //上传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";
@@ -980,7 +1000,7 @@
    }
    private Integer uploadFile(String filePath, String strFUrl, List<RbDetailFile> parseArray2, List<RbDetailFile> parseArray, ServiceFunddetailShared remShare, String flag) {
    private Integer uploadFile(String filePath, String strFUrl, List<RbDetailFile> parseArray2, List<RbDetailFile> parseArray, ServiceFunddetailShared remShare, String flag) throws Exception {
        if (!CollectionUtils.isEmpty(parseArray)) {
            for (int i = 0; i < parseArray.size(); i++) {
                RbDetailFile rbDetailFile = parseArray.get(i);
@@ -992,24 +1012,24 @@
                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.error("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();
                String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl);
                log.info("第三方传回的数据: {}", struploadResult);
                if (StringUtils.isEmpty(struploadResult)) {
                    log.error("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);
                    if (StringUtils.isEmpty(jsonRet.get("fileUrl").toString())) {
                        throw new BaseException("fileID为空,请联系第三方处理");
                    }
                    rbDetailFile.setFileid(jsonRet.get("fileUrl").toString());
                }
                parseArray2.add(rbDetailFile);
            }
            if (flag.equals("1")) {
@@ -1167,4 +1187,16 @@
            e.printStackTrace();
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateFundTaxIdById(Long id, Long fundTaxId) {
        //将fund里的算税时间,与详情里的版税时间全清空
        Boolean aBoolean = serviceFundMapper.updateFundTaxIdById(id, fundTaxId);
        ServiceFunddetail serviceFunddetail = new ServiceFunddetail();
        serviceFunddetail.setFundid(id);
        serviceFunddetail.setTaxTime(null);
        serviceFunddetail.setXh(null);
        boolean b = serviceFunddetailMapper.updateTaxTime(serviceFunddetail);
        return b;
    }
}