he2802 1 gadu atpakaļ
vecāks
revīzija
f14f0a48be

+ 0 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/covenant/BsCovenantController.java

@@ -163,8 +163,6 @@ public class BsCovenantController extends BaseController {
     }
 
 
-
-
     /**
      * 修改企业协议
      */

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/covenant/bo/BsCovenantAddBo.java

@@ -131,4 +131,6 @@ public class BsCovenantAddBo {
     /** 业务员姓名 */
     @ApiModelProperty("业务员姓名")
     private String saleName;
+
+    private Long checkId;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/covenant/bo/BsCovenantEditBo.java

@@ -153,4 +153,8 @@ public class BsCovenantEditBo {
     private String saleName;
 
     private String paths;
+
+
+    @ApiModelProperty("操作端 1云学堂  2企业系统  3业务系统 4总平台 ")
+    private Long operateApp;
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/covenant/domain/BsCovenant.java

@@ -166,4 +166,10 @@ public class BsCovenant implements Serializable {
     private String saleNum;
     /** 业务员姓名 */
     private String saleName;
+
+    private Long checkApp;
+
+    private Long checkId;
+
+    private Long uploadApp;
 }

+ 136 - 19
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/covenant/service/impl/BsCovenantServiceImpl.java

@@ -314,17 +314,24 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
         add.setYiCompanyContract(yiSysTenant.getLinkMan());
         add.setYiCompanyPhone(yiSysTenant.getCompanyPh());
         add.setStatus(1);
-        int insert = this.baseMapper.insert(add);
-        BsCovenant newBsCovenant = this.getOne(new LambdaQueryWrapper<BsCovenant>().eq(BsCovenant::getCovenantNum, bo.getCovenantNum()).eq(BsCovenant::getStatus, 1));
+    //    BsCovenant newBsCovenant = this.getOne(new LambdaQueryWrapper<BsCovenant>().eq(BsCovenant::getCovenantNum, bo.getCovenantNum()).eq(BsCovenant::getStatus, 1));
         //写入协议审核流程
         SysTenant sysTenant = iSysTenantService.getById(ServletUtils.getRequest().getHeader("TenantId"));
+        if(Validator.isEmpty(sysTenant)){
+            throw new CustomException("机构数据错误");
+        }
+
         if (ObjectUtils.isNotNull(sysTenant)) {
             BsCovenantCheckAddBo bsCovenantCheckAddBo = new BsCovenantCheckAddBo();
-            bsCovenantCheckAddBo.setCovenantId(newBsCovenant.getCovenantId());
-            bsCovenantCheckAddBo.setCompanyId(Long.valueOf(companyId));
             if (!sysTenant.getAppList().isEmpty()) {
                 List<String> list1 = Arrays.asList(sysTenant.getAppList().split(","));
                 List<Long> longList = list1.stream().map(Long::parseLong).collect(Collectors.toList());
+                if(Validator.isEmpty(longList)||longList.size()==0){
+                    throw new CustomException("应用列表错误");
+                }
+                add.setCheckApp(getInitCheckStatus(add.getFormApp(),longList,add.getCheckId()));
+                add.setUploadApp(getInitUploadStatus(add.getFormApp(), longList, add.getCheckId()));
+                this.baseMapper.insert(add);
                 longList.forEach(num -> {
                     bsCovenantCheckAddBo.setAppId(num);
                     if (num == 1L) {
@@ -337,6 +344,8 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
                     } else if (num == 4L) {
                         bsCovenantCheckAddBo.setSort(3);
                     }
+                    bsCovenantCheckAddBo.setCovenantId(add.getCovenantId());
+                    bsCovenantCheckAddBo.setCompanyId(Long.valueOf(companyId));
                     bsCovenantCheckAddBo.setStatus(1);
                     bsCovenantCheckAddBo.setCreateTime(DateUtils.getNowTime());
                     bsCovenantCheckAddBo.setUpdateTime(DateUtils.getNowTime());
@@ -364,7 +373,7 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
                             CourseBusiness courseBusiness = iCourseBusinessService.getOne(new LambdaQueryWrapper<CourseBusiness>().eq(CourseBusiness::getId, bsCovenantBusinessAddBo.getBusinessId()).eq(CourseBusiness::getStatus, 1));
                             bsCovenantBusinessAddBo.setProjectId(Long.valueOf(courseBusiness.getProjectId()));
                             bsCovenantBusinessAddBo.setBusinessId(courseBusiness.getId());
-                            bsCovenantBusinessAddBo.setCovenantId(newBsCovenant.getCovenantId());
+                            bsCovenantBusinessAddBo.setCovenantId(add.getCovenantId());
                             bsCovenantBusinessAddBo.setCreateTime(DateUtils.getNowTime());
                             bsCovenantBusinessAddBo.setUpdateTime(DateUtils.getNowTime());
                             bsCovenantBusinessAddBo.setStatus(1);
@@ -376,7 +385,7 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
                                         .eq(BsCovenantBusiness::getStatus, 1));
                                 //写入协议业务类型有关商品
                                 bsCovenantBusinessAddBo.getBsCovenantGoodsVos().forEach(bsCovenantGoodsAddBo -> {
-                                    bsCovenantGoodsAddBo.setCovenantId(newBsCovenant.getCovenantId());
+                                    bsCovenantGoodsAddBo.setCovenantId(add.getCovenantId());
                                     bsCovenantGoodsAddBo.setCovenantBusinessId(bsCovenantBusiness.getCovenantBusinessId());
                                     bsCovenantGoodsAddBo.setCreateTime(DateUtils.getNowTime());
                                     bsCovenantGoodsAddBo.setUpdateTime(DateUtils.getNowTime());
@@ -394,7 +403,7 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
         bo.getBsCovenantBusinessVos().forEach(bsCovenantBusinessAddBo -> {
             CourseBusiness courseBusiness = iCourseBusinessService.getOne(new LambdaQueryWrapper<CourseBusiness>().eq(CourseBusiness::getId, bsCovenantBusinessAddBo.getBusinessId()).eq(CourseBusiness::getStatus, 1));
             bsCovenantBusinessAddBo.setProjectId(Long.valueOf(courseBusiness.getProjectId()));
-            bsCovenantBusinessAddBo.setCovenantId(newBsCovenant.getCovenantId());
+            bsCovenantBusinessAddBo.setCovenantId(add.getCovenantId());
             bsCovenantBusinessAddBo.setBusinessId(courseBusiness.getId());
             bsCovenantBusinessAddBo.setCreateTime(DateUtils.getNowTime());
             bsCovenantBusinessAddBo.setUpdateTime(DateUtils.getNowTime());
@@ -403,7 +412,7 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
             if (!bsCovenantBusinessAddBo.getBsCovenantGoodsVos().isEmpty()) {
                 //写入协议业务类型有关商品
                 bsCovenantBusinessAddBo.getBsCovenantGoodsVos().forEach(bsCovenantGoodsAddBo -> {
-                    bsCovenantGoodsAddBo.setCovenantId(newBsCovenant.getCovenantId());
+                    bsCovenantGoodsAddBo.setCovenantId(add.getCovenantId());
                     bsCovenantGoodsAddBo.setCovenantBusinessId(covenantBusinessId);
                     bsCovenantGoodsAddBo.setCreateTime(DateUtils.getNowTime());
                     bsCovenantGoodsAddBo.setUpdateTime(DateUtils.getNowTime());
@@ -412,13 +421,113 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
                 });
             }
         });
-        if (insert == 1) {
+        if (add.getCovenantId() >0) {
             return true;
         } else {
             return false;
         }
     }
 
+    private Long getInitCheckStatus(Long formApp,List<Long> appList,Long userId){
+        if(formApp==2L){
+            if(appList.size()==2){
+                return 1L;
+            }
+            else if(appList.contains(4L)&&appList.size()==3){
+                return 4L;
+            }
+            else if(appList.contains(3L)&&appList.size()==3){
+                return 3L;
+            }
+            else if(appList.size()==4){
+                return 3L;
+            }
+        }
+        else if(formApp==1L){
+            if(appList.size()==2){
+                return 1L;
+            }
+            else if(appList.contains(4L)&&appList.size()==3){
+                return 4L;
+            }
+            else if(appList.contains(3L)&&appList.size()==3){
+                return 3L;
+            }
+            else if(appList.size()==4){
+                return 3L;
+            }
+        }
+        if(formApp==3L){
+            if(appList.contains(3L)&&appList.size()==3){
+                if(userId==0){
+                    return 3L;
+                }
+                if(userId==1){
+                    return 1L;
+                }
+            }
+            else if(appList.size()==4){
+                if(userId==0){
+                    return 3L;
+                }
+                if(userId==1){
+                    return 4L;
+                }
+            }
+        }
+        if(formApp==4L){
+            if(appList.contains(4L)&&appList.size()==3){
+                return 4L;
+            }
+        }
+        return 0L;
+    }
+
+    private Long getInitUploadStatus(Long formApp,List<Long> appList,Long userId){
+        if(formApp==2L){
+            if(appList.size()==2){
+                return 1L;
+            }
+            else if(appList.contains(4L)&&appList.size()==3){
+                return 4L;
+            }
+            else if(appList.contains(3L)&&appList.size()==3){
+                return 1L;
+            }
+            else if(appList.size()==4){
+                return 4L;
+            }
+        }
+        else if(formApp==1L){
+            if(appList.size()==2){
+                return 1L;
+            }
+            else if(appList.contains(4L)&&appList.size()==3){
+                return 4L;
+            }
+            else if(appList.contains(3L)&&appList.size()==3){
+                return 1L;
+            }
+            else if(appList.size()==4){
+                return 4L;
+            }
+        }
+        else if(formApp==3L){
+            if(appList.contains(3L)&&appList.size()==3){
+                return 1L;
+            }
+            else if(appList.size()==4){
+                return 4L;
+            }
+        }
+        if(formApp==4L){
+            if(appList.contains(4L)&&appList.size()==3){
+                return 4L;
+            }
+        }
+        return 0L;
+    }
+
     @Override
     @Transactional
     public Boolean insertYXTByAddBo(BsCovenantAddBo bo) {
@@ -454,16 +563,21 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
         }
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
-        this.baseMapper.insert(add);
+
         //写入协议审核流程
         SysTenant sysTenant = iSysTenantService.getById(ServletUtils.getRequest().getHeader("TenantId"));
         if (ObjectUtils.isNotNull(sysTenant)) {
             BsCovenantCheckAddBo bsCovenantCheckAddBo = new BsCovenantCheckAddBo();
-            bsCovenantCheckAddBo.setCovenantId(add.getCovenantId());
             bsCovenantCheckAddBo.setCompanyId(bo.getCompanyId());
             if (!sysTenant.getAppList().isEmpty()) {
                 List<String> list1 = Arrays.asList(sysTenant.getAppList().split(","));
                 List<Long> longList = list1.stream().map(Long::parseLong).collect(Collectors.toList());
+                if(Validator.isEmpty(longList)||longList.size()==0){
+                    throw new CustomException("应用列表错误");
+                }
+                add.setCheckApp(getInitCheckStatus(add.getFormApp(),longList,add.getCheckId()));
+                add.setUploadApp(getInitUploadStatus(add.getFormApp(), longList, add.getCheckId()));
+                this.baseMapper.insert(add);
                 longList.forEach(num -> {
                     bsCovenantCheckAddBo.setAppId(num);
                     if (num == 1L) {
@@ -476,6 +590,7 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
                         bsCovenantCheckAddBo.setCurrentStatus(1);
                         bsCovenantCheckAddBo.setSort(3);
                     }
+                    bsCovenantCheckAddBo.setCovenantId(add.getCovenantId());
                     bsCovenantCheckAddBo.setStatus(1);
                     bsCovenantCheckAddBo.setCreateTime(DateUtils.getNowTime());
                     bsCovenantCheckAddBo.setUpdateTime(DateUtils.getNowTime());
@@ -595,9 +710,15 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
             throw new CustomException("请选择协议");
         } else {
             BsCovenantVo bsCovenantVo = queryById(bo.getCovenantId());
-            if (bsCovenantVo.getStatus() != 4) {
+            if(Validator.isEmpty(bo.getOperateApp())){
+                throw new CustomException("缺失操作平台参数");
+            }
+            if (bo.getOperateApp()==bsCovenantVo.getFormApp()&&bsCovenantVo.getStatus() != 4) {
                 throw new CustomException("当前协议未处于审核不通过状态");
-            } else {
+            }
+            else if (bo.getOperateApp()==bsCovenantVo.getCheckApp()&&bsCovenantVo.getStatus() != 1) {
+                throw new CustomException("当前协议未处于待审核状态");
+            }else {
                 BsCovenant update = BeanUtil.toBean(bo, BsCovenant.class);
                 update.setUpdateTime(DateUtils.getNowTime());
                 this.updateById(update);
@@ -668,17 +789,13 @@ public class BsCovenantServiceImpl extends ServiceImpl<BsCovenantMapper, BsCoven
                     covenantBusiness.setBusinessId(courseBusiness.getId());
                     covenantBusiness.setCreateTime(DateUtils.getNowTime());
                     covenantBusiness.setUpdateTime(DateUtils.getNowTime());
-                    iBsCovenantBusinessService.insertByAddBo(covenantBusiness);
+                    Long covenantBusinessId = iBsCovenantBusinessService.insertByAddBo(covenantBusiness);
                     if (!bsCovenantBusinessVo.getBsCovenantGoodsVos().isEmpty()) {
-                        BsCovenantBusiness bsCovenantBusiness = iBsCovenantBusinessService.getOne(new LambdaQueryWrapper<BsCovenantBusiness>().eq(BsCovenantBusiness::getBusinessId, covenantBusiness.getBusinessId())
-                                .eq(BsCovenantBusiness::getEducationTypeId, covenantBusiness.getEducationTypeId())
-                                .eq(BsCovenantBusiness::getProjectId, covenantBusiness.getProjectId())
-                                .eq(BsCovenantBusiness::getStatus, 1));
                         //写入协议业务类型有关商品
                         bsCovenantBusinessVo.getBsCovenantGoodsVos().forEach(bsCovenantGoodsVo -> {
                             BsCovenantGoodsAddBo covenantGoodsAddBo = BeanUtil.toBean(bsCovenantGoodsVo, BsCovenantGoodsAddBo.class);
                             covenantGoodsAddBo.setCovenantId(bo.getCovenantId());
-                            covenantGoodsAddBo.setCovenantBusinessId(bsCovenantBusiness.getCovenantBusinessId());
+                            covenantGoodsAddBo.setCovenantBusinessId(covenantBusinessId);
                             covenantGoodsAddBo.setCreateTime(DateUtils.getNowTime());
                             covenantGoodsAddBo.setUpdateTime(DateUtils.getNowTime());
                             iBsCovenantGoodsService.insertByAddBo(covenantGoodsAddBo);

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/covenant/vo/BsCovenantVo.java

@@ -178,4 +178,8 @@ public class BsCovenantVo {
 	@ApiModelProperty("业务员姓名")
 	@Excel(name = "业务员姓名")
 	private String saleName;
+
+	private Long checkApp;
+
+	private Long checkId;
 }

+ 4 - 4
zhongzheng-system/src/main/resources/mapper/modules/covenant/BsCovenantMapper.xml

@@ -90,24 +90,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         and bc.covenant_id=#{covenantId}
     </if>
     <if test="searchKey !=null and searchKey !=''">
-        and bc.jia_company_name=#{searchKey} or bc.covenant_num=#{searchKey} or bc.sale_id=#{searchKey} or bc.sale_name=#{searchKey} or bc.sale_num=#{searchKey}
+        and ((select  count(*) from bs_company c where  c.company_name  like concat('%', #{searchKey}, '%') and (c.company_id = bc.company_id or c.sale_company_id = bc.company_id))>0 or bc.covenant_num=#{searchKey} or bc.sale_id=#{searchKey} or bc.sale_name=#{searchKey} or bc.sale_num=#{searchKey})
     </if>
     <if test="listType == 2">
         and bc.stop_status!=0
     </if>
     <if test="listType ==3">
-        and bc.status!=3 and bc.status!=5 and bc.status!=6 and bc.status!=7
+        and bc.status!=3 and bc.status!=5 and bc.status!=6 and bc.status!=7 and bc.check_app=#{formApp}
     </if>
     <if test="listType == 4">
         and bc.stop_status!=0  and bc.stop_status!=4 and bc.stop_status!=5
     </if>
     <if test="listType ==5">
-        and  bc.status in (2,5,6,7)
+        and  bc.status in (2,5,6,7) and bc.upload_app=#{formApp}
     </if>
     <if test="userId != null and userId != ''">
         and bc.user_id=#{userId}
     </if>
-    <if test="formApp != null and formApp != ''">
+    <if test="formApp != null and listType != 3 and listType != 5">
         and bc.form_app=#{formApp}
     </if>
     <if test="covenantNum != null and covenantNum != ''">