mirror of https://github.com/elunez/eladmin
新增供应商资料
parent
d2304e60d5
commit
4169db81ca
|
@ -37,12 +37,6 @@ public class SupplierInfoDTO implements Serializable {
|
||||||
// 备注
|
// 备注
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
// 供应商地址地址数组[{“province”:””,”city”:””,”area”:””,”address_detail”:””,”sort”:””}]
|
|
||||||
private String supplierAddress;
|
|
||||||
|
|
||||||
// 供应商联系人[{“sort”:””,”name”:””,”mobile”:””,”phone”:””,”email”:””,”qq”:””,”weixin”:””,”firstTag”:””}]firstTag 0:非首要联系人 1:首要联系人
|
|
||||||
private String supplierContact;
|
|
||||||
|
|
||||||
private Boolean status;
|
private Boolean status;
|
||||||
|
|
||||||
// 供应商类别主键
|
// 供应商类别主键
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package me.zhengjie.modules.wms.bd.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.modules.wms.bd.request.SupplierAddress;
|
||||||
|
import me.zhengjie.modules.wms.bd.request.SupplierContact;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jie
|
||||||
|
* @date 2019-08-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SupplierInfoDetailDTO extends SupplierInfoDTO implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 供应商地址地址数组[{“province”:””,”city”:””,”area”:””,”address_detail”:””,”sort”:””}]
|
||||||
|
private List<SupplierAddress> supplierAddress;
|
||||||
|
|
||||||
|
// 供应商联系人[{“sort”:””,”name”:””,”mobile”:””,”phone”:””,”email”:””,”qq”:””,”weixin”:””,”firstTag”:””}]firstTag 0:非首要联系人 1:首要联系人
|
||||||
|
private List<SupplierContact> supplierContact;
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,17 @@
|
||||||
package me.zhengjie.modules.wms.bd.service.impl;
|
package me.zhengjie.modules.wms.bd.service.impl;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
||||||
|
import me.zhengjie.modules.wms.bd.domain.SupplierCategory;
|
||||||
import me.zhengjie.modules.wms.bd.domain.SupplierInfo;
|
import me.zhengjie.modules.wms.bd.domain.SupplierInfo;
|
||||||
|
import me.zhengjie.modules.wms.bd.repository.SupplierCategoryRepository;
|
||||||
import me.zhengjie.modules.wms.bd.request.CreateSupplierInfoRequest;
|
import me.zhengjie.modules.wms.bd.request.CreateSupplierInfoRequest;
|
||||||
import me.zhengjie.modules.wms.bd.request.SupplierAddress;
|
import me.zhengjie.modules.wms.bd.request.SupplierAddress;
|
||||||
import me.zhengjie.modules.wms.bd.request.SupplierContact;
|
import me.zhengjie.modules.wms.bd.request.SupplierContact;
|
||||||
|
import me.zhengjie.modules.wms.bd.service.dto.SupplierInfoDetailDTO;
|
||||||
|
import me.zhengjie.modules.wms.bd.service.mapper.SupplierCategoryMapper;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import me.zhengjie.modules.wms.bd.repository.SupplierInfoRepository;
|
import me.zhengjie.modules.wms.bd.repository.SupplierInfoRepository;
|
||||||
import me.zhengjie.modules.wms.bd.service.SupplierInfoService;
|
import me.zhengjie.modules.wms.bd.service.SupplierInfoService;
|
||||||
|
@ -28,6 +33,7 @@ import org.springframework.data.domain.Pageable;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.PageUtil;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
@ -48,6 +54,12 @@ public class SupplierInfoServiceImpl implements SupplierInfoService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SupplierInfoMapper supplierInfoMapper;
|
private SupplierInfoMapper supplierInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierCategoryMapper supplierCategoryMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierCategoryRepository supplierCategoryRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(SupplierInfoQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(SupplierInfoQueryCriteria criteria, Pageable pageable){
|
||||||
Specification<SupplierInfo> specification = new Specification<SupplierInfo>() {
|
Specification<SupplierInfo> specification = new Specification<SupplierInfo>() {
|
||||||
|
@ -101,6 +113,15 @@ public class SupplierInfoServiceImpl implements SupplierInfoService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SupplierInfoDTO create(CreateSupplierInfoRequest createSupplierInfoRequest) {
|
public SupplierInfoDTO create(CreateSupplierInfoRequest createSupplierInfoRequest) {
|
||||||
|
Long supplierCategoryId = createSupplierInfoRequest.getSupplierCategoryId();
|
||||||
|
if(null == supplierCategoryId){
|
||||||
|
throw new BadRequestException("供应商类别不存在!");
|
||||||
|
}
|
||||||
|
Optional<SupplierCategory> supplierCategoryOptional = supplierCategoryRepository.findById(supplierCategoryId);
|
||||||
|
SupplierCategory supplierCategory = supplierCategoryOptional.get();
|
||||||
|
|
||||||
|
SupplierInfoDetailDTO supplierInfoDetailDTO = new SupplierInfoDetailDTO();
|
||||||
|
|
||||||
SupplierInfo supplierInfo = new SupplierInfo();
|
SupplierInfo supplierInfo = new SupplierInfo();
|
||||||
BeanUtils.copyProperties(createSupplierInfoRequest, supplierInfo);
|
BeanUtils.copyProperties(createSupplierInfoRequest, supplierInfo);
|
||||||
supplierInfo.setStatus(true);
|
supplierInfo.setStatus(true);
|
||||||
|
@ -108,15 +129,21 @@ public class SupplierInfoServiceImpl implements SupplierInfoService {
|
||||||
if(!CollectionUtils.isEmpty(supplierAddressList)){
|
if(!CollectionUtils.isEmpty(supplierAddressList)){
|
||||||
String supplierAddressStr = new Gson().toJson(supplierAddressList);
|
String supplierAddressStr = new Gson().toJson(supplierAddressList);
|
||||||
supplierInfo.setSupplierAddress(supplierAddressStr);
|
supplierInfo.setSupplierAddress(supplierAddressStr);
|
||||||
|
supplierInfoDetailDTO.setSupplierAddress(supplierAddressList);
|
||||||
}
|
}
|
||||||
List<SupplierContact> supplierContactList = createSupplierInfoRequest.getSupplierContact();
|
List<SupplierContact> supplierContactList = createSupplierInfoRequest.getSupplierContact();
|
||||||
if(!CollectionUtils.isEmpty(supplierContactList)){
|
if(!CollectionUtils.isEmpty(supplierContactList)){
|
||||||
String supplierContactStr = new Gson().toJson(supplierContactList);
|
String supplierContactStr = new Gson().toJson(supplierContactList);
|
||||||
supplierInfo.setSupplierContact(supplierContactStr);
|
supplierInfo.setSupplierContact(supplierContactStr);
|
||||||
|
supplierInfoDetailDTO.setSupplierContact(supplierContactList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supplierInfo.setSupplierCategoryName(supplierCategory.getName());
|
||||||
|
|
||||||
supplierInfo = supplierInfoRepository.save(supplierInfo);
|
supplierInfo = supplierInfoRepository.save(supplierInfo);
|
||||||
SupplierInfoDTO supplierInfoDTO = supplierInfoMapper.toDto(supplierInfo);
|
SupplierInfoDTO supplierInfoDTO = supplierInfoMapper.toDto(supplierInfo);
|
||||||
return supplierInfoDTO;
|
BeanUtils.copyProperties(supplierInfoDTO, supplierInfoDetailDTO);
|
||||||
|
return supplierInfoDetailDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue