mirror of https://github.com/elunez/eladmin
产品统计
parent
7e2daa57d1
commit
d5437ffa0e
|
@ -98,7 +98,7 @@ public class OutSourceCompanyInfoServiceImpl implements OutSourceCompanyInfoServ
|
||||||
List<OutSourceCompanyContact> outSourceCompanyContactList = new Gson().fromJson(outSourceCompanyJsonStr,new TypeToken<ArrayList<OutSourceCompanyContact>>() {}.getType());
|
List<OutSourceCompanyContact> outSourceCompanyContactList = new Gson().fromJson(outSourceCompanyJsonStr,new TypeToken<ArrayList<OutSourceCompanyContact>>() {}.getType());
|
||||||
if(!CollectionUtils.isEmpty(outSourceCompanyContactList)){
|
if(!CollectionUtils.isEmpty(outSourceCompanyContactList)){
|
||||||
for(OutSourceCompanyContact outSourceCompanyContact : outSourceCompanyContactList){
|
for(OutSourceCompanyContact outSourceCompanyContact : outSourceCompanyContactList){
|
||||||
if(outSourceCompanyContact.getFirstTag() == 1){
|
if(!StringUtils.isEmpty(outSourceCompanyContact.getFirstTag()) && outSourceCompanyContact.getFirstTag() == 1){
|
||||||
outSourceCompanyInfoDTO.setFirstContactMobile(outSourceCompanyContact.getMobile());
|
outSourceCompanyInfoDTO.setFirstContactMobile(outSourceCompanyContact.getMobile());
|
||||||
outSourceCompanyInfoDTO.setFirstContactName(outSourceCompanyContact.getName());
|
outSourceCompanyInfoDTO.setFirstContactName(outSourceCompanyContact.getName());
|
||||||
}
|
}
|
||||||
|
@ -188,11 +188,52 @@ public class OutSourceCompanyInfoServiceImpl implements OutSourceCompanyInfoServ
|
||||||
}
|
}
|
||||||
List<OutSourceCompanyContact> outSourceCompanyContactList = createOutSourceCompanyInfoRequest.getOutSourceCompanyContact();
|
List<OutSourceCompanyContact> outSourceCompanyContactList = createOutSourceCompanyInfoRequest.getOutSourceCompanyContact();
|
||||||
if(!CollectionUtils.isEmpty(outSourceCompanyContactList)){
|
if(!CollectionUtils.isEmpty(outSourceCompanyContactList)){
|
||||||
|
Boolean firstTagFlag = false;
|
||||||
|
for(OutSourceCompanyContact outSourceCompanyContact: outSourceCompanyContactList){
|
||||||
|
String name = outSourceCompanyContact.getName();
|
||||||
|
if(StringUtils.isEmpty(name)){
|
||||||
|
throw new BadRequestException("联系人姓名不能为空!");
|
||||||
|
}
|
||||||
|
String mobile = outSourceCompanyContact.getMobile();
|
||||||
|
if(StringUtils.isEmpty(mobile)){
|
||||||
|
throw new BadRequestException("联系人" + name +"对应的手机号码不能为空!");
|
||||||
|
}
|
||||||
|
String phone = outSourceCompanyContact.getPhone();
|
||||||
|
if(StringUtils.isEmpty(phone)){
|
||||||
|
throw new BadRequestException("联系人" + name +"对应的座机不能为空!");
|
||||||
|
}
|
||||||
|
String email = outSourceCompanyContact.getEmail();
|
||||||
|
if(StringUtils.isEmpty(email)){
|
||||||
|
throw new BadRequestException("联系人" + name +"对应的邮箱不能为空!");
|
||||||
|
}
|
||||||
|
String weixin = outSourceCompanyContact.getWeixin();
|
||||||
|
if(StringUtils.isEmpty(weixin)){
|
||||||
|
throw new BadRequestException("联系人" + name +"对应的微信不能为空!");
|
||||||
|
}
|
||||||
|
String qq = outSourceCompanyContact.getQq();
|
||||||
|
if(StringUtils.isEmpty(qq)){
|
||||||
|
throw new BadRequestException("联系人" + name +"对应的qq不能为空!");
|
||||||
|
}
|
||||||
|
Integer firstTag = outSourceCompanyContact.getFirstTag();
|
||||||
|
if(null == firstTag){
|
||||||
|
throw new BadRequestException("联系人" + name +"对应的首要联系人不能为空!");
|
||||||
|
}
|
||||||
|
if(firstTag == 1){
|
||||||
|
firstTagFlag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!firstTagFlag){
|
||||||
|
throw new BadRequestException("委外公司联系人必须设置一个首要联系人!");
|
||||||
|
}
|
||||||
String outSourceCompanyContactStr = new Gson().toJson(outSourceCompanyContactList);
|
String outSourceCompanyContactStr = new Gson().toJson(outSourceCompanyContactList);
|
||||||
outSourceCompanyInfo.setOutSourceCompanyContact(outSourceCompanyContactStr);
|
outSourceCompanyInfo.setOutSourceCompanyContact(outSourceCompanyContactStr);
|
||||||
outSourceCompanyInfoDetailDTO.setOutSourceCompanyContact(outSourceCompanyContactList);
|
outSourceCompanyInfoDetailDTO.setOutSourceCompanyContact(outSourceCompanyContactList);
|
||||||
|
}else{
|
||||||
|
throw new BadRequestException("委外公司联系人不能为空!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
outSourceCompanyInfo = outSourceCompanyInfoRepository.save(outSourceCompanyInfo);
|
outSourceCompanyInfo = outSourceCompanyInfoRepository.save(outSourceCompanyInfo);
|
||||||
OutSourceCompanyInfoDTO outSourceCompanyInfoDTO = outSourceCompanyInfoMapper.toDto(outSourceCompanyInfo);
|
OutSourceCompanyInfoDTO outSourceCompanyInfoDTO = outSourceCompanyInfoMapper.toDto(outSourceCompanyInfo);
|
||||||
BeanUtils.copyProperties(outSourceCompanyInfoDTO, outSourceCompanyInfoDetailDTO);
|
BeanUtils.copyProperties(outSourceCompanyInfoDTO, outSourceCompanyInfoDetailDTO);
|
||||||
|
|
|
@ -9,10 +9,14 @@ import me.zhengjie.modules.wms.bd.repository.ProductCategoryRepository;
|
||||||
import me.zhengjie.modules.wms.bd.repository.ProductSeriesRepository;
|
import me.zhengjie.modules.wms.bd.repository.ProductSeriesRepository;
|
||||||
import me.zhengjie.modules.wms.bd.request.*;
|
import me.zhengjie.modules.wms.bd.request.*;
|
||||||
import me.zhengjie.modules.wms.bd.service.dto.*;
|
import me.zhengjie.modules.wms.bd.service.dto.*;
|
||||||
|
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
|
||||||
|
import me.zhengjie.modules.wms.sr.productCount.repository.ProductCountRepository;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
|
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
|
||||||
import me.zhengjie.modules.wms.bd.service.ProductInfoService;
|
import me.zhengjie.modules.wms.bd.service.ProductInfoService;
|
||||||
import me.zhengjie.modules.wms.bd.service.mapper.ProductInfoMapper;
|
import me.zhengjie.modules.wms.bd.service.mapper.ProductInfoMapper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
@ -46,6 +50,8 @@ import javax.persistence.criteria.Root;
|
||||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||||
public class ProductInfoServiceImpl implements ProductInfoService {
|
public class ProductInfoServiceImpl implements ProductInfoService {
|
||||||
|
|
||||||
|
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductInfoRepository productInfoRepository;
|
private ProductInfoRepository productInfoRepository;
|
||||||
|
|
||||||
|
@ -61,6 +67,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductSeriesRepository productSeriesRepository;
|
private ProductSeriesRepository productSeriesRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductCountRepository productCountRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(ProductInfoQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(ProductInfoQueryCriteria criteria, Pageable pageable){
|
||||||
Specification<ProductInfo> specification = new Specification<ProductInfo>() {
|
Specification<ProductInfo> specification = new Specification<ProductInfo>() {
|
||||||
|
@ -190,6 +199,15 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
||||||
productInfo = productInfoRepository.save(productInfo);
|
productInfo = productInfoRepository.save(productInfo);
|
||||||
ProductInfoDTO productInfoDTO = productInfoMapper.toDto(productInfo);
|
ProductInfoDTO productInfoDTO = productInfoMapper.toDto(productInfo);
|
||||||
BeanUtils.copyProperties(productInfoDTO, productInfoDetailDTO);
|
BeanUtils.copyProperties(productInfoDTO, productInfoDetailDTO);
|
||||||
|
|
||||||
|
// 新增产品统计数据
|
||||||
|
ProductCount productCount = new ProductCount();
|
||||||
|
productCount.setProductName(productInfo.getName());
|
||||||
|
productCount.setProductCategoryId(productInfo.getProductCategoryId());
|
||||||
|
productCount.setProductCategoryName(productInfo.getProductCategoryName());
|
||||||
|
productCount.setProductSeriesId(productInfo.getProductSeriesId());
|
||||||
|
productCount.setProductSeriesName(productInfo.getProductSeriesName());
|
||||||
|
productCountRepository.save(productCount);
|
||||||
return productInfoDetailDTO;
|
return productInfoDetailDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +292,26 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
||||||
productInfo.setProductCategoryName(productCategory.getName());
|
productInfo.setProductCategoryName(productCategory.getName());
|
||||||
// 修改客户资料
|
// 修改客户资料
|
||||||
productInfoRepository.save(productInfo);
|
productInfoRepository.save(productInfo);
|
||||||
|
|
||||||
|
// 根据产品主键查看产品统计是否存在,如果存在则不操作,不存在则插入
|
||||||
|
ProductCount productCount = productCountRepository.findByProductId(productInfoId);
|
||||||
|
if(null == productCount){
|
||||||
|
productCount = new ProductCount();
|
||||||
|
productCount.setProductId(productInfoId);
|
||||||
|
productCount.setProductName(productInfo.getName());
|
||||||
|
productCount.setProductSeriesName(productInfo.getProductSeriesName());
|
||||||
|
productCount.setProductSeriesId(productInfo.getProductSeriesId());
|
||||||
|
productCount.setProductCategoryName(productInfo.getProductCategoryName());
|
||||||
|
productCount.setProductCategoryId(productInfo.getProductCategoryId());
|
||||||
|
logger.info("新增产品统计;[]", new Gson().toJson(productCount));
|
||||||
|
productCountRepository.save(productCount);
|
||||||
|
}else{
|
||||||
|
productCount.setProductSeriesId(productInfo.getProductSeriesId());
|
||||||
|
productCount.setProductSeriesName(productInfo.getProductSeriesName());
|
||||||
|
productCount.setProductCategoryId(productInfo.getProductCategoryId());
|
||||||
|
productCount.setProductCategoryName(productInfo.getProductCategoryName());
|
||||||
|
productCountRepository.save(productCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,6 +40,13 @@ public interface ProductCountService {
|
||||||
//@Cacheable(key = "#p0")
|
//@Cacheable(key = "#p0")
|
||||||
ProductCountDTO findById(Long id);
|
ProductCountDTO findById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据productId查看产品统计
|
||||||
|
* @param productId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ProductCountDTO findByProductId(Long productId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create
|
* create
|
||||||
* @param resources
|
* @param resources
|
||||||
|
|
|
@ -59,6 +59,13 @@ public class ProductCountServiceImpl implements ProductCountService {
|
||||||
return productCountMapper.toDto(srProductCount.get());
|
return productCountMapper.toDto(srProductCount.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductCountDTO findByProductId(Long productId) {
|
||||||
|
|
||||||
|
ProductCount productCount = productCountMapper.findByProductId(productId);
|
||||||
|
return productCountMapper.toDto(productCount);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ProductCountDTO create(ProductCount resources) {
|
public ProductCountDTO create(ProductCount resources) {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package me.zhengjie.modules.wms.sr.productCount.service.mapper;
|
package me.zhengjie.modules.wms.sr.productCount.service.mapper;
|
||||||
|
|
||||||
import me.zhengjie.mapper.EntityMapper;
|
import me.zhengjie.mapper.EntityMapper;
|
||||||
|
import me.zhengjie.modules.wms.qualityCheckSheet.domain.QualityCheckSheet;
|
||||||
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
|
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
|
||||||
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountDTO;
|
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountDTO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
|
@ -13,4 +15,7 @@ import org.mapstruct.ReportingPolicy;
|
||||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
public interface ProductCountMapper extends EntityMapper<ProductCountDTO, ProductCount> {
|
public interface ProductCountMapper extends EntityMapper<ProductCountDTO, ProductCount> {
|
||||||
|
|
||||||
|
@Query(value ="select * from sr_product_count where product_id = ?1", nativeQuery = true)
|
||||||
|
ProductCount findByProductId(Long productId);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue