peixh %!s(int64=4) %!d(string=hai) anos
pai
achega
ef70e5cdf6

+ 5 - 3
sc-service/src/main/java/com/huyi/service/common/financeInf/controller/FinanceInfController.java

@@ -49,12 +49,13 @@ public class FinanceInfController extends BaseController {
     private FinanceInfService financeInfService;
 
     /**
-     * 查询融信(融资用
+     * 查询融信 (融资用
+     * @param zfrFinanceId 融信id
      * @return
      */
     @PreAuthorize(hasPermi = "finance:inf:list")
-    @GetMapping("/list")
-    public R list() {
+    @GetMapping("/list/{zfrFinanceId}")
+    public R list(@PathVariable String zfrFinanceId) {
         //查询当前操作员
         LoginUser userInfo = tokenService.getLoginUser();
         SysUser user = userInfo.getSysUser();
@@ -62,6 +63,7 @@ public class FinanceInfController extends BaseController {
         String companyId = user.getCompanyId();
         Map map = new HashMap();
         map.put("companyId",companyId);
+        map.put("zfiId",zfrFinanceId);
         List<Map> list = financeInfService.selectFinanceInfList(map);
 //        LambdaQueryWrapper<ZcFinanceInf> queryWrapper = new LambdaQueryWrapper<>();
 //        queryWrapper.eq(ZcFinanceInf::getZfiSupplierId,companyId);

+ 495 - 12
sc-service/src/main/java/com/huyi/service/financeRecord/controller/FinanceRecordController.java

@@ -6,9 +6,9 @@ import com.huyi.service.base.entity.*;
 import com.huyi.service.base.service.*;
 import com.huyi.service.financeRecord.service.FinanceRecordService;
 import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
-import com.sun.xml.internal.bind.v2.TODO;
 import com.tianhu.common.core.constant.SalaryConstants;
 import com.tianhu.common.core.domain.R;
+import com.tianhu.common.core.utils.AmtUtil;
 import com.tianhu.common.core.utils.CommonUtil;
 import com.tianhu.common.core.utils.DateUtils;
 import com.tianhu.common.core.utils.IdUtils;
@@ -21,17 +21,23 @@ import com.tianhu.common.security.service.TokenService;
 import com.tianhu.system.api.domain.SysUser;
 import com.tianhu.system.api.model.LoginUser;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cglib.beans.BeanMap;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
 import java.lang.reflect.InvocationTargetException;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
 
 
 /**
@@ -44,15 +50,12 @@ import java.util.Map;
 @RestController
 @RequestMapping("/financeRecord")
 public class FinanceRecordController extends BaseController {
+    private static final Logger log = LoggerFactory.getLogger(FinanceRecordController.class);
     @Autowired
     private TokenService tokenService;
     @Autowired
     private FinanceRecordService financeRecordService;
     @Autowired
-    private IZcFinanceInfService zcFinanceInfService;
-    @Autowired
-    private IZcFinanceProComRelService iZcFinanceProComRelService;
-    @Autowired
     private IZcFinanceProductService iZcFinanceProductService;
     @Autowired
     private IPayAccInfService iPayAccInfService;
@@ -62,12 +65,35 @@ public class FinanceRecordController extends BaseController {
     private IZcBillInfService iZcBillInfService;
     @Autowired
     private IZcFinanceRecordService iZcFinanceRecordService;
+    @Autowired
+    private ISysUserService iSysUserService;
+    //发票服务
+    @Autowired
+    private IZcInvoiceInfService invoiceInfService;
+    //文件服务类
+    @Autowired
+    private IPubFileInfService fileInfService;
+    //收付款和文件的关系表服务类
+    @Autowired
+    private IZcBillFileRelService billFileRelService;
+    //收付款与发票关系表
+    @Autowired
+    private IZcBillInvoiceRelService billInvoiceRelService;
+    @Autowired
+    private IZcChargeInfService iZcChargeInfService;
+    @Autowired
+    private ISysUserCompanyRelService iSysUserCompanyRelService;
+    @Autowired
+    private IZcFinanceInfService iZcFinanceInfService;
      /**
      * 查询融资管理列表
      */
     @PreAuthorize(hasPermi = "finance:record:list")
     @GetMapping("/list")
-    public R list(@RequestParam (required = false) String zfrStatus, QueryRequest request) {
+    public R list(@RequestParam (required = false) String zfrTypes,
+                  @RequestParam (required = false) String zfrQuery,
+                  @RequestParam (required = false) String zfrValue,
+                  @RequestParam (required = false) String zfrStatus,QueryRequest request) {
         //查询当前操作员
         LoginUser userInfo = tokenService.getLoginUser();
         SysUser use = userInfo.getSysUser();
@@ -78,11 +104,50 @@ public class FinanceRecordController extends BaseController {
             map.put("companyId", companyId);
         }
         map.put("zfrStatus",zfrStatus);
+        //00:我签收的   01:我开立的
+        if ("00".equals(zfrTypes)){
+            map.put("zfiSupplierId",zfrTypes);
+        }else if ("01".equals(zfrTypes)){
+            map.put("zfiCoreId",zfrTypes);
+        }
+        //00:按开立企业名称查询 01:按接收方企业名称查询 02:按授信额度查询 03:按融资利率查询
+        if ("00".equals(zfrQuery)) {
+            map.put("coreScyName", zfrValue);
+        }else if ("01".equals(zfrQuery)){
+            map.put("supplierScyName", zfrValue);
+        }else if ("02".equals(zfrQuery)){
+            map.put("zfpcrAmount", zfrValue);
+        }else if ("03".equals(zfrQuery)){
+            map.put("zfrRate", zfrValue);
+        }
         IPage<Map> list = financeRecordService.selectFinanceRecordList(map, request);
         return R.ok(list);
     }
 
     /**
+     * 融资管理信息详情
+     * @param zfrId 融资id
+     * @return
+     */
+    @PreAuthorize(hasPermi = "credit:line:query")
+    @GetMapping(value = "/{zfrId}")
+    public AjaxResult getInfo(@PathVariable("zfrId") String zfrId)
+    {
+        ZcFinanceRecord zcFinanceRecord = iZcFinanceRecordService.getById(zfrId);
+        Map map = new HashMap();
+        if (zcFinanceRecord != null) {
+            com.huyi.service.base.entity.SysUser user = iSysUserService.getById(zcFinanceRecord.getCreateBy());
+            BeanMap beanMap = BeanMap.create(zcFinanceRecord);
+            for (Object key : beanMap.keySet()) {
+                map.put(key + "", beanMap.get(key));
+            }
+            //创建人
+            map.put("createUser", user.getNickName());
+        }
+        return AjaxResult.success(map);
+    }
+
+    /**
      * 新增融资管理
      * @param map
      * @return
@@ -98,6 +163,21 @@ public class FinanceRecordController extends BaseController {
         LoginUser userInfo = tokenService.getLoginUser();
         SysUser user = userInfo.getSysUser();
         String userId = user.getUserId() + "";
+        String companyId = user.getCompanyId();
+        //查询当前用户是否是经办人
+        LambdaQueryWrapper<SysUserCompanyRel> companyRelWrapper = new LambdaQueryWrapper<>();
+        companyRelWrapper.eq(SysUserCompanyRel::getSucrUserId,userId);
+        companyRelWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
+        List<SysUserCompanyRel> list = iSysUserCompanyRelService.findSysUserCompanyRels(companyRelWrapper);
+        if (list.size() > 0){
+            //是否经办人 0:不是, 1:是
+            String handler = list.get(0).getSucrHandler();
+            if (!"1".equals(handler)){
+                throw new Exception("此操作需经办人权限,请确认您是否是经办人");
+            }
+        }else {
+            throw new Exception("此操作需经办人权限,请确认您是否是经办人");
+        }
         //融信id
         String zfrFinanceId = CommonUtil.objToString(map.get("zfrFinanceId"));
         //融资金额
@@ -106,6 +186,7 @@ public class FinanceRecordController extends BaseController {
         String zfrCollectionAccount = CommonUtil.objToString(map.get("zfrCollectionAccount"));
         //融资利率
         String zfrRate = CommonUtil.objToString(map.get("zfrRate"));
+        String zfpcrChargeRate = CommonUtil.objToString(map.get("zfpcrChargeRate"));
         //融资放款方式(0:平台电子记账簿 1:供应商指定账户 2:供应商线下面签)
         String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
         //融资产品
@@ -154,7 +235,7 @@ public class FinanceRecordController extends BaseController {
                 zfrCollectionAccount = accInfList.get(0).getPaiAccno();
             }
         }
-        //执行新增
+        /*---------------新增融资表----------*/
         ZcFinanceRecord zcFinanceRecord = new ZcFinanceRecord();
         //主键
         String zfrId = IdUtils.fastSimpleUUID();
@@ -184,11 +265,104 @@ public class FinanceRecordController extends BaseController {
         zcFinanceRecord.setCreateBy(userId);
         //创建时间
         zcFinanceRecord.setCreateTime(createTime);
+        /*-------------新增费用表--------*/
+        ZcChargeInf zcChargeInf = new ZcChargeInf();
+        //主键
+        zcChargeInf.setZciId(IdUtils.fastSimpleUUID());
+        //融资id
+        zcChargeInf.setZciFinanceId(zfrId);
+        //手续费
+        String zciAmount = AmtUtil.divide(zfpcrChargeRate,"100",4);
+        zciAmount = AmtUtil.subtract(zfrAmount,zciAmount,2);
+        zcChargeInf.setZciAmount(zciAmount);
+        //创建人
+        zcChargeInf.setCreateBy(userId);
+        //创建时间
+        zcChargeInf.setCreateTime(DateUtils.getNowDate());
+        /*----------修改融信表状态---------------*/
+        ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
+        //融信id
+        zcFinanceInf.setZfiId(zfrFinanceId);
+        //融信状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回)
+        zcFinanceInf.setZfiStatus("04");
+        //修改人
+        zcFinanceInf.setUpdateBy(userId);
+        //修改时间
+        zcFinanceInf.setUpdateTime(DateUtils.getNowDate());
+        iZcFinanceInfService.updateZcFinanceInf(zcFinanceInf);
+        iZcChargeInfService.createZcChargeInf(zcChargeInf);
         iZcFinanceRecordService.createZcFinanceRecord(zcFinanceRecord);
         return AjaxResult.success();
     }
 
     /**
+     * 放款登记
+     * @param map
+     * @return
+     * @throws Exception
+     */
+    @PreAuthorize(hasPermi = "finance:record:edit")
+    @Log(title = "融资管理", businessType = BusinessType.UPDATE)
+    @Transactional(rollbackFor = Exception.class)
+    @PutMapping
+    public AjaxResult update(@RequestBody Map<String,Object> map)throws Exception
+    {
+        //主键
+        String zfrId = CommonUtil.objToString(map.get("zfrId"));
+        //获取此操作员
+        LoginUser userInfo = tokenService.getLoginUser();
+        SysUser user = userInfo.getSysUser();
+        String userId = user.getUserId() + "";
+        //放款金额
+        String zfrLoanAmount = CommonUtil.objToString(map.get("zfrLoanAmount"));
+        //融资金额
+        String zfrAmount = CommonUtil.objToString(map.get("zfrAmount"));
+        //融信id
+        String zfrFinanceId = CommonUtil.objToString(map.get("zfrFinanceId"));
+        //授信额度
+        if(CommonUtil.isNotEmpty(zfrLoanAmount)) {
+            if(AmtUtil.isMoney(zfrLoanAmount) == false) {
+                throw new Exception("请输入正确的放款金额");
+            }
+        }else {
+            throw new Exception("放款金额不能为空");
+        }
+        int count = CommonUtil.compare(zfrLoanAmount,zfrAmount);
+        if (count == 1){
+            throw new Exception("实际放款金额不能大于融资金额");
+        }
+        //图片
+        String zfrLoanFile = "";
+        List<Map<String, String>> url = (List<Map<String, String>>) map.get("zfrLoanFile");
+        if (url.size() > 0){
+            zfrLoanFile = String.valueOf(url.get(0).get("uid"));
+        }
+        //-----------------执行修改融资表
+        ZcFinanceRecord zcFinanceRecord = new ZcFinanceRecord();
+        //主键
+        zcFinanceRecord.setZfrId(zfrId);
+        //放款金额
+        zcFinanceRecord.setZfrLoanAmount(zfrLoanAmount);
+        //附件
+        zcFinanceRecord.setZfrLoanFile(zfrLoanFile);
+        //融资状态(00:融资中 01:已放款 02:融资失败 03:已结算)
+        zcFinanceRecord.setZfrStatus("01");
+        /*----------修改融信表状态---------------*/
+        ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
+        //融信id
+        zcFinanceInf.setZfiId(zfrFinanceId);
+        //融信状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回)
+        zcFinanceInf.setZfiStatus("05");
+        //修改人
+        zcFinanceInf.setUpdateBy(userId);
+        //修改时间
+        zcFinanceInf.setUpdateTime(DateUtils.getNowDate());
+        iZcFinanceInfService.updateZcFinanceInf(zcFinanceInf);
+        iZcFinanceRecordService.updateZcFinanceRecord(zcFinanceRecord);
+        return AjaxResult.success();
+    }
+
+    /**
      * 查询往来账款
      * @param zfiId 融信id
      * @return
@@ -216,5 +390,314 @@ public class FinanceRecordController extends BaseController {
         return AjaxResult.success(list);
     }
 
+    /**
+     * 导出附件
+     * @return
+     */
+    @PreAuthorize(hasPermi = "finance:record:export")
+    @Log(title = "融资管理", businessType = BusinessType.EXPORT)
+    @PostMapping("/export/{zfrFinanceId}")
+    public AjaxResult export(HttpServletResponse response,@PathVariable String zfrFinanceId ) throws Exception {
+        List<Map<String, String>> list = new ArrayList<>();
+        //查询往来账款
+        LambdaQueryWrapper<ZcFinanceBillRel> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(ZcFinanceBillRel::getZfbrFinanceId,zfrFinanceId);
+        List<ZcFinanceBillRel> billRelList = iZcFinanceBillRelService.findZcFinanceBillRels(queryWrapper);
+        List<String>  billIdList = new ArrayList<>();
+        //查询往来账款
+        if (billRelList.size() > 0){
+            //提取所有的
+            billIdList = CommonUtil.getIdFromList(billRelList,"zfbrBillId");
+        }
+        LambdaQueryWrapper<ZcBillInf> billInfWrapper = new LambdaQueryWrapper<>();
+        billInfWrapper.in(ZcBillInf::getZbiId,billIdList);
+        List<ZcBillInf> billInfList = iZcBillInfService.findZcBillInfs(billInfWrapper);
+        //发票文件
+        List<PubFileInf> invoiceFileList = new ArrayList<>();
+        //收付款的合同类型的文件
+        List<PubFileInf> contractFileList = new ArrayList<>();
+        //收付款的其他文件
+        List<PubFileInf> otherFileList = new ArrayList<>();
+        //提取收付款编号
+        List<String> zbiIdList = CommonUtil.getIdFromList(billInfList,"zbiId");
+        //发票与收付款相关
+        LambdaQueryWrapper<ZcBillInvoiceRel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.in(ZcBillInvoiceRel::getZbirBillId,zbiIdList);
+        List<ZcBillInvoiceRel>  relList =  billInvoiceRelService.findZcBillInvoiceRels(lambdaQueryWrapper);
+        //有关联的发票
+        if(relList.size() > 0 ){
+            List<String> invoiceIdList = CommonUtil.getIdFromList(relList,"zbirInvoiceId");
+            //查询发票
+            LambdaQueryWrapper<ZcInvoiceInf> invoiceInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            invoiceInfLambdaQueryWrapper.in(ZcInvoiceInf::getZiiId,invoiceIdList);
+            invoiceInfLambdaQueryWrapper.eq(ZcInvoiceInf::getZiiStatus,"00");
+            List<ZcInvoiceInf>   invoiceInfList =  invoiceInfService.findZcInvoiceInfs(invoiceInfLambdaQueryWrapper);
+            //发票信息不为空
+            if(invoiceInfList.size() > 0){
+                //提取出文件信息
+                List<String> fileIdList = CommonUtil.getIdFromList(invoiceInfList,"ziiFile");
+                LambdaQueryWrapper<PubFileInf> fileInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                fileInfLambdaQueryWrapper.in(PubFileInf::getPfiFileId,fileIdList);
+                fileInfLambdaQueryWrapper.eq(PubFileInf::getPfiIsDel,"00");
+                //查询文件
+                invoiceFileList =  fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
+            }
+        }
+        //查询文件关系表
+        LambdaQueryWrapper<ZcBillFileRel>  billFileRelLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        billFileRelLambdaQueryWrapper.in(ZcBillFileRel::getZbfrBillId,zbiIdList);
+        billFileRelLambdaQueryWrapper.eq(ZcBillFileRel::getZbfrType,"0");
+        List<ZcBillFileRel> billFileRelList =  billFileRelService.findZcBillFileRels(billFileRelLambdaQueryWrapper);
+        //不为空
+        if(billFileRelList.size() > 0){
+            //提取文件编号
+            List<String> idList = CommonUtil.getIdFromList(billFileRelList,"zbfrFileId");
+            LambdaQueryWrapper<PubFileInf> fileInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            fileInfLambdaQueryWrapper.in(PubFileInf::getPfiFileId,idList);
+            fileInfLambdaQueryWrapper.eq(PubFileInf::getPfiIsDel,"00");
+            contractFileList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
+        }
+        //查询文件关系表
+        LambdaQueryWrapper<ZcBillFileRel>  fileRelLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        fileRelLambdaQueryWrapper.in(ZcBillFileRel::getZbfrBillId,zbiIdList);
+        fileRelLambdaQueryWrapper.eq(ZcBillFileRel::getZbfrType,"2");
+        List<ZcBillFileRel> relFileList =  billFileRelService.findZcBillFileRels(fileRelLambdaQueryWrapper);
+        //不为空
+        if(relFileList.size() > 0){
+            //提取文件编号
+            List<String> idList = CommonUtil.getIdFromList(relFileList,"zbfrFileId");
+            LambdaQueryWrapper<PubFileInf> fileInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            fileInfLambdaQueryWrapper.in(PubFileInf::getPfiFileId,idList);
+            fileInfLambdaQueryWrapper.eq(PubFileInf::getPfiIsDel,"00");
+            otherFileList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
+        }
+        String directory = "E:\\home\\" ;
+//        String directory = configService.selectConfigByKey("hr_resume_export");
+
+        for (int i = 0; i < otherFileList.size(); i++) {
+            Map map = new HashMap();
+            //文件路径
+            String pfiFileUrl = otherFileList.get(i).getPfiFileUrl();
+            //文件名称
+            String pfiFileName = otherFileList.get(i).getPfiFileName();
+            map.put("pfiFileUrl",pfiFileUrl);
+            map.put("pfiFileName",pfiFileName);
+            list.add(map);
+        }
+        for (int j = 0; j < contractFileList.size(); j++) {
+            Map map = new HashMap();
+            //文件路径
+            String pfiFileUrl = contractFileList.get(j).getPfiFileUrl();
+            //文件名称
+            String pfiFileName = contractFileList.get(j).getPfiFileName();
+            map.put("pfiFileUrl",pfiFileUrl);
+            map.put("pfiFileName",pfiFileName);
+            list.add(map);
+        }
+        for (int k = 0; k < invoiceFileList.size(); k++) {
+            Map map = new HashMap();
+            //文件路径
+            String pfiFileUrl = invoiceFileList.get(k).getPfiFileUrl();
+            //文件名称
+            String pfiFileName = invoiceFileList.get(k).getPfiFileName();
+            map.put("pfiFileUrl",pfiFileUrl);
+            map.put("pfiFileName",pfiFileName);
+            list.add(map);
+
+        }
+        for (int l = 0; l < list.size(); l++) {
+            String files = list.get(l).get("pfiFileUrl");
+            String names = list.get(l).get("pfiFileName");
+            downloadFile(files, directory+ names);
+        }
+        /** 压缩方法 */
+        FileOutputStream fos1= new FileOutputStream(new File("E:/" + "rzgl"+DateUtils.dateTimeNow()+ ".zip"));
+        toZip("E:\\home",fos1 ,true);
+        File zipFile = new File("E:/" + "rzgl"+DateUtils.dateTimeNow()+ ".zip");
+        if(zipFile.exists()) {
+            down(response, "rzgl" + DateUtils.dateTimeNow() + ".zip", "E:/");
+            zipFile.delete();
+        }
+        return null;
+    }
+
+    public void down(HttpServletResponse response, String fileName, String path) {
+        response.setHeader("content-type", "application/octet-stream");
+        response.setContentType("application/octet-stream");
+        response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
+        byte[] buff = new byte[1024];
+        //创建缓冲输入流
+        BufferedInputStream bis = null;
+        OutputStream outputStream = null;
+        try {
+            outputStream = response.getOutputStream();
+
+            //这个路径为待下载文件的路径
+            bis = new BufferedInputStream(new FileInputStream(new File(path + fileName )));
+            int read = bis.read(buff);
+
+            //通过while循环写入到指定了的文件夹中
+            while (read != -1) {
+                outputStream.write(buff, 0, buff.length);
+                outputStream.flush();
+                read = bis.read(buff);
+            }
+        } catch ( Exception e ) {
+            e.printStackTrace();
+            // 下载失败
+        } finally {
+            if (bis != null) {
+                try {
+                    bis.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 下载远程文件并保存到本地
+     * @param remoteFilePath 远程文件路径
+     * @param localFilePath 本地文件路径(带文件名)
+     */
+    public  static  String  downloadFile(String remoteFilePath, String localFilePath)
+    {
+        URL urlfile = null;
+        HttpURLConnection httpUrl = null;
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+
+        File path = new File("E:\\home\\");
+        //判断文件是否存在
+        if(!path.exists()){
+            path.mkdirs();
+        }
+        File f = new File( localFilePath );
+        try
+        {
+            urlfile = new URL(remoteFilePath);
+            httpUrl = (HttpURLConnection)urlfile.openConnection();
+            httpUrl.connect();
+            bis = new BufferedInputStream(httpUrl.getInputStream());
+            bos = new BufferedOutputStream(new FileOutputStream(f));
+            int len = 2048;
+            byte[] b = new byte[len];
+            while ((len = bis.read(b)) != -1)
+            {
+                bos.write(b, 0, len);
+            }
+            bos.flush();
+            bis.close();
+            httpUrl.disconnect();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            try
+            {
+                bis.close();
+                bos.close();
+            }
+            catch (IOException e)
+            {
+                e.printStackTrace();
+            }
+        }
+        return f.getAbsolutePath();
+    }
+
+
+      /**
+       * 压缩成ZIP 方法     * @param srcDir 压缩文件夹路径
+       * @param out    压缩文件输出流
+       * @param KeepDirStructure  是否保留原来的目录结构,true:保留目录结构;
+       *                          false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)
+       * @throws RuntimeException 压缩失败会抛出运行时异常
+       */
+    public static void toZip(String srcDir, OutputStream out, boolean KeepDirStructure) throws RuntimeException{
+        long start = System.currentTimeMillis();
+        ZipOutputStream zos = null ;
+        try {
+            zos = new ZipOutputStream(out);
+            File sourceFile = new File(srcDir);
+            compress(sourceFile,zos,sourceFile.getName(),KeepDirStructure);
+            long end = System.currentTimeMillis();
+             System.out.println("压缩完成,耗时:" + (end - start) +" ms");
+        } catch (Exception e) {
+                throw new RuntimeException("zip error from ZipUtils",e);
+        }finally{
+            if(zos != null){
+                try {
+                    zos.flush();
+                    zos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+    }
+      /**
+       * 递归压缩方法
+       * @param sourceFile 源文件
+       * @param zos        zip输出流
+       * @param name       压缩后的名称
+       * @param KeepDirStructure  是否保留原来的目录结构,true:保留目录结构;
+       *                          false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)
+       * @throws Exception
+       */
+    private static void compress(File sourceFile, ZipOutputStream zos, String name,
+                          boolean KeepDirStructure) throws Exception{
+        byte[] buf = new byte[2 * 1024];
+        if(sourceFile.isFile()){
+              // 向zip输出流中添加一个zip实体,构造器中name为zip实体的文件的名字
+                zos.putNextEntry(new ZipEntry(name));
+               // copy文件到zip输出流中
+                int len;
+               FileInputStream in = new FileInputStream(sourceFile);
+                while ((len = in.read(buf)) != -1){
+                        zos.write(buf, 0, len);
+                    }
+                // Complete the entry
+              zos.closeEntry();
+               in.close();
+        } else {
+                //是文件夹
+               File[] listFiles = sourceFile.listFiles();
+              if(listFiles == null || listFiles.length == 0){
+                    // 需要保留原来的文件结构时,需要对空文件夹进行处理
+                  if(KeepDirStructure){
+                        // 空文件夹的处理
+                       zos.putNextEntry(new ZipEntry(name + "/"));
+                        // 没有文件,不需要文件的copy
+                       zos.closeEntry();
+                  }
+
+              }else {
+                   for (File file : listFiles) {
+                        // 判断是否需要保留原来的文件结构
+                        if (KeepDirStructure) {
+                           // 注意:file.getName()前面需要带上父文件夹的名字加一斜杠,
+                            // 不然最后压缩包中就不能保留原来的文件结构,即:所有文件都跑到压缩包根目录下了
+                            compress(file, zos, name + "/" + file.getName(),KeepDirStructure);
+                        } else {
+                            compress(file, zos, file.getName(),KeepDirStructure);
+                        }
+
+                   }
+              }
+        }
+    }
 }
 

+ 5 - 1
sc-service/src/main/resources/mapper/common/ContractMapper.xml

@@ -16,12 +16,16 @@
             z.create_by 'createBy',
             date_format( z.create_time,   '%Y-%m-%d %T') 'createTime',
             s.scy_name 'scyName',
-            u.nick_name 'nickName'
+            u.nick_name 'nickName',
+            f.pfi_url   'pfiUrl',
+            f.pfi_file_name 'pfiFileName'
             from zc_finance_contract z
             left join sys_company s
             on z.zfc_management_id = s.scy_id
             left join sys_user u
             on z.create_by = u.user_id
+            left join pub_file_inf f
+            on z.zfc_file = f.pfi_file_id
             where 1=1
             and z.zfc_status = '00'
             and z.zfc_management_id = #{paramMap.zfcManagementId}

+ 9 - 2
sc-service/src/main/resources/mapper/common/FinanceInfMapper.xml

@@ -12,15 +12,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         DATE_FORMAT(zfi_expire_date,'%Y-%m-%d %H:%i:%s') AS 	'zfiExpireDate',
         zfi_product_id      'zfiProductId',
         zfpcr_rate 		    'zfpcrRate',
-        zfpcr_loan_type 	'zfpcrLoantype'
+        zfpcr_loan_type 	'zfpcrLoantype',
+        zfpcr_charge_rate   'zfpcrChargeRate'
         FROM
         zc_finance_inf
         LEFT JOIN zc_finance_pro_com_rel
         ON zfi_core_quota_id = zfpcr_id
-        WHERE zfi_status = '02'
+        WHERE 1=1
         <if test="paramMap.companyId != null  and paramMap.companyId != ''">
             AND zfi_supplier_id = #{paramMap.companyId}
         </if>
+        <if test="paramMap.zfiId != null  and paramMap.zfiId != ''">
+            AND (zfi_id= #{paramMap.zfiId} OR zfi_status = '02')
+        </if>
+        <if test="paramMap.zfiId == null  or paramMap.zfiId == ''">
+            zfi_status = '02'
+        </if>
         order by zc_finance_inf.create_time desc
     </select>
 </mapper>

+ 19 - 39
sc-service/src/main/resources/mapper/financeRecord/FinanceRecordMapper.xml

@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             DATE_FORMAT(r.zfr_loan_date,'%Y-%m-%d') AS 'zfrLoanDate',
             r.zfr_approve_stt     'zfrApproveStt',
             r.zfr_status          'zfrStatus',
+            r.zfr_finance_id      'zfrFinanceId',
             i.zfi_id              'zfiId',
             i.zfi_number          'zfiNumner',
             i.zfi_core_id         'zfiCoreId',
@@ -39,45 +40,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="paramMap.zfrStatus != null  and paramMap.zfrStatus != ''">
             and r.zfr_status = #{paramMap.zfrStatus}
         </if>
-<!--        <if test="paramMap.pvfId != null  and paramMap.pvfId != ''">-->
-<!--            and i.pvf_id = #{paramMap.pvfId}-->
-<!--        </if>-->
-<!--        <if test="paramMap.pvfCategory != null  and paramMap.pvfCategory != ''">-->
-<!--            and i.pvf_category = #{paramMap.pvfCategory}-->
-<!--        </if>-->
-<!--        <if test="paramMap.cciAbbreviation != null  and paramMap.cciAbbreviation != ''">-->
-<!--            and c.cci_abbreviation like concat('%', #{paramMap.cciAbbreviation}, '%')-->
-<!--        </if>-->
-<!--        <if test="paramMap.cifNo != null  and paramMap.cifNo != ''">-->
-<!--            and a.cif_no like concat('%', #{paramMap.cifNo}, '%')-->
-<!--        </if>-->
-<!--        <if test="paramMap.cifName != null  and paramMap.cifName != ''">-->
-<!--            and a.cif_name like concat('%', #{paramMap.cifName}, '%')-->
-<!--        </if>-->
-<!--        <if test="paramMap.pifName != null  and paramMap.pifName != ''">-->
-<!--            and p.pif_name like concat('%', #{paramMap.pifName}, '%')-->
-<!--        </if>-->
-<!--        <if test="paramMap.pvfInvoiceTitle != null  and paramMap.pvfInvoiceTitle != ''">-->
-<!--            and i.pvf_invoice_title like concat('%', #{paramMap.pvfInvoiceTitle}, '%')-->
-<!--        </if>-->
-<!--        <if test="paramMap.pvfType != null  and paramMap.pvfType != ''">-->
-<!--            and i.pvf_type = #{paramMap.pvfType}-->
-<!--        </if>-->
-<!--        <if test="paramMap.pvfAuthStt != null  and paramMap.pvfAuthStt != ''">-->
-<!--            and i.pvf_auth_stt = #{paramMap.pvfAuthStt}-->
-<!--        </if>-->
-<!--        <if test="paramMap.startTime != null  and paramMap.startTime != ''">-->
-<!--            and i.pvf_date &gt;= #{paramMap.startTime}-->
-<!--        </if>-->
-<!--        <if test="paramMap.endTime != null  and paramMap.endTime != ''">-->
-<!--            and i.pvf_date &lt;=  #{paramMap.endTime}-->
-<!--        </if>-->
-<!--        <if test="paramMap.startCreate != null  and paramMap.startCreate != ''">-->
-<!--            and DATE_FORMAT(i.create_time, '%Y-%m-%d') &gt;= #{paramMap.startCreate}-->
-<!--        </if>-->
-<!--        <if test="paramMap.endCreate != null  and paramMap.endCreate != ''">-->
-<!--            and DATE_FORMAT(i.create_time, '%Y-%m-%d') &lt;=  #{paramMap.endCreate}-->
-<!--        </if>-->
+        <if test="paramMap.zfiSupplierId != null  and paramMap.zfiSupplierId != ''">
+            and i.zfi_supplier_id = #{paramMap.zfiSupplierId}
+        </if>
+        <if test="paramMap.zfiCoreId != null  and paramMap.zfiCoreId != ''">
+            and i.zfi_core_id = #{paramMap.zfiCoreId}
+        </if>
+        <if test="paramMap.coreScyName != null  and paramMap.coreScyName != ''">
+            and s.scy_name  like concat('%', #{paramMap.coreScyName}, '%')
+        </if>
+        <if test="paramMap.supplierScyName != null  and paramMap.supplierScyName != ''">
+            and c.scy_name like concat('%', #{paramMap.supplierScyName}, '%')
+        </if>
+        <if test="paramMap.zfpcrAmount != null  and paramMap.zfpcrAmount != ''">
+            and p.zfpcr_amount = #{paramMap.cifNo}
+        </if>
+        <if test="paramMap.zfrRate != null  and paramMap.zfrRate != ''">
+            and r.zfr_rate = #{paramMap.zfrRate}
+        </if>
         order by r.create_time desc
     </select>
     <select id="selectBillInfList" parameterType="map" resultType="map">