|
@@ -23,6 +23,7 @@ import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -53,17 +54,22 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
@Override
|
|
@Override
|
|
public Page<SupplierInfoVo> getPage(SupplierInfoSelectDto dto) {
|
|
public Page<SupplierInfoVo> getPage(SupplierInfoSelectDto dto) {
|
|
IWrapper<SupplierInfo> wrapper = getWrapper();
|
|
IWrapper<SupplierInfo> wrapper = getWrapper();
|
|
- wrapper.orderByDesc("si", SupplierInfo::getId);
|
|
|
|
wrapper.eq("si", SupplierInfo::getType, dto.getType());
|
|
wrapper.eq("si", SupplierInfo::getType, dto.getType());
|
|
- wrapper.like("si",SupplierInfo::getCode,dto.getCode());
|
|
|
|
- wrapper.like("si",SupplierInfo::getName,dto.getName());
|
|
|
|
- wrapper.eq("si",SupplierInfo::getCountryId,dto.getCountryId());
|
|
|
|
- wrapper.eq("si",SupplierInfo::getProvinceId,dto.getProvinceId());
|
|
|
|
- wrapper.eq("si",SupplierInfo::getCityId,dto.getCityId());
|
|
|
|
|
|
+ wrapper.like("si", SupplierInfo::getCode, dto.getCode());
|
|
|
|
+ wrapper.like("si", SupplierInfo::getName, dto.getName());
|
|
|
|
+ wrapper.eq("si", SupplierInfo::getCountryId, dto.getCountryId());
|
|
|
|
+ wrapper.eq("si", SupplierInfo::getProvinceId, dto.getProvinceId());
|
|
|
|
+ wrapper.eq("si", SupplierInfo::getCityId, dto.getCityId());
|
|
wrapper.keyword(dto,
|
|
wrapper.keyword(dto,
|
|
new SqlField("si", SupplierInfo::getName),
|
|
new SqlField("si", SupplierInfo::getName),
|
|
new SqlField("si", SupplierInfo::getCode)
|
|
new SqlField("si", SupplierInfo::getCode)
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ //权限过滤:供应商自己看自己
|
|
|
|
+ wrapper.eq("si", SupplierInfo::getCompanyId, SecurityUtils.getCompanyId());
|
|
|
|
+
|
|
|
|
+ wrapper.orderByDesc("si", SupplierInfo::getId);
|
|
|
|
+
|
|
Page<SupplierInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<SupplierInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
|
|
List<SupplierInfoVo> records = page.getRecords();
|
|
List<SupplierInfoVo> records = page.getRecords();
|
|
@@ -136,6 +142,13 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
public void add(SupplierInfoDto supplierInfoDto) {
|
|
public void add(SupplierInfoDto supplierInfoDto) {
|
|
CustomizeAreaUtil.setAreaId(supplierInfoDto);
|
|
CustomizeAreaUtil.setAreaId(supplierInfoDto);
|
|
supplierInfoDto.setCode(CodeEnum.SUPPLIER_INFO.getCode());
|
|
supplierInfoDto.setCode(CodeEnum.SUPPLIER_INFO.getCode());
|
|
|
|
+
|
|
|
|
+ //赋值产品归属公司
|
|
|
|
+ Long companyId = supplierInfoDto.getCompanyId();
|
|
|
|
+ if (ObjectUtil.isEmpty(companyId)) {
|
|
|
|
+ supplierInfoDto.setCountryId(SecurityUtils.getCompanyId());
|
|
|
|
+ }
|
|
|
|
+
|
|
this.save(supplierInfoDto);
|
|
this.save(supplierInfoDto);
|
|
ObsFileUtil.saveFile(supplierInfoDto.getFileList(), supplierInfoDto.getId());
|
|
ObsFileUtil.saveFile(supplierInfoDto.getFileList(), supplierInfoDto.getId());
|
|
}
|
|
}
|
|
@@ -145,6 +158,13 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
public void edit(SupplierInfoDto supplierInfoDto) {
|
|
public void edit(SupplierInfoDto supplierInfoDto) {
|
|
CustomizeAreaUtil.setAreaId(supplierInfoDto);
|
|
CustomizeAreaUtil.setAreaId(supplierInfoDto);
|
|
supplierInfoDto.setCode(null);
|
|
supplierInfoDto.setCode(null);
|
|
|
|
+
|
|
|
|
+ //赋值产品归属公司
|
|
|
|
+ Long companyId = supplierInfoDto.getCompanyId();
|
|
|
|
+ if (ObjectUtil.isEmpty(companyId)) {
|
|
|
|
+ supplierInfoDto.setCountryId(SecurityUtils.getCompanyId());
|
|
|
|
+ }
|
|
|
|
+
|
|
this.updateById(supplierInfoDto);
|
|
this.updateById(supplierInfoDto);
|
|
ObsFileUtil.editFile(supplierInfoDto.getFileList(), supplierInfoDto.getId());
|
|
ObsFileUtil.editFile(supplierInfoDto.getFileList(), supplierInfoDto.getId());
|
|
}
|
|
}
|
|
@@ -162,9 +182,9 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> supplierStatistics(BaseSelectDto dto) {
|
|
public Map<String, Object> supplierStatistics(BaseSelectDto dto) {
|
|
//存放供应商统计数据
|
|
//存放供应商统计数据
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
//存放供应商类型数据列表
|
|
//存放供应商类型数据列表
|
|
- List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
|
QueryWrapper<SupplierInfo> query = Wrappers.query();
|
|
QueryWrapper<SupplierInfo> query = Wrappers.query();
|
|
//为-1则说明没有查到供应商的数据(如果为null的话后面list转map报错)
|
|
//为-1则说明没有查到供应商的数据(如果为null的话后面list转map报错)
|
|
@@ -176,7 +196,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
|
|
|
//赋值合计数据
|
|
//赋值合计数据
|
|
Integer amount = supplierInfoList.stream().map(SupplierInfo::getCount).reduce(Integer::sum).orElse(0);
|
|
Integer amount = supplierInfoList.stream().map(SupplierInfo::getCount).reduce(Integer::sum).orElse(0);
|
|
- map.put("amount",amount);
|
|
|
|
|
|
+ map.put("amount", amount);
|
|
|
|
|
|
//切换数据源
|
|
//切换数据源
|
|
DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
@@ -184,30 +204,30 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
List<DictTenantDataVo> dictTenantDataVoList = getDict("supplier_type");
|
|
List<DictTenantDataVo> dictTenantDataVoList = getDict("supplier_type");
|
|
DynamicDataSourceContextHolder.poll();
|
|
DynamicDataSourceContextHolder.poll();
|
|
|
|
|
|
- if (ObjectUtil.isEmpty(dictTenantDataVoList)){
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(dictTenantDataVoList)) {
|
|
throw new ServiceException("数据有误:没有配置供应商类型字典,请先配置");
|
|
throw new ServiceException("数据有误:没有配置供应商类型字典,请先配置");
|
|
}
|
|
}
|
|
|
|
|
|
//赋值
|
|
//赋值
|
|
for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
|
|
for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
|
|
//设置初始值
|
|
//设置初始值
|
|
- Map<String,Object> supplierMap = new HashMap<>();
|
|
|
|
- supplierMap.put("type",dictTenantDataVo.getDictValue());
|
|
|
|
- supplierMap.put("count",0);
|
|
|
|
|
|
+ Map<String, Object> supplierMap = new HashMap<>();
|
|
|
|
+ supplierMap.put("type", dictTenantDataVo.getDictValue());
|
|
|
|
+ supplierMap.put("count", 0);
|
|
|
|
|
|
//赋值数量
|
|
//赋值数量
|
|
List<SupplierInfo> supplierInfos = supplierInfoMap.get(dictTenantDataVo.getDictKey());
|
|
List<SupplierInfo> supplierInfos = supplierInfoMap.get(dictTenantDataVo.getDictKey());
|
|
- if (ObjectUtil.isNotEmpty(supplierInfos)){
|
|
|
|
- supplierMap.put("count",supplierInfos.get(0).getCount());
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(supplierInfos)) {
|
|
|
|
+ supplierMap.put("count", supplierInfos.get(0).getCount());
|
|
}
|
|
}
|
|
list.add(supplierMap);
|
|
list.add(supplierMap);
|
|
}
|
|
}
|
|
- map.put("supplierInfoList",list);
|
|
|
|
|
|
+ map.put("supplierInfoList", list);
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
//根据字典编码获取字典的数据
|
|
//根据字典编码获取字典的数据
|
|
- private List<DictTenantDataVo> getDict(String code){
|
|
|
|
|
|
+ private List<DictTenantDataVo> getDict(String code) {
|
|
DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|
|
DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|
|
dto.setDictCode(code);
|
|
dto.setDictCode(code);
|
|
return dictTenantDataService.getList(dto);
|
|
return dictTenantDataService.getList(dto);
|