diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/SupplierInfoService.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/SupplierInfoService.java index 07a387d2..2c0bf4d1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/SupplierInfoService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/SupplierInfoService.java @@ -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 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/dto/SupplierInfoDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/dto/SupplierInfoDTO.java index 92d374fb..5798380b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/dto/SupplierInfoDTO.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/dto/SupplierInfoDTO.java @@ -44,4 +44,16 @@ public class SupplierInfoDTO implements Serializable { // 供应商类别名称 private String supplierCategoryName; + + // 首要联系人姓名 + private String firstContactName; + + // 首要联系人手机 + private String firstContactMobile; + + // 首要联系人地址 + private String firstContactAddress; + + // 应付款 + private Long upPayMoney; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/impl/SupplierInfoServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/impl/SupplierInfoServiceImpl.java index 49fc70a0..a5337419 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/impl/SupplierInfoServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/bd/service/impl/SupplierInfoServiceImpl.java @@ -79,7 +79,32 @@ public class SupplierInfoServiceImpl implements SupplierInfoService { } }; Page page = supplierInfoRepository.findAll(specification, pageable); - return PageUtil.toPage(page.map(supplierInfoMapper::toDto)); + Page supplierInfoDTOPage = page.map(supplierInfoMapper::toDto); + if(null != supplierInfoDTOPage){ + List supplierInfoDtoList = supplierInfoDTOPage.getContent(); + if(!CollectionUtils.isEmpty(supplierInfoDtoList)){ + for(SupplierInfoDTO supplierInfoDTO : supplierInfoDtoList){ + Long supplierInfoDTOId = supplierInfoDTO.getId(); + Optional supplierInfoOptional = supplierInfoRepository.findById(supplierInfoDTOId); + if(null != supplierInfoOptional){ + SupplierInfo supplierInfo = supplierInfoOptional.get(); + if(null != supplierInfo){ + String supplierContactJsonStr = supplierInfo.getSupplierContact(); + List supplierContactList = new Gson().fromJson(supplierContactJsonStr,new TypeToken>() {}.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 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 supplierAddressList = new Gson().fromJson(supplierAddressJsonStr,new TypeToken>() {}.getType()); + supplierInfoDetailDTO.setSupplierAddress(supplierAddressList); + } + + + String supplierContactJsonStr = supplierInfo.getSupplierContact(); + if(StringUtils.hasLength(supplierContactJsonStr)){ + List supplierContactList = new Gson().fromJson(supplierContactJsonStr,new TypeToken>() {}.getType()); + supplierInfoDetailDTO.setSupplierContact(supplierContactList); + } + } + return supplierInfoDetailDTO; } @Override