mirror of https://github.com/elunez/eladmin
供应商资料
parent
4169db81ca
commit
0bf76d58d3
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.wms.bd.service;
|
|||
import me.zhengjie.modules.wms.bd.domain.SupplierInfo;
|
||||
import me.zhengjie.modules.wms.bd.request.CreateSupplierInfoRequest;
|
||||
import me.zhengjie.modules.wms.bd.service.dto.SupplierInfoDTO;
|
||||
import me.zhengjie.modules.wms.bd.service.dto.SupplierInfoDetailDTO;
|
||||
import me.zhengjie.modules.wms.bd.service.dto.SupplierInfoQueryCriteria;
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
|
@ -39,7 +40,7 @@ public interface SupplierInfoService {
|
|||
* @return
|
||||
*/
|
||||
//@Cacheable(key = "#p0")
|
||||
SupplierInfoDTO findById(Long id);
|
||||
SupplierInfoDetailDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* create
|
||||
|
|
|
@ -44,4 +44,16 @@ public class SupplierInfoDTO implements Serializable {
|
|||
|
||||
// 供应商类别名称
|
||||
private String supplierCategoryName;
|
||||
|
||||
// 首要联系人姓名
|
||||
private String firstContactName;
|
||||
|
||||
// 首要联系人手机
|
||||
private String firstContactMobile;
|
||||
|
||||
// 首要联系人地址
|
||||
private String firstContactAddress;
|
||||
|
||||
// 应付款
|
||||
private Long upPayMoney;
|
||||
}
|
|
@ -79,7 +79,32 @@ public class SupplierInfoServiceImpl implements SupplierInfoService {
|
|||
}
|
||||
};
|
||||
Page<SupplierInfo> page = supplierInfoRepository.findAll(specification, pageable);
|
||||
return PageUtil.toPage(page.map(supplierInfoMapper::toDto));
|
||||
Page<SupplierInfoDTO> supplierInfoDTOPage = page.map(supplierInfoMapper::toDto);
|
||||
if(null != supplierInfoDTOPage){
|
||||
List<SupplierInfoDTO> supplierInfoDtoList = supplierInfoDTOPage.getContent();
|
||||
if(!CollectionUtils.isEmpty(supplierInfoDtoList)){
|
||||
for(SupplierInfoDTO supplierInfoDTO : supplierInfoDtoList){
|
||||
Long supplierInfoDTOId = supplierInfoDTO.getId();
|
||||
Optional<SupplierInfo> supplierInfoOptional = supplierInfoRepository.findById(supplierInfoDTOId);
|
||||
if(null != supplierInfoOptional){
|
||||
SupplierInfo supplierInfo = supplierInfoOptional.get();
|
||||
if(null != supplierInfo){
|
||||
String supplierContactJsonStr = supplierInfo.getSupplierContact();
|
||||
List<SupplierContact> supplierContactList = new Gson().fromJson(supplierContactJsonStr,new TypeToken<ArrayList<SupplierContact>>() {}.getType());
|
||||
if(!CollectionUtils.isEmpty(supplierContactList)){
|
||||
for(SupplierContact supplierContact : supplierContactList){
|
||||
if(supplierContact.getFirstTag() == 1){
|
||||
supplierInfoDTO.setFirstContactMobile(supplierContact.getMobile());
|
||||
supplierInfoDTO.setFirstContactName(supplierContact.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return PageUtil.toPage(supplierInfoDTOPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,10 +129,28 @@ public class SupplierInfoServiceImpl implements SupplierInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SupplierInfoDTO findById(Long id) {
|
||||
public SupplierInfoDetailDTO findById(Long id) {
|
||||
SupplierInfoDetailDTO supplierInfoDetailDTO = new SupplierInfoDetailDTO();
|
||||
|
||||
Optional<SupplierInfo> bdSupplierInfo = supplierInfoRepository.findById(id);
|
||||
ValidationUtil.isNull(bdSupplierInfo,"BdSupplierInfo","id",id);
|
||||
return supplierInfoMapper.toDto(bdSupplierInfo.get());
|
||||
SupplierInfo supplierInfo = bdSupplierInfo.get();
|
||||
SupplierInfoDTO supplierInfoDTO = supplierInfoMapper.toDto(supplierInfo);
|
||||
if(null != supplierInfoDTO){
|
||||
BeanUtils.copyProperties( supplierInfoDTO, supplierInfoDetailDTO);
|
||||
String supplierAddressJsonStr = supplierInfo.getSupplierAddress();
|
||||
if(StringUtils.hasLength(supplierAddressJsonStr)){
|
||||
List<SupplierAddress> supplierAddressList = new Gson().fromJson(supplierAddressJsonStr,new TypeToken<ArrayList<SupplierAddress>>() {}.getType());
|
||||
supplierInfoDetailDTO.setSupplierAddress(supplierAddressList);
|
||||
}
|
||||
|
||||
|
||||
String supplierContactJsonStr = supplierInfo.getSupplierContact();
|
||||
if(StringUtils.hasLength(supplierContactJsonStr)){
|
||||
List<SupplierContact> supplierContactList = new Gson().fromJson(supplierContactJsonStr,new TypeToken<ArrayList<SupplierContact>>() {}.getType());
|
||||
supplierInfoDetailDTO.setSupplierContact(supplierContactList);
|
||||
}
|
||||
}
|
||||
return supplierInfoDetailDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue