|
@@ -79,6 +79,7 @@ import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
@@ -87,6 +88,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import com.ruoyi.framework.config.ThreadPoolConfig;
|
|
|
+import com.ruoyi.system.service.ISysDeptService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import com.ruoyi.system.utils.UserUtil;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
@@ -200,6 +202,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Autowired
|
|
|
private FileInfoService fileInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
/**
|
|
|
* 合同和样品单 下拉分页
|
|
|
*/
|
|
@@ -320,15 +325,22 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
if (StringUtils.isNotEmpty(dto.getRefundStatusNew())) {
|
|
|
wrapper.in("t1.refundStatusNew", Arrays.asList(dto.getRefundStatusNew().split(",")));
|
|
|
}
|
|
|
+ //归属公司id过滤
|
|
|
+ wrapper.eq(Contract::getCompanyId, dto.getCompanyId());
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
- //归属公司
|
|
|
List<Long> corporationIds = corporationService.listObject(Corporation::getId, q -> q.like(Corporation::getName, dto.getKeyword()));
|
|
|
List<Long> customerIds = customerService.listObject(Customer::getId, q -> q.like(Customer::getName, dto.getKeyword()));
|
|
|
+
|
|
|
+ //归属公司
|
|
|
+ List<SysDept> companyList = deptService.list(Wrappers.<SysDept>query().eq("type", 0));
|
|
|
+ List<Long> companyIds = companyList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
|
|
wrapper.and(q -> q
|
|
|
.like("t1", Contract::getCode, dto.getKeyword())
|
|
|
.or().like("t1", Contract::getUserName, dto.getUserName())
|
|
|
.or().in("t1", Contract::getSellCorporationId, corporationIds)
|
|
|
.or().in("t1", Contract::getBuyCorporationId, customerIds)
|
|
|
+ .or().in("t1", Contract::getCompanyId, companyIds)
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -378,62 +390,71 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
private Page<ContractVo> pageCommon(ContractSelectDto dto, IWrapper<Contract> wrapper) {
|
|
|
Page<ContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<ContractVo> list = page.getRecords();
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- //获取合同类型字典内容
|
|
|
- DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
- DictTenantDataSelectDto dictTenantDataSelectDto = new DictTenantDataSelectDto();
|
|
|
- dictTenantDataSelectDto.setDictCode("contract_type");
|
|
|
- List<DictTenantDataVo> dictTenantDataVoList = dictTenantDataService.getList(dictTenantDataSelectDto);
|
|
|
- Map<String, String> contractTypeStatusDic = dictTenantDataVoList.stream().collect(Collectors.toMap(DictTenantDataVo::getDictKey, DictTenantDataVo::getDictValue));
|
|
|
- DynamicDataSourceContextHolder.poll();
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ //获取归属公司
|
|
|
+ List<SysDept> companyList = deptService.list(Wrappers.<SysDept>query().eq("type", 0));
|
|
|
+ Map<Long, String> companyMap = companyList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
|
|
|
- List<Long> customerIds = list.stream().map(Contract::getBuyCorporationId).collect(Collectors.toList());
|
|
|
- List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
|
|
|
- Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
|
|
|
+ //获取合同类型字典内容
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ DictTenantDataSelectDto dictTenantDataSelectDto = new DictTenantDataSelectDto();
|
|
|
+ dictTenantDataSelectDto.setDictCode("contract_type");
|
|
|
+ List<DictTenantDataVo> dictTenantDataVoList = dictTenantDataService.getList(dictTenantDataSelectDto);
|
|
|
+ Map<String, String> contractTypeStatusDic = dictTenantDataVoList.stream().collect(Collectors.toMap(DictTenantDataVo::getDictKey, DictTenantDataVo::getDictValue));
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
|
|
|
- List<Long> ids = list.stream().map(ContractVo::getId).collect(Collectors.toList());
|
|
|
- // 获取交接单附件
|
|
|
- Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);
|
|
|
+ List<Long> customerIds = list.stream().map(Contract::getBuyCorporationId).collect(Collectors.toList());
|
|
|
+ List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
|
|
|
+ Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
|
|
|
+
|
|
|
+ List<Long> ids = list.stream().map(ContractVo::getId).collect(Collectors.toList());
|
|
|
+ // 获取交接单附件
|
|
|
+ Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);
|
|
|
+
|
|
|
+ // 获取包装附件
|
|
|
+ Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);
|
|
|
+ for (ContractVo p : list) {
|
|
|
+
|
|
|
+ // 客户
|
|
|
+ if (MapUtils.isNotEmpty(cusMap)) {
|
|
|
+ List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(), null);
|
|
|
+ p.setBuyCorporationName(customers == null ? null : customers.get(0).getName());
|
|
|
+ // 赋值客户标签
|
|
|
+ p.setTag(customers == null ? null : customers.get(0).getTag());
|
|
|
+ //赋值业务员
|
|
|
+ p.setUserName(p.getSalesmanName());
|
|
|
+ }
|
|
|
|
|
|
- // 获取包装附件
|
|
|
- Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);
|
|
|
- for (ContractVo p : list) {
|
|
|
+ // 赋值交接单附件
|
|
|
+ if (MapUtils.isNotEmpty(fileMap)) {
|
|
|
+ List<FileInfoVo> fileInfoVos = fileMap.get(p.getId());
|
|
|
+ p.setFileInfoVos(fileInfoVos);
|
|
|
+ }
|
|
|
|
|
|
- // 客户
|
|
|
- if (MapUtils.isNotEmpty(cusMap)) {
|
|
|
- List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(), null);
|
|
|
- p.setBuyCorporationName(customers == null ? null : customers.get(0).getName());
|
|
|
- // 赋值客户标签
|
|
|
- p.setTag(customers == null ? null : customers.get(0).getTag());
|
|
|
- //赋值业务员
|
|
|
- p.setUserName(p.getSalesmanName());
|
|
|
- }
|
|
|
+ // 赋值包装附件信息
|
|
|
+ if (MapUtils.isNotEmpty(packageFileMap)) {
|
|
|
+ List<FileInfoVo> packageFileInfoVOList = packageFileMap.get(p.getId());
|
|
|
+ p.setPackageFileInfoVOList(packageFileInfoVOList);
|
|
|
+ }
|
|
|
|
|
|
- // 赋值交接单附件
|
|
|
- if (MapUtils.isNotEmpty(fileMap)) {
|
|
|
- List<FileInfoVo> fileInfoVos = fileMap.get(p.getId());
|
|
|
- p.setFileInfoVos(fileInfoVos);
|
|
|
- }
|
|
|
+ //获取合同类型字典内容
|
|
|
+ p.setContractTypeVal(contractTypeStatusDic.get(p.getContractType()));
|
|
|
|
|
|
- // 赋值包装附件信息
|
|
|
- if (MapUtils.isNotEmpty(packageFileMap)) {
|
|
|
- List<FileInfoVo> packageFileInfoVOList = packageFileMap.get(p.getId());
|
|
|
- p.setPackageFileInfoVOList(packageFileInfoVOList);
|
|
|
- }
|
|
|
+ //赋值归属公司
|
|
|
+ p.setCompanyName(companyMap.get(p.getCompanyId()));
|
|
|
|
|
|
- //获取合同类型字典内容
|
|
|
- p.setContractTypeVal(contractTypeStatusDic.get(p.getContractType()));
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ // 赋值流程id
|
|
|
+ List<ContractVo> collect = list.stream().filter(item -> Objects.isNull(item.getFlowId())).collect(Collectors.toList());
|
|
|
+ flowExampleService.setFlowId(collect, ContractVo::setFlowId);
|
|
|
+ //赋值原卖方公司名称 多公司
|
|
|
+ corporationService.attributeAssign(list, ContractVo::getSellCorporationId, (item, corporation) -> {
|
|
|
+ item.setSellCorporationName(corporation.getName());
|
|
|
+ });
|
|
|
|
|
|
- // 赋值流程id
|
|
|
- List<ContractVo> collect = list.stream().filter(item -> Objects.isNull(item.getFlowId())).collect(Collectors.toList());
|
|
|
- flowExampleService.setFlowId(collect, ContractVo::setFlowId);
|
|
|
- //赋值原卖方公司名称 多公司
|
|
|
- corporationService.attributeAssign(list, ContractVo::getSellCorporationId, (item, corporation) -> {
|
|
|
- item.setSellCorporationName(corporation.getName());
|
|
|
- });
|
|
|
- }
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -1150,6 +1171,13 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
List<ContractBudgetVo.GrossProfitInfo> grossProfitInfoList = contractBudgetVo.getGrossProfitInfoList();
|
|
|
result.setGrossProfitInfoList(grossProfitInfoList);
|
|
|
}
|
|
|
+
|
|
|
+ //赋值归属公司
|
|
|
+ SysDept company = deptService.getById(result.getCompanyId());
|
|
|
+ if (ObjectUtil.isNotEmpty(company)) {
|
|
|
+ result.setCompanyName(company.getDeptName());
|
|
|
+ }
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|