|
|
@@ -5,16 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
import com.ydtech.constants.sys.SystemConstant;
|
|
|
-import com.ydtech.core.page.HttpResult;
|
|
|
-import com.ydtech.core.page.PageRequest;
|
|
|
import com.ydtech.modules.admin.constants.RoleConstants;
|
|
|
import com.ydtech.modules.admin.model.SysUserRole;
|
|
|
import com.ydtech.modules.admin.service.SysUserRoleService;
|
|
|
import com.ydtech.modules.esm.model.EsmInsCompany;
|
|
|
import com.ydtech.modules.esm.service.EsmInsCompanyService;
|
|
|
-import com.ydtech.modules.order.entity.InsOrders;
|
|
|
import com.ydtech.modules.order.service.InsOrdersService;
|
|
|
import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
|
|
|
import com.ydtech.modules.protocol.dao.TaxSourceMapper;
|
|
|
@@ -35,7 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
@Service
|
|
|
public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceDto> implements ITaxSourceService {
|
|
|
@@ -193,73 +189,175 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper,TaxSourceD
|
|
|
return agreementCompany;
|
|
|
}
|
|
|
|
|
|
+ public PtlAgreementInsCompanyDto getAgreementInsCompany(String deptId, String userId,String companyId) {
|
|
|
+ // 领导标志
|
|
|
+ SysUserRole userRole = sysUserRoleService.selectByUserId(userId);
|
|
|
+
|
|
|
+ if (Arrays.asList(SystemConstant.getSysRoleTeamLeader()).contains(userRole.getRoleId().toString()) && !RoleConstants.R21.getCode().equals(userRole.getRoleId().toString())) { //团队长可查询下面所有人员订单
|
|
|
+ deptId = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ PtlAgreementInsCompanyDto agreementCompany = ptlAgreementService.getAgreementCompany(deptId,companyId);
|
|
|
+ return agreementCompany;
|
|
|
+ }
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public List<PtlAgreementInsCompanyDto> getAgreementInsCompany(String deptId, String userId, String license,String volume) {
|
|
|
+// //查出所有协议
|
|
|
+// List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
|
|
|
+// if(license != null && volume != null) {
|
|
|
+// //排除的部门信息
|
|
|
+// 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))
|
|
|
+// .findFirst()
|
|
|
+// .ifPresent(taxSourceDto -> item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START))
|
|
|
+// );
|
|
|
+// //查找排除的车牌号
|
|
|
+// 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 -> {
|
|
|
+// if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
|
|
|
+// if (license.equals(taxSourceDto.getExcludeInfo())) {
|
|
|
+// //排除
|
|
|
+// item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// });
|
|
|
+//
|
|
|
+// //查找配置的默认项
|
|
|
+// List<TaxSourceDto> taxSourceDefaultDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>()
|
|
|
+// .eq(TaxSourceDto::getLicense, license));
|
|
|
+// //设置协议的默认项
|
|
|
+// agreementInsCompany.forEach(item -> {
|
|
|
+// taxSourceDefaultDtos.forEach(taxSourceDto -> {
|
|
|
+// if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
|
|
|
+// item.getAgreement().forEach(agreement -> {
|
|
|
+// if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
|
|
|
+// agreement.setIsAllocation(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// });
|
|
|
+// });
|
|
|
+// //判断汽车排量是否大于1升
|
|
|
+// if (Float.parseFloat(volume) >= 1) {
|
|
|
+// //查找是否配置税源
|
|
|
+// List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
|
|
|
+// //设置税源参数
|
|
|
+// agreementInsCompany.forEach(item -> {
|
|
|
+// if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
|
|
|
+// taxSourceDtos.forEach(taxSourceDto -> {
|
|
|
+// if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
|
|
|
+// item.getAgreement().forEach(agreement -> {
|
|
|
+// if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
|
|
|
+// agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
+// item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
+// item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return agreementInsCompany;
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回是否是税源
|
|
|
+ * @param deptId
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<PtlAgreementInsCompanyDto> getAgreementInsCompany(String deptId, String userId, String license,String volume) {
|
|
|
+ public List<PtlAgreementInsCompanyDto> getAllAgreement(String deptId, String userId) {
|
|
|
//查出所有协议
|
|
|
List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
|
|
|
+
|
|
|
+ //查找是否配置税源
|
|
|
+ List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
|
|
|
+ //设置税源参数
|
|
|
+ agreementInsCompany.forEach(item -> {
|
|
|
+ if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
|
|
|
+ taxSourceDtos.forEach(taxSourceDto -> {
|
|
|
+ if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
|
|
|
+ item.getAgreement().forEach(agreement -> {
|
|
|
+ if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
|
|
|
+ agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
+ item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
+ item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return agreementInsCompany;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据税源获取协议id
|
|
|
+ * @param deptId
|
|
|
+ * @param userId
|
|
|
+ * @param companyId
|
|
|
+ * @param license
|
|
|
+ * @param volume
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getAgreementId(String deptId, String userId, String companyId, String license, String volume) {
|
|
|
+ String resultId = "";
|
|
|
+ boolean isExclude = false;
|
|
|
//排除的部门信息
|
|
|
- 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::getInsCompanyId, companyId)
|
|
|
.eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
|
|
|
|
|
|
- agreementInsCompany.forEach(item ->
|
|
|
- excludeDepts.stream()
|
|
|
- .filter(taxSourceDto -> item.getId().equals(taxSourceDto.getInsCompanyId()) && taxSourceDto.getExcludeInfo().equals(deptId))
|
|
|
- .findFirst()
|
|
|
- .ifPresent(taxSourceDto -> item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START))
|
|
|
- );
|
|
|
+ //部门排除
|
|
|
+ if (excludeDepts.stream()
|
|
|
+ .filter(taxSourceDto -> taxSourceDto.getExcludeInfo().equals(deptId)).count() > 0) {
|
|
|
+ isExclude = true;
|
|
|
+ }
|
|
|
+
|
|
|
//查找排除的车牌号
|
|
|
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 -> {
|
|
|
- if(item.getId().equals(taxSourceDto.getInsCompanyId())){
|
|
|
- if(license.equals(taxSourceDto.getExcludeInfo()))
|
|
|
- {
|
|
|
- //排除
|
|
|
- item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- //查找配置的默认项
|
|
|
- List<TaxSourceDto> taxSourceDefaultDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>()
|
|
|
- .eq(TaxSourceDto::getLicense, license));
|
|
|
- //设置协议的默认项
|
|
|
- agreementInsCompany.forEach(item->{
|
|
|
- taxSourceDefaultDtos.forEach(taxSourceDto -> {
|
|
|
- if(item.getId().equals(taxSourceDto.getInsCompanyId())){
|
|
|
- item.getAgreement().forEach(agreement -> {
|
|
|
- if(agreement.getId().equals(taxSourceDto.getAgreementId())){
|
|
|
- agreement.setIsAllocation(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
- }
|
|
|
- });
|
|
|
+ //车牌排除
|
|
|
+ if (licenseExclude.stream()
|
|
|
+ .filter(taxSourceDto -> taxSourceDto.getExcludeInfo().equals(license)).count() > 0) {
|
|
|
+ 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();
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- //判断汽车排量是否大于1升
|
|
|
- if(Float.parseFloat(volume) >= 1) {
|
|
|
- //查找是否配置税源
|
|
|
- List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
|
|
|
- //设置税源参数
|
|
|
- agreementInsCompany.forEach(item -> {
|
|
|
- if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
|
|
|
- taxSourceDtos.forEach(taxSourceDto -> {
|
|
|
- if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
|
|
|
- item.getAgreement().forEach(agreement -> {
|
|
|
- if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
|
|
|
- agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
- item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
|
|
|
- item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ //查找配置的默认项
|
|
|
+ TaxSourceDto taxSourceDefaultDto = baseMapper.selectOne(new LambdaQueryWrapper<TaxSourceDto>()
|
|
|
+ .eq(TaxSourceDto::getInsCompanyId, companyId)
|
|
|
+ .eq(TaxSourceDto::getLicense, license));
|
|
|
+ if (taxSourceDefaultDto != null) {
|
|
|
+ resultId = taxSourceDefaultDto.getAgreementId();
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
- return agreementInsCompany;
|
|
|
+ return resultId;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|