浏览代码

平台拒绝增加待办,核心开立、供应商开立内部审批拒绝增加待办

xuefy 3 年之前
父节点
当前提交
fe08981367

+ 137 - 9
sc-service/src/main/java/com/huyi/service/common/flowable/controller/FlowableController.java

@@ -656,8 +656,9 @@ public class  FlowableController extends BaseController
                 zcFinanceInf.setZfiCoreStatus("02");
             }
             zcFinanceInfService.updateById(zcFinanceInf);
+
             //待办更改为已办
-            LambdaQueryWrapper<SysNotice> noticeLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        /*    LambdaQueryWrapper<SysNotice> noticeLambdaQueryWrapper = new LambdaQueryWrapper<>();
             //待办
             noticeLambdaQueryWrapper.eq(SysNotice::getStatus,"0");
             //融信编号
@@ -668,7 +669,15 @@ public class  FlowableController extends BaseController
             SysNotice notice = new SysNotice();
             //已办
             notice.setStatus("1");
-            sysNoticeService.update(notice,noticeLambdaQueryWrapper);
+            sysNoticeService.update(notice,noticeLambdaQueryWrapper);*/
+            //先查询需要修改的待办,最后改,放在这改的话,有事务会锁表,后面生成待办就超时
+            //盖章待办改为已办
+            LambdaQueryWrapper<SysNotice> queryWrapperA = new LambdaQueryWrapper<>();
+            queryWrapperA.eq(SysNotice::getTableId,id);
+            queryWrapperA.eq(SysNotice::getType,"00");
+            queryWrapperA.eq(SysNotice::getWorkType,"01");
+            queryWrapperA.eq(SysNotice::getStatus,"0");
+            List<SysNotice> noticeList =  sysNoticeService.findSysNotices(queryWrapperA);
             //根据Id查询实体类
             ZcFinanceInf financeInf = zcFinanceInfService.getById(id);
             //核心企业Id
@@ -686,6 +695,19 @@ public class  FlowableController extends BaseController
             //发起人最终结果【拒绝】消息通知
             String title = "【审批拒绝】由"+ userName +"于"+ dateTime +"发起的:融信"+ zfiNumber +"审批"+ userNowName +"被拒绝,拒绝的理由为:"+reason;
             remoteSystemService.sendNotice(zfiCoreId, id, title,"01","01","","0", userId.toString(),"", null, null);
+            String titleName = "【内部审核退回】融信【"+zfiNumber+"】内部审批退回,请维护资料后,再次提交";
+            //给发起人生成待办
+            remoteSystemService.sendNotice(zfiCoreId,id,titleName,"00","","01","0",userId.toString(),"", "01", "/credit/creditUpdate/"+id);
+            //修改待办为已办
+            if(noticeList.size() > 0) {
+                //提取主键
+                List<String> idList = CommonUtil.getIdFromList(noticeList,"noticeId");
+                LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.in(SysNotice::getNoticeId,idList);
+                SysNotice notice = new SysNotice();
+                notice.setStatus("1");
+                sysNoticeService.update(notice,queryWrapper);
+            }
             //核心企业确权审批
         }else if("1000000007".equals(menuId)){
             ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
@@ -816,7 +838,8 @@ public class  FlowableController extends BaseController
                 zcFinanceInf.setZfiSupplierStatus("02");
             }
             zcFinanceInfService.update(zcFinanceInf,lambdaQueryWrapper);
-            //待办更改为已办
+
+         /*   //待办更改为已办
             LambdaQueryWrapper<SysNotice> noticeLambdaQueryWrapper = new LambdaQueryWrapper<>();
             //待办
             noticeLambdaQueryWrapper.eq(SysNotice::getStatus,"0");
@@ -828,7 +851,15 @@ public class  FlowableController extends BaseController
             SysNotice notice = new SysNotice();
             //已办
             notice.setStatus("1");
-            sysNoticeService.update(notice,noticeLambdaQueryWrapper);
+            sysNoticeService.update(notice,noticeLambdaQueryWrapper);*/
+            //先查询需要修改的待办,最后改,放在这改的话,有事务会锁表,后面生成待办就超时
+            //盖章待办改为已办
+            LambdaQueryWrapper<SysNotice> queryWrapperA = new LambdaQueryWrapper<>();
+            queryWrapperA.eq(SysNotice::getTableId,zfiId);
+            queryWrapperA.eq(SysNotice::getType,"00");
+            queryWrapperA.eq(SysNotice::getWorkType,"01");
+            queryWrapperA.eq(SysNotice::getStatus,"0");
+            List<SysNotice> noticeList =  sysNoticeService.findSysNotices(queryWrapperA);
             //TODO 发起人最终结果【拒绝】消息通知
             //查询发起人,融资企业Id
             ZcFinanceInf financeInf = zcFinanceInfService.getById(zfiId);
@@ -847,6 +878,19 @@ public class  FlowableController extends BaseController
             list.add(user);
             String title = "【审批拒绝】由"+ userName +"于"+ createTime +"发起的:融信"+ number +"审批被拒绝,拒绝的理由为:"+reason;
             remoteSystemService.sendNotice(company,zfiId,title,"01","01","","0",user.toString(),"", null, null);
+            //给融信发起人生成待办
+            String titleName = "【内部审核退回】融信【"+number+"】内部审批退回,请维护资料后,再次提交";
+            remoteSystemService.sendNotice(company,zfiId,titleName,"00","","01","0",user.toString(),"", "01", "/credit/financeOpenUpdate/"+zfiId);
+            //修改待办为已办
+            if(noticeList.size() > 0) {
+                //提取主键
+                List<String> idList = CommonUtil.getIdFromList(noticeList,"noticeId");
+                LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.in(SysNotice::getNoticeId,idList);
+                SysNotice notice = new SysNotice();
+                notice.setStatus("1");
+                sysNoticeService.update(notice,queryWrapper);
+            }
         }//融资企业补充资料审批拒绝
         else if("1000000003".equals(menuId)){
             LambdaQueryWrapper<ZcFinanceInf> wrapper = new LambdaQueryWrapper<>();
@@ -898,6 +942,7 @@ public class  FlowableController extends BaseController
         }
         //平台审批拒绝
         else if("1000000004".equals(menuId)){
+
             LambdaQueryWrapper<ZcFinanceInf> wrapper = new LambdaQueryWrapper<>();
             String [] arr = id.split("\\|");
             //融信id
@@ -912,6 +957,14 @@ public class  FlowableController extends BaseController
             String zfiSupplierId = inf.getZfiSupplierId();
             wrapper.eq(ZcFinanceInf::getZfiId,zfiId);
             ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
+            //先查询需要修改的待办,最后改,放在这改的话,有事务会锁表,后面生成待办就超时
+            //盖章待办改为已办
+            LambdaQueryWrapper<SysNotice> queryWrapperA = new LambdaQueryWrapper<>();
+            queryWrapperA.eq(SysNotice::getTableId,zfiId);
+            queryWrapperA.eq(SysNotice::getType,"00");
+            queryWrapperA.eq(SysNotice::getWorkType,"01");
+            queryWrapperA.eq(SysNotice::getStatus,"0");
+            List<SysNotice> noticeList =  sysNoticeService.findSysNotices(queryWrapperA);
             //审批拒绝
             if("delete".equals(state)){
                 //平台审批状态(00:审批中, 01:审批通过, 02:审批拒绝, 03:暂存)
@@ -927,7 +980,7 @@ public class  FlowableController extends BaseController
             }
             //更新融信状态
             zcFinanceInfService.update(zcFinanceInf,wrapper);
-            //待办更改为已办
+        /*    //待办更改为已办
             LambdaQueryWrapper<SysNotice> noticeLambdaQueryWrapper = new LambdaQueryWrapper<>();
             //待办
             noticeLambdaQueryWrapper.eq(SysNotice::getStatus,"0");
@@ -939,7 +992,7 @@ public class  FlowableController extends BaseController
             SysNotice notice = new SysNotice();
             //已办
             notice.setStatus("1");
-            sysNoticeService.update(notice,noticeLambdaQueryWrapper);
+            sysNoticeService.update(notice,noticeLambdaQueryWrapper);*/
             // TODO 不管什么类型都给 融资企业经办人 最终结果【拒绝】消息通知
             /*----------查询供应商企业经办人----------*/
             //查询用户与企业关系表
@@ -966,12 +1019,86 @@ public class  FlowableController extends BaseController
             remoteSystemService.sendNotice(zfiSupplierId, zfiId,title,"01","02","","0",supplierUserId.toString(),"", null, null);
 
             /**融信操作日志*/
-            if ("0".equals(inf.getZfiCreateType())) {
+            if ("0".equals(inf.getZfiCreateType())) {//供应商申请
                 financeLog.addFinanceLog(zfiId, "平台资料审核退回,请重新核对资料再次提交", null, FinanceLog.STATUS_ZERO);
-            } else if ("1".equals(inf.getZfiCreateType())) {
+                //查询供应商下的所有用户
+               LambdaQueryWrapper<SysUserCompanyRel>  userCompanyRelWrapper  = new LambdaQueryWrapper<>();
+               userCompanyRelWrapper.eq(SysUserCompanyRel::getSucrCompanyId,zfiSupplierId);
+               List<SysUserCompanyRel>  sysUserCompanyRelList = sysUserCompanyRelService.findSysUserCompanyRels(userCompanyWrapper);
+               if(sysUserCompanyRelList.size() < 1){
+                   throw new Exception("获取供应商下的用户信息失败");
+               }
+               String titleName = "【平台审核退回】融信【"+zfiNumber+"】平台审批退回,请维护资料后,再次提交";
+               //组装用户
+                String userIds = "";
+                for(int j = 0 ; j < sysUserCompanyRelList.size();j++){
+                    //最后一个
+                    if(j == sysUserCompanyRelList.size() -1){
+                        userIds += sysUserCompanyRelList.get(j).getSucrUserId();
+                    }else{
+                        userIds += sysUserCompanyRelList.get(j).getSucrUserId()+",";
+                    }
+
+                }
+                //给供应商下的所有的用户生成待办
+               remoteSystemService.sendNotice(zfiSupplierId,zfiId,titleName,"00","","01","0",userIds,"", "01", "/credit/applyCreditEdit/"+zfiId);
+
+            } else if ("1".equals(inf.getZfiCreateType())) {//核心开立
                 financeLog.addFinanceLog(zfiId, "平台资料审核退回,请重新核对资料再次提交", null, FinanceLog.STATUS_ONE);
-            } else if ("2".equals(inf.getZfiCreateType())) {
+                //查询核心企业下的所有用户
+                LambdaQueryWrapper<SysUserCompanyRel>  userCompanyRelWrapper  = new LambdaQueryWrapper<>();
+                userCompanyRelWrapper.eq(SysUserCompanyRel::getSucrCompanyId,zfiCoreId);
+                List<SysUserCompanyRel>  sysUserCompanyRelList = sysUserCompanyRelService.findSysUserCompanyRels(userCompanyWrapper);
+                if(sysUserCompanyRelList.size() < 1){
+                    throw new Exception("获取核心企业下的用户信息失败");
+                }
+                String titleName = "【平台审核退回】融信【"+zfiNumber+"】平台审批退回,请维护资料后,再次提交";
+                //组装用户
+                String userIds = "";
+                for(int j = 0 ; j < sysUserCompanyRelList.size();j++){
+                    //最后一个
+                    if(j == sysUserCompanyRelList.size() -1){
+                        userIds += sysUserCompanyRelList.get(j).getSucrUserId();
+                    }else{
+                        userIds += sysUserCompanyRelList.get(j).getSucrUserId()+",";
+                    }
+
+                }
+                //给核心企业下的所有的用户生成待办
+                remoteSystemService.sendNotice(zfiCoreId,zfiId,titleName,"00","","01","0",userIds,"", "01", "/credit/creditUpdate/"+zfiId);
+            } else if ("2".equals(inf.getZfiCreateType())) {//供应商开立
                 financeLog.addFinanceLog(zfiId, "平台审核融信资料【退回】,请编辑后,再次提交", null, FinanceLog.STATUS_ZERO);
+                //查询供应商下的所有用户
+                LambdaQueryWrapper<SysUserCompanyRel>  userCompanyRelWrapper  = new LambdaQueryWrapper<>();
+                userCompanyRelWrapper.eq(SysUserCompanyRel::getSucrCompanyId,zfiSupplierId);
+                List<SysUserCompanyRel>  sysUserCompanyRelList = sysUserCompanyRelService.findSysUserCompanyRels(userCompanyWrapper);
+                if(sysUserCompanyRelList.size() < 1){
+                    throw new Exception("获取供应商下的用户信息失败");
+                }
+                String titleName = "【平台审核退回】融信【"+zfiNumber+"】平台审批退回,请维护资料后,再次提交";
+                //组装用户
+                String userIds = "";
+                for(int j = 0 ; j < sysUserCompanyRelList.size();j++){
+                    //最后一个
+                    if(j == sysUserCompanyRelList.size() -1){
+                        userIds += sysUserCompanyRelList.get(j).getSucrUserId();
+                    }else{
+                        userIds += sysUserCompanyRelList.get(j).getSucrUserId()+",";
+                    }
+
+                }
+                //给供应商下的所有的用户生成待办
+                remoteSystemService.sendNotice(zfiSupplierId,zfiId,titleName,"00","","01","0",userIds,"", "01", "/credit/financeOpenUpdate/"+zfiId);
+            }
+            //修改待办为已办
+            if(noticeList.size() > 0) {
+                //提取主键
+                List<String> idList = CommonUtil.getIdFromList(noticeList,"noticeId");
+                LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.in(SysNotice::getNoticeId,idList);
+                SysNotice notice = new SysNotice();
+                notice.setStatus("1");
+                sysNoticeService.update(notice,queryWrapper);
             }
 
         }//融资企业签收审批拒绝
@@ -1210,4 +1337,5 @@ public class  FlowableController extends BaseController
         }
         return AjaxResult.success(resList);
     }
+
 }