Преглед на файлове

修复暂存,修改删除所有附件问题,新增删除服务器内文件pdf,新增pdf压缩

Administrator преди 11 месеца
родител
ревизия
30c33259f9

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/loan/LoanApplicationController.java

@@ -80,7 +80,7 @@ public class LoanApplicationController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:application:query')")
     @GetMapping(value = "/{loanApplicationId}")
     public AjaxResult getInfo(@PathVariable("loanApplicationId") Long loanApplicationId) {
-        return success(loanApplicationService.selectLoanApplicationByLoanApplicationId(loanApplicationId));
+        return loanApplicationService.selectLoanApplicationByLoanApplicationId(loanApplicationId);
     }
 
     /**
@@ -111,7 +111,7 @@ public class LoanApplicationController extends BaseController {
     @Log(title = "贷款申请主", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
     public AjaxResult edit(@RequestBody LoanApplication loanApplication) {
-        return toAjax(loanApplicationService.updateLoanApplication(loanApplication));
+        return loanApplicationService.updateLoanApplication(loanApplication);
     }
 
     /**

+ 24 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java

@@ -6,9 +6,11 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.TimerTask;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.uuid.Seq;
 import com.ruoyi.system.domain.loan.LoanApplicationFj;
@@ -31,7 +33,11 @@ import com.ruoyi.system.domain.SysOperLog;
 import com.ruoyi.system.service.ISysLogininforService;
 import com.ruoyi.system.service.ISysOperLogService;
 import eu.bitwalker.useragentutils.UserAgent;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
 
 import static com.ruoyi.common.constant.CommonConstants.*;
 
@@ -40,10 +46,20 @@ import static com.ruoyi.common.constant.CommonConstants.*;
  *
  * @author ruoyi
  */
+
+@Component
 public class AsyncFactory
 {
     private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");
 
+    @Autowired
+    private static RedisCache redisCache;
+
+    @Autowired
+    public void setRedisCache(RedisCache redisCache) {
+        AsyncFactory.redisCache = redisCache;
+    }
+
     /**
      * 记录登录信息
      *
@@ -130,6 +146,9 @@ public class AsyncFactory
             @Override
             public void run()
             {
+                String key = "lock:A:"+loanApplicationNumber;
+                redisCache.setCacheObject(key,1,5, TimeUnit.MINUTES);
+                //自定义锁,必须要所有异步任务都跑完才能再次修改
                 //根据文件类型进行判断是否需要合成pdf
                 Map<String, List<LoanApplicationFj>> bigTypeMap = loanApplicationFjList.stream().collect(Collectors.groupingBy(LoanApplicationFj::getBigType));
                 if (bigTypeMap.size() > 0){
@@ -142,6 +161,8 @@ public class AsyncFactory
                         createPdfFromImages(loanApplicationFjList,loanApplicationFjListB,loanApplicationNumber,B);
                     }
                 }
+                //自定义锁,必须要所有异步任务都跑完才能再次修改
+                redisCache.deleteObject(key);
             }
         };
     }
@@ -242,6 +263,8 @@ public class AsyncFactory
             @Override
             public void run()
             {
+                String key = "lock:B:"+loanApplicationNumber;
+                redisCache.setCacheObject(key,1,5, TimeUnit.MINUTES);
                 List<String> imagePaths = new ArrayList<>();
                 //根据文件类型进行判断是否需要合成pdf
                 for (ShareholderFj shareholderFj : shareholderFjList) {
@@ -304,6 +327,7 @@ public class AsyncFactory
                         SpringUtils.getBean(ShareholderFjMapper.class).updateShareholderFj(shareholderFj);
                     }
                 }
+                redisCache.deleteObject(key);
             }
         };
     }

+ 52 - 20
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/LoanApplicationServiceImpl.java

@@ -84,9 +84,21 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
      * @return 贷款申请主
      */
     @Override
-    public LoanApplication selectLoanApplicationByLoanApplicationId(Long loanApplicationId) {
+    public AjaxResult selectLoanApplicationByLoanApplicationId(Long loanApplicationId) {
 
         LoanApplication loanApplication = loanApplicationMapper.selectLoanApplicationByLoanApplicationId(loanApplicationId);
+        if (loanApplication != null){
+            String loanApplicationNumber = loanApplication.getLoanApplicationNumber();
+            //判断自定义锁,必须全部释放,才能修改
+            String keyA = "lock:A:" + loanApplicationNumber;
+            String keyB = "lock:B:" + loanApplicationNumber;
+            Object cacheObjectA = redisCache.getCacheObject(keyA);
+            Object cacheObjectB = redisCache.getCacheObject(keyB);
+            if (ObjectUtils.isNotEmpty(cacheObjectA)||ObjectUtils.isNotEmpty(cacheObjectB)) {
+                return AjaxResult.error("稍后重试,文件正在生成");
+            }
+        }
+
         //查询企业信息
         SysUserEnterprise sysUserEnterprise = sysUserEnterpriseMapper.selectSysUserEnterpriseByEnterpriseId(loanApplication.getEnterpriseId());
         loanApplication.setSysUserEnterprise(sysUserEnterprise);
@@ -120,10 +132,10 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         }
         //会议状态
         loanApplication.setVotingResult(FOR);
-        if(redisCache.getCacheObject(loanApplication.getLoanApplicationNumber()+"tp")!=null){
-            loanApplication.setVotingResult(redisCache.getCacheObject(loanApplication.getLoanApplicationNumber()+"tp"));
+        if (redisCache.getCacheObject(loanApplication.getLoanApplicationNumber() + "tp") != null) {
+            loanApplication.setVotingResult(redisCache.getCacheObject(loanApplication.getLoanApplicationNumber() + "tp"));
         }
-        return loanApplication;
+        return AjaxResult.success(loanApplication);
     }
 
     /**
@@ -157,7 +169,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         List<SysRole> roles = user.getRoles();
         Boolean bl = false;
         for (SysRole role : roles) {
-            if (role.getRoleKey().equals("admin") || role.getRoleKey().equals("manager")|| role.getRoleKey().equals("sensible")) {
+            if (role.getRoleKey().equals("admin") || role.getRoleKey().equals("manager") || role.getRoleKey().equals("sensible")) {
                 bl = true;
                 break;
             }
@@ -168,8 +180,8 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         List<LoanApplication> loanApplications = loanApplicationMapper.conferenceList(loanApplication);
         for (LoanApplication application : loanApplications) {
             application.setVotingResult(FOR);
-            if(redisCache.getCacheObject(application.getLoanApplicationNumber()+"tp")!=null){
-                application.setVotingResult(redisCache.getCacheObject(application.getLoanApplicationNumber()+"tp"));
+            if (redisCache.getCacheObject(application.getLoanApplicationNumber() + "tp") != null) {
+                application.setVotingResult(redisCache.getCacheObject(application.getLoanApplicationNumber() + "tp"));
             }
         }
         return loanApplications;
@@ -207,7 +219,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
      */
     @Override
     public int insertLoanApplication(LoanApplication loanApplication) {
-        if (loanApplicationMapper.selectLoanApplicationList(loanApplication).size() > 0){
+        if (loanApplicationMapper.selectLoanApplicationList(loanApplication).size() > 0) {
             return 0;
         }
         //先去查询贷款编码是否已经存在
@@ -261,7 +273,16 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
      * @return 结果
      */
     @Override
-    public int updateLoanApplication(LoanApplication loanApplication) {
+    public AjaxResult updateLoanApplication(LoanApplication loanApplication) {
+
+        //判断自定义锁,必须全部释放,才能修改
+        String keyA = "lock:A:" + loanApplication.getLoanApplicationNumber();
+        String keyB = "lock:B:" + loanApplication.getLoanApplicationNumber();
+        Object cacheObjectA = redisCache.getCacheObject(keyA);
+        Object cacheObjectB = redisCache.getCacheObject(keyB);
+        if (ObjectUtils.isNotEmpty(cacheObjectA)||ObjectUtils.isNotEmpty(cacheObjectB)) {
+            return AjaxResult.error("稍后重试,文件正在生成");
+        }
         loanApplication.setUpdateTime(DateUtils.getNowDate());
         loanApplication.setLoanApplicationType(TWO);
         loanApplication.setApplicationTime(DateUtils.getNowDate());
@@ -284,7 +305,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 //新增新增的附件
                 loanApplicationFjMapper.batchLoanApplicationFj(loanApplicationFjsInsert);
             }
-            if (loanApplicationFjsInsert.size() > 0 || loanApplicationFjIdList.length > 0){
+            if (loanApplicationFjsInsert.size() > 0 || loanApplicationFjIdList.length > 0) {
                 AsyncManager.me().execute(AsyncFactory.createPdfFromImages(loanApplicationFjList, loanApplication.getLoanApplicationNumber()));
             }
         }
@@ -303,7 +324,8 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         if (shareholderFjIdList.length > 0) {
             shareholderFjMapper.deleteShareholderFjByShareholderFjIds(shareholderFjIdList);
         }
-        return loanApplicationMapper.updateLoanApplication(loanApplication);
+        int rows = loanApplicationMapper.updateLoanApplication(loanApplication);
+        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
     }
 
     /**
@@ -314,6 +336,14 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
      */
     @Override
     public AjaxResult temporary(LoanApplication loanApplication) {
+        //判断自定义锁,必须全部释放,才能修改
+        String keyA = "lock:A:" + loanApplication.getLoanApplicationNumber();
+        String keyB = "lock:B:" + loanApplication.getLoanApplicationNumber();
+        Object cacheObjectA = redisCache.getCacheObject(keyA);
+        Object cacheObjectB = redisCache.getCacheObject(keyB);
+        if (ObjectUtils.isNotEmpty(cacheObjectA)||ObjectUtils.isNotEmpty(cacheObjectB)) {
+            return AjaxResult.error("稍后重试,文件正在生成");
+        }
         loanApplication.setLoanApplicationType(ONE);
         Long loanApplicationId = loanApplication.getLoanApplicationId();
         //走修改
@@ -334,7 +364,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                     //新增新增的附件
                     loanApplicationFjMapper.batchLoanApplicationFj(loanApplicationFjsInsert);
                 }
-                if (loanApplicationFjsInsert.size() > 0 || loanApplicationFjIdList.length > 0){
+                if (loanApplicationFjsInsert.size() > 0 || loanApplicationFjIdList.length > 0) {
                     AsyncManager.me().execute(AsyncFactory.createPdfFromImages(loanApplicationFjList, loanApplication.getLoanApplicationNumber()));
                 }
             }
@@ -477,13 +507,15 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         List<WaitRemind> waitRemindList = new ArrayList<>();
         //查询审核管理员用户id
         List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectRoleListNoDataScope();
-        //A角色进度之前审核不通过,直接放入回收站,之后的进入到申诉状态
+        //A角色进度之前审核不通过,给客户回馈不通过问题,之后的进入到申诉状态
         if (THR.equals(auditType) && ONE.equals(auditSchedule)) {
             loanApplication.setAuditType(auditType);
             loanApplication.setAuditSchedule(auditSchedule);
-            loanApplication.setLoanApplicationType(THR);
+            loanApplication.setLoanApplicationType(TWO);
+            //插入不通过原因
+            loanApplication.setRejectionReason(reviewComments.getAuditView());
             loanApplicationMapper.updateLoanApplication(loanApplication);
-            //给A角色,审核管理员发送待办
+          /*  //给A角色,审核管理员发送待办
             WaitRemind waitRemind = new WaitRemind();
             waitRemind.setLoanApplicationId(loanApplicationId);
             waitRemind.setLoanApplicationNumber(loanApplication.getLoanApplicationNumber());
@@ -508,7 +540,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                     waitRemindList.add(waitRemindManager);
                 }
             }
-            waitRemindMapper.batchWaitRemind(waitRemindList);
+            waitRemindMapper.batchWaitRemind(waitRemindList);*/
             return AjaxResult.success();
             //A角色审核不通过 audit_schedule = 2的时候贷款申请进度处于担保初审状态
         } else if (THR.equals(auditType) && auditSchedule.equals(TWO)) {
@@ -700,7 +732,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
             loanSchedule.setLoanScheduleTime(DateUtils.getNowDate());
             loanScheduleMapper.insertLoanSchedule(loanSchedule);
             //插入审核通过的待办提醒
-            if(waitRemindList.size()>0){
+            if (waitRemindList.size() > 0) {
                 waitRemindMapper.batchWaitRemind(waitRemindList);
             }
 
@@ -946,7 +978,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                     //删掉参会人员
                     sysUserConferenceMapper.deleteSysUserConferenceByTime(loanApplicationOld.getReviewTime(), loanApplicationOld.getLoanApplicationId());
                 }
-            }else {
+            } else {
                 //进入待审核
                 loanApplication.setAuditType(ONE);
             }
@@ -1535,9 +1567,9 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 //拼接姓名
                 StringBuilder sb = new StringBuilder();
                 for (SysUserConference userConference : sysUserConferences) {
-                    if(sb.length()>0){
+                    if (sb.length() > 0) {
                         sb.append("  ").append(userConference.getRealName());
-                    }else{
+                    } else {
                         sb.append(userConference.getRealName());
                     }
 

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/loan/LoanApplication.java

@@ -260,6 +260,10 @@ public class LoanApplication extends BaseEntity
     /** 贷款申请状态 1:暂存 2:正常 3:回收站 4:归档 */
     @Excel(name = "贷款申请状态 1:暂存 2:正常 3:回收站 4:归档")
     private String loanApplicationType;
+    /**
+     * 业务审核/分配驳回原因,给贷款客户使用,只展示最新的原因
+     */
+    private String rejectionReason;
 
     /** A角色用户ID */
     @Excel(name = "A角色用户ID")
@@ -340,6 +344,14 @@ public class LoanApplication extends BaseEntity
      */
     private Long[] shareholderFjIdList;
 
+    public String getRejectionReason() {
+        return rejectionReason;
+    }
+
+    public void setRejectionReason(String rejectionReason) {
+        this.rejectionReason = rejectionReason;
+    }
+
     public Long[] getLoanApplicationFjIdList() {
         return loanApplicationFjIdList;
     }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/loan/ILoanApplicationService.java

@@ -21,7 +21,7 @@ public interface ILoanApplicationService
      * @param loanApplicationId 贷款申请主主键
      * @return 贷款申请主
      */
-    public LoanApplication selectLoanApplicationByLoanApplicationId(Long loanApplicationId);
+    public AjaxResult selectLoanApplicationByLoanApplicationId(Long loanApplicationId);
 
     /**
      * 查询贷款申请主列表
@@ -46,7 +46,7 @@ public interface ILoanApplicationService
      * @param loanApplication 贷款申请主
      * @return 结果
      */
-    public int updateLoanApplication(LoanApplication loanApplication);
+    public AjaxResult updateLoanApplication(LoanApplication loanApplication);
 
     /**
      * 暂存

+ 6 - 2
ruoyi-system/src/main/resources/mapper/system/LoanApplicationMapper.xml

@@ -66,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="auditType"    column="audit_type"    />
         <result property="loanApplicationType"    column="loan_application_type"    />
         <result property="reviewSchedule"    column="review_schedule"    />
+        <result property="rejectionReason"    column="rejection_reason"    />
         <result property="aUserId"    column="a_user_id"    />
         <result property="aUserName"    column="a_user_name"    />
         <result property="aAuthorize"    column="a_authorize"    />
@@ -81,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLoanApplicationVo">
-        select loan_application_id, loan_application_number, application_type,application_amount,actually_amount,enterprise_id,guarantee_shareholder_name,guarantee_shareholder_id_card, application_bank, usage_period, purpose_funds, repayment_source, enterprise_name, category_type, is_make, is_new, is_small, is_duty, company_introduction, customer_type, corporation_front, corporation_back, corporation_name, corporation_id_card, corporation_phone,corporation_address,corporation_expiration_date, family_population, corporation_job, is_loan, receivable_pay, business_situation, business_efficiency, corporation_marital_status, spouse_front, spouse_back, spouse_name, spouse_id_card, spouse_phone, guarantee_type, guarantee_front, guarantee_back, guarantee_name, guarantee_id_card, guarantee_phone, guarantee_marital_status, guarantee_spouse_front, guarantee_spouse_back, guarantee_spouse_name, guarantee_spouse_id_card, guarantee_spouse_phone, user_id, id_card, application_time, file_time,review_time, loan_schedule, audit_schedule, audit_type, loan_application_type,review_schedule, a_user_id, a_user_name,a_authorize, b_user_id, b_user_name,f_user_id, f_user_name, create_by, create_time, update_by, update_time, remark from loan_application
+        select loan_application_id, loan_application_number, application_type,application_amount,actually_amount,enterprise_id,guarantee_shareholder_name,guarantee_shareholder_id_card, application_bank, usage_period, purpose_funds, repayment_source, enterprise_name, category_type, is_make, is_new, is_small, is_duty, company_introduction, customer_type, corporation_front, corporation_back, corporation_name, corporation_id_card, corporation_phone,corporation_address,corporation_expiration_date, family_population, corporation_job, is_loan, receivable_pay, business_situation, business_efficiency, corporation_marital_status, spouse_front, spouse_back, spouse_name, spouse_id_card, spouse_phone, guarantee_type, guarantee_front, guarantee_back, guarantee_name, guarantee_id_card, guarantee_phone, guarantee_marital_status, guarantee_spouse_front, guarantee_spouse_back, guarantee_spouse_name, guarantee_spouse_id_card, guarantee_spouse_phone, user_id, id_card, application_time, file_time,review_time, loan_schedule, audit_schedule, audit_type, loan_application_type,review_schedule,rejection_reason, a_user_id, a_user_name,a_authorize, b_user_id, b_user_name,f_user_id, f_user_name, create_by, create_time, update_by, update_time, remark from loan_application
     </sql>
 
     <select id="selectLoanApplicationList" parameterType="LoanApplication" resultMap="LoanApplicationResult">
@@ -120,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="spouseName != null  and spouseName != ''"> and spouse_name like concat('%', #{spouseName}, '%')</if>
             <if test="spouseIdCard != null  and spouseIdCard != ''"> and spouse_id_card = #{spouseIdCard}</if>
             <if test="spousePhone != null  and spousePhone != ''"> and spouse_phone = #{spousePhone}</if>
-            <if test="guaranteeType != null  and guaranteeType != ''"> and FIND_IN_SET(guarantee_type,#{guaranteeType}</if>
+            <if test="guaranteeType != null  and guaranteeType != ''"> and FIND_IN_SET(guarantee_type,#{guaranteeType})</if>
             <if test="guaranteeFront != null  and guaranteeFront != ''"> and guarantee_front = #{guaranteeFront}</if>
             <if test="guaranteeBack != null  and guaranteeBack != ''"> and guarantee_back = #{guaranteeBack}</if>
             <if test="guaranteeName != null  and guaranteeName != ''"> and guarantee_name like concat('%', #{guaranteeName}, '%')</if>
@@ -333,6 +334,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="auditType != null and auditType != ''">audit_type,</if>
             <if test="loanApplicationType != null and loanApplicationType != ''">loan_application_type,</if>
             <if test="reviewSchedule != null and reviewSchedule != ''">review_schedule,</if>
+            <if test="rejectionReason != null and rejectionReason != ''">rejection_reason,</if>
             <if test="aUserId != null">a_user_id,</if>
             <if test="aUserName != null">a_user_name,</if>
             <if test="aAuthorize != null and aAuthorize != ''">a_authorize,</if>
@@ -407,6 +409,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="auditType != null and auditType != ''">#{auditType},</if>
             <if test="loanApplicationType != null and loanApplicationType != ''">#{loanApplicationType},</if>
             <if test="reviewSchedule != null and reviewSchedule != ''">#{reviewSchedule},</if>
+            <if test="rejectionReason != null and rejectionReason != ''">#{rejectionReason},</if>
             <if test="aUserId != null">#{aUserId},</if>
             <if test="aUserName != null">#{aUserName},</if>
             <if test="aAuthorize != null and aAuthorize != ''">#{aAuthorize},</if>
@@ -485,6 +488,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="auditType != null and auditType != ''">audit_type = #{auditType},</if>
             <if test="loanApplicationType != null and loanApplicationType != ''">loan_application_type = #{loanApplicationType},</if>
             <if test="reviewSchedule != null and reviewSchedule != ''">review_schedule = #{reviewSchedule},</if>
+            <if test="rejectionReason != null and rejectionReason != ''">rejection_reason = #{rejectionReason},</if>
             <if test="aUserId != null">a_user_id = #{aUserId},</if>
             <if test="aUserName != null">a_user_name = #{aUserName},</if>
             <if test="aAuthorize != null and aAuthorize != ''">a_authorize = #{aAuthorize},</if>