|
@@ -1,13 +1,20 @@
|
|
package com.cdf.service.impl;
|
|
package com.cdf.service.impl;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
+import com.cdf.entity.ProductHk;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.cdf.common.ResultCode;
|
|
import com.cdf.entity.ProductSource;
|
|
import com.cdf.entity.ProductSource;
|
|
import com.cdf.entity.SceneSource;
|
|
import com.cdf.entity.SceneSource;
|
|
|
|
+import com.cdf.exception.BusinessException;
|
|
import com.cdf.mapper.ISceneSourceMapper;
|
|
import com.cdf.mapper.ISceneSourceMapper;
|
|
|
|
+import com.cdf.request.ProductSourceAddParam;
|
|
import com.cdf.service.IProductSourceService;
|
|
import com.cdf.service.IProductSourceService;
|
|
import com.cdf.service.ISceneSourceService;
|
|
import com.cdf.service.ISceneSourceService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -40,4 +47,74 @@ public class SceneSourceServiceImpl extends ServiceImpl<ISceneSourceMapper, Scen
|
|
}
|
|
}
|
|
return productSourceService.getById(list.get(0).getProductSourceId());
|
|
return productSourceService.getById(list.get(0).getProductSourceId());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void add(ProductSourceAddParam param) {
|
|
|
|
+ if(StringUtils.isBlank(param.getCdfHost()) || StringUtils.isBlank(param.getCdfMchId())
|
|
|
|
+ || StringUtils.isBlank(param.getCdfName())){
|
|
|
|
+ throw new BusinessException(ResultCode.PARAM_MISS);
|
|
|
|
+ }
|
|
|
|
+ ProductSource productSource = new ProductSource();
|
|
|
|
+ BeanUtils.copyProperties(param,productSource);
|
|
|
|
+ productSourceService.save(productSource);
|
|
|
|
+ if(param.getSceneNumList() == null || param.getSceneNumList().size() <=0){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (String sceneNum : param.getSceneNumList()) {
|
|
|
|
+ SceneSource sceneSource = new SceneSource();
|
|
|
|
+ sceneSource.setSceneNum(sceneNum);
|
|
|
|
+ sceneSource.setProductSourceId(productSource.getId());
|
|
|
|
+ this.save(sceneSource);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateByParam(ProductSourceAddParam param) {
|
|
|
|
+ if(param.getId() == null ){
|
|
|
|
+ throw new BusinessException(ResultCode.PARAM_MISS);
|
|
|
|
+ }
|
|
|
|
+ ProductSource productSource = productSourceService.getById(param.getId());
|
|
|
|
+ if(productSource == null){
|
|
|
|
+ throw new BusinessException(ResultCode.PRODUCT_SOURCE_NOT_EXIST);
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(param.getCdfHost())){
|
|
|
|
+ productSource.setCdfHost(param.getCdfHost());
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(param.getCdfMchId())){
|
|
|
|
+ productSource.setCdfMchId(param.getCdfMchId());
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(param.getCdfName())){
|
|
|
|
+ productSource.setCdfName(param.getCdfName());
|
|
|
|
+ }
|
|
|
|
+ productSource.setUpdateTime(null);
|
|
|
|
+ productSourceService.updateById(productSource);
|
|
|
|
+
|
|
|
|
+ this.delByProductSourceId(param.getId());
|
|
|
|
+ if(param.getSceneNumList() == null || param.getSceneNumList().size() <=0){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (String sceneNum : param.getSceneNumList()) {
|
|
|
|
+ SceneSource sceneSource = new SceneSource();
|
|
|
|
+ sceneSource.setSceneNum(sceneNum);
|
|
|
|
+ sceneSource.setProductSourceId(productSource.getId());
|
|
|
|
+ this.save(sceneSource);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void delByProductSourceId(Integer productSourceId) {
|
|
|
|
+ LambdaQueryWrapper<SceneSource> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(SceneSource::getProductSourceId,productSourceId);
|
|
|
|
+ this.remove(wrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<SceneSource> getByProductSourceId(Integer productSourceId) {
|
|
|
|
+ LambdaQueryWrapper<SceneSource> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(SceneSource::getProductSourceId,productSourceId);
|
|
|
|
+ return this.list(wrapper);
|
|
|
|
+ }
|
|
}
|
|
}
|