From bd2d3096021fc03aecea16fccd2463ea424066a4 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 24 一月 2024 18:12:48 +0800
Subject: [PATCH] 111

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |  124 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 1 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
index 0203ee3..9264c44 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -51,6 +51,9 @@
     private InsuranceApplyMapper insuranceApplyMapper;
 
     @Autowired
+    private CompanySolutionMapper companySolutionMapper;
+
+    @Autowired
     private ApplyChangeJoinMapper applyChangeJoinMapper;
 
     @Autowired
@@ -348,7 +351,7 @@
             }
         }
         if(addList!=null && addList.size()>0){
-            applyChagneDetailJoinMapper.insertBatchSomeColumn(addList);
+            applyDetailJoinMapper.insertBatchSomeColumn(addList);
         }
         if(totalFee.compareTo(new BigDecimal(0)) != 0){
             //濡傛灉淇濆崟閲戦鍙戠敓缂栫爜锛屾洿鏂版�讳繚鍗曢噾棰�
@@ -453,6 +456,15 @@
         if(Objects.isNull(solutions)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
         }
+        CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
+                .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
+                .eq(CompanySolution::getSolutionBaseId,solutions.getId())
+                .eq(CompanySolution::getIsdeleted,Constants.ZERO)
+                .last(" limit 1 ")
+        );
+        if(Objects.isNull(companySolution)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌浼佷笟鍒嗛厤淇濋櫓鏂规淇℃伅");
+        }
         //鐢宠鏃堕棿蹇呴』澶勪簬淇濆崟鐨勬椂闂磋寖鍥村唴
         if (!(DateUtil.compareDate(applyChange.getValidTime(), insuranceApply.getStartTime()) >= Constants.ZERO
                 && DateUtil.compareDate(insuranceApply.getEndTime(), applyChange.getValidTime()) >= Constants.ZERO)) {
@@ -485,12 +497,18 @@
         //鍔犱繚鏁版嵁
         List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
         if (CollectionUtils.isNotEmpty(addDetailList)) {
+           if(companySolution.getCanAdd().equals(Constants.ZERO)){
+               throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
+           }
             this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo);
         }
 
         //鍑忎繚鏁版嵁
         List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
         if (CollectionUtils.isNotEmpty(delDetailList)) {
+            if(companySolution.getCanReduce().equals(Constants.ZERO)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
+            }
             this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
         }
         //鎹㈠巶涓氬姟
@@ -910,8 +928,112 @@
         ApplyChange applyChange =  applyChangeJoinMapper.selectOne(queryWrapper);
         return applyChange;
     }
+    /**
+     * 瀵煎嚭鎹㈠巶鐢宠琛�
+     * @param param
+     * @return
+     */
+    @Override
+    public  ApplyChange  exportChangeUnitExcel(ApplyChange param){
+        ApplyChange model = findJoinDetail(param);
+        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+
+        //鏌ヨ鏄庣粏
+        List<ApplyChagneDetail> detailList =findJoinChangeDetailList(model);
+        model.setChangeDetailList(detailList!=null?detailList:new ArrayList<>());
+        model.setChangeNum(model.getChangeDetailList().size());
+        return model;
+    }
 
 
+    /**
+     * 瀵煎嚭鍔犲噺淇濈敵璇疯〃
+     * @param param
+     * @return
+     */
+    @Override
+    public  ApplyChange  exportJiajianBaoExcel(ApplyChange param){
+
+        ApplyChange model = findJoinDetail(param);
+        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+
+        //鏌ヨ鏄庣粏
+        List<ApplyChagneDetail> detailList =findJoinDetailList(model);
+        model.setAddDetailList(new ArrayList<>());
+        model.setDelDetailList(new ArrayList<>());
+        if(detailList!=null){
+            for(ApplyChagneDetail ad :detailList){
+                if(Constants.equalsInteger(ad.getType(),Constants.ZERO)){
+                    model.getAddDetailList().add(ad);
+                }else{
+                    model.getDelDetailList().add(ad);
+                }
+            }
+        }
+        model.setDelNum(model.getDelDetailList().size());
+        model.setAddNum(model.getAddDetailList().size());
+        return model;
+    }
+    private ApplyChange findJoinDetail(ApplyChange param) {
+        MPJLambdaWrapper wrapper=  new MPJLambdaWrapper<ApplyChange>()
+                .selectAll(ApplyChange.class)
+                .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
+                .selectAs(Company::getName,ApplyChange::getCompanyName)
+                .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
+                .selectAs(InsuranceApply::getStartTime,ApplyChange::getStartTime)
+                .selectAs(InsuranceApply::getStartTime,ApplyChange::getEndTime)
+                .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
+                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
+                .leftJoin(Company.class,Company::getId,ApplyChange::getCompanyId)
+                .eq(ApplyChange::getId,param.getId())
+                .last("limit 1");
+
+        ApplyChange model = applyChangeJoinMapper.selectJoinOne(ApplyChange.class,wrapper);
+        return  model;
+    }
+    private List<ApplyChagneDetail> findJoinDetailList(ApplyChange model) {
+        MPJLambdaWrapper wrapper1=  new MPJLambdaWrapper<ApplyChagneDetail>()
+                .selectAll(ApplyChagneDetail.class)
+                .selectAs(Member::getName,ApplyChagneDetail::getMemberName)
+                .selectAs(Member::getSex,ApplyChagneDetail::getSex)
+                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo)
+                .selectAs(Worktype::getName,ApplyChagneDetail::getWorkTypeName)
+                .selectAs(DispatchUnit::getName,ApplyChagneDetail::getDuName)
+                .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
+                .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getDuId)
+                .leftJoin(Member.class,Member::getId,ApplyChagneDetail::getMemberId)
+                .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO)
+                .eq(ApplyChagneDetail::getApplyChangeId,model.getId());
+        //鏌ヨ鏄庣粏
+        List<ApplyChagneDetail> detailList =applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,wrapper1);
+        return  detailList;
+    }
+    private List<ApplyChagneDetail> findJoinChangeDetailList(ApplyChange model) {
+        MPJLambdaWrapper wrapper1=  new MPJLambdaWrapper<ApplyChagneDetail>()
+                .selectAll(ApplyChagneDetail.class)
+                .selectAs(Member::getName,ApplyChagneDetail::getMemberName)
+                .selectAs(Member::getSex,ApplyChagneDetail::getSex)
+                .select("t1.name as worktypeName")
+                .select("t2.name as duName")
+                .select("t3.name as oldWorktypeName")
+                .select("t4.name as oldDuName")
+                .selectAs(Member::getSex,ApplyChagneDetail::getSex)
+                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo)
+                .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
+                .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getDuId)
+                .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getOldWorktypeId)
+                .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getOldDuId)
+                .leftJoin(Member.class,Member::getId,ApplyChagneDetail::getMemberId)
+                .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO)
+                .eq(ApplyChagneDetail::getApplyChangeId,model.getId());
+        //鏌ヨ鏄庣粏
+        List<ApplyChagneDetail> detailList =applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,wrapper1);
+        return  detailList;
+    }
 
 
 }

--
Gitblit v1.9.3