wks пре 2 година
родитељ
комит
881259e664

+ 46 - 38
src/main/java/com/ydtech/modules/protocol/service/impl/TaxSourceServiceImpl.java

@@ -31,10 +31,9 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 @Service
-public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceDto> implements ITaxSourceService {
+public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSourceDto> implements ITaxSourceService {
 
     @Autowired
     PtlAgreementService ptlAgreementService;
@@ -58,18 +57,18 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
     }
 
     @Override
-    public List<PtlAgreement> getAgreementByCompanyId(String companyId,String deptId,String userId) {
+    public List<PtlAgreement> getAgreementByCompanyId(String companyId, String deptId, String userId) {
         List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
         List<String> agreementIds = new ArrayList<>();
-        for(PtlAgreementInsCompanyDto item : agreementInsCompany){
-            if(item.getId().equals(companyId)){
-                for(PtlAgreementDto agreementDto : item.getAgreement()){
+        for (PtlAgreementInsCompanyDto item : agreementInsCompany) {
+            if (item.getId().equals(companyId)) {
+                for (PtlAgreementDto agreementDto : item.getAgreement()) {
                     agreementIds.add(agreementDto.getId());
                 }
             }
         }
         QueryWrapper queryWrapper = new QueryWrapper();
-        queryWrapper.in("id",agreementIds);
+        queryWrapper.in("id", agreementIds);
         List<PtlAgreement> list = ptlAgreementService.list(queryWrapper);
         return list;
     }
@@ -78,7 +77,8 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
     @Transactional
     public boolean saveTaxSource(TaxSourceVo taxSourceVo) {
         //删除排除的信息
-        taxSourceExcludeService.remove(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getInsCompanyId,taxSourceVo.getInsCompanyId()));
+        taxSourceExcludeService.remove(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getInsCompanyId,
+                taxSourceVo.getInsCompanyId()));
         //删除税源配置信息
         baseMapper.delete(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getInsCompanyId, taxSourceVo.getInsCompanyId()));
         //组装税源数据
@@ -95,7 +95,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
             dtos.add(dto);
         });
         //组装排除的部门信息
-        for(String agreementTaxExclude : taxSourceVo.getAgreementTaxExcludeDeptList()){
+        for (String agreementTaxExclude : taxSourceVo.getAgreementTaxExcludeDeptList()) {
             TaxSourceExcludeDto dto = new TaxSourceExcludeDto();
             dto.setId(IdGenerate.nextId());
             dto.setType(Integer.parseInt(TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
@@ -137,7 +137,8 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
     public TaxSourceVo getTaxSource(String companyId) {
         TaxSourceVo taxSourceVo = new TaxSourceVo();
         //税源信息
-        List<TaxSourceDto> taxSourceDto = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getInsCompanyId, companyId));
+        List<TaxSourceDto> taxSourceDto = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getInsCompanyId,
+                companyId));
         //排除的部门信息
         List<TaxSourceExcludeDto> taxSourceExcludeDepts = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>()
                 .eq(TaxSourceExcludeDto::getInsCompanyId, companyId)
@@ -189,7 +190,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
         return agreementCompany;
     }
 
-    public PtlAgreementInsCompanyDto getAgreementInsCompany(String deptId, String userId,String companyId) {
+    public PtlAgreementInsCompanyDto getAgreementInsCompany(String deptId, String userId, String companyId) {
         // 领导标志
         SysUserRole userRole = sysUserRoleService.selectByUserId(userId);
 
@@ -197,7 +198,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
             deptId = null;
         }
 
-        PtlAgreementInsCompanyDto agreementCompany = ptlAgreementService.getAgreementCompany(deptId,companyId);
+        PtlAgreementInsCompanyDto agreementCompany = ptlAgreementService.getAgreementCompany(deptId, companyId);
         return agreementCompany;
     }
 
@@ -207,17 +208,20 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
 //        List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
 //        if(license != null && volume != null) {
 //            //排除的部门信息
-//            List<TaxSourceExcludeDto> excludeDepts = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getExcludeInfo, deptId)
+//            List<TaxSourceExcludeDto> excludeDepts = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq
+//            (TaxSourceExcludeDto::getExcludeInfo, deptId)
 //                    .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
 //
 //            agreementInsCompany.forEach(item ->
 //                    excludeDepts.stream()
-//                            .filter(taxSourceDto -> item.getId().equals(taxSourceDto.getInsCompanyId()) && taxSourceDto.getExcludeInfo().equals(deptId))
+//                            .filter(taxSourceDto -> item.getId().equals(taxSourceDto.getInsCompanyId()) && taxSourceDto.getExcludeInfo
+//                            ().equals(deptId))
 //                            .findFirst()
 //                            .ifPresent(taxSourceDto -> item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START))
 //            );
 //            //查找排除的车牌号
-//            List<TaxSourceExcludeDto> licenseExclude = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getExcludeInfo, license)
+//            List<TaxSourceExcludeDto> licenseExclude = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq
+//            (TaxSourceExcludeDto::getExcludeInfo, license)
 //                    .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_LICENSE));
 //            agreementInsCompany.forEach(item -> {
 //                licenseExclude.forEach(taxSourceDto -> {
@@ -248,7 +252,8 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
 //            //判断汽车排量是否大于1升
 //            if (Float.parseFloat(volume) >= 1) {
 //                //查找是否配置税源
-//                List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
+//                List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq
+//                (TaxSourceDto::getIsTaxSource, "1"));
 //                //设置税源参数
 //                agreementInsCompany.forEach(item -> {
 //                    if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
@@ -272,6 +277,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
 
     /**
      * 返回是否是税源
+     *
      * @param deptId
      * @param userId
      * @return
@@ -282,7 +288,8 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
         List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
 
         //查找是否配置税源
-        List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
+        List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource,
+                "1"));
         //设置税源参数
         agreementInsCompany.forEach(item -> {
             if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
@@ -304,6 +311,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
 
     /**
      * 根据税源获取协议id
+     *
      * @param deptId
      * @param userId
      * @param companyId
@@ -315,8 +323,16 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
     public String getAgreementId(String deptId, String userId, String companyId, String license, String volume) {
         // 车牌前两位
         String firstTwoPlates = license.substring(0, 2);
-
         String resultId = "";
+
+        //查找配置的默认项
+        TaxSourceDto taxSourceDefaultDto = baseMapper.selectOne(new LambdaQueryWrapper<TaxSourceDto>()
+                .eq(TaxSourceDto::getInsCompanyId, companyId)
+                .eq(TaxSourceDto::getLicense, firstTwoPlates));
+        if (taxSourceDefaultDto != null) {
+            resultId = taxSourceDefaultDto.getAgreementId();
+        }
+
         boolean isExclude = false;
         //排除的部门信息
         List<TaxSourceExcludeDto> excludeDepts = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>()
@@ -330,34 +346,26 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
         }
 
         //查找排除的车牌号
-        List<TaxSourceExcludeDto> licenseExclude = taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getExcludeInfo, license)
-                .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_LICENSE));
+        List<TaxSourceExcludeDto> licenseExclude =
+                taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getExcludeInfo, license)
+                        .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_LICENSE));
 
         //车牌排除
         if (licenseExclude.stream().anyMatch(taxSourceDto -> taxSourceDto.getExcludeInfo().contains(firstTwoPlates))) {
             isExclude = true;
         }
 
-        if (!isExclude) {
-            //判断排量 如果大于一升 走税源 否则走默认配置
-            if (Float.parseFloat(volume) >= 1) {
-                //查找是否配置税源
-                TaxSourceDto taxSourceDtos = baseMapper.selectOne(new LambdaQueryWrapper<TaxSourceDto>()
-                        .eq(TaxSourceDto::getIsTaxSource, "1")
-                        .eq(TaxSourceDto::getInsCompanyId, companyId));
-                if (taxSourceDtos != null) {
-                    resultId = taxSourceDtos.getAgreementId();
-                }
-            } else {
-                //查找配置的默认项
-                TaxSourceDto taxSourceDefaultDto = baseMapper.selectOne(new LambdaQueryWrapper<TaxSourceDto>()
-                        .eq(TaxSourceDto::getInsCompanyId, companyId)
-                        .eq(TaxSourceDto::getLicense, firstTwoPlates));
-                if (taxSourceDefaultDto != null) {
-                    resultId = taxSourceDefaultDto.getAgreementId();
-                }
+        if (!isExclude && (Float.parseFloat(volume) >= 1)) {
+            //查找是否配置税源
+            TaxSourceDto taxSourceDtos = baseMapper.selectOne(new LambdaQueryWrapper<TaxSourceDto>()
+                    .eq(TaxSourceDto::getIsTaxSource, "1")
+                    .eq(TaxSourceDto::getInsCompanyId, companyId));
+            if (taxSourceDtos != null) {
+                resultId = taxSourceDtos.getAgreementId();
             }
         }
+
+
         return resultId;
     }