ConfigValueService.java
2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.huaheng.pc.config.configValue.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.configValue.domain.ConfigValue;
import com.huaheng.pc.config.configValue.mapper.ConfigValueMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class ConfigValueService extends ServiceImpl<ConfigValueMapper, ConfigValue> {
/**
* 复制系统参数配置表
* @param warehouseCode 原仓库编码
* @param newWarehouseCode 新仓库编码
* @return 是否复制成功
*/
@Transactional
public boolean configValueCopy(String warehouseCode, String newWarehouseCode){
log.trace("开始复制系统参数配置表");
LambdaQueryWrapper<ConfigValue> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ConfigValue::getWarehouseCode, newWarehouseCode);
if (!this.list(lambdaQueryWrapper).isEmpty()){
log.error(newWarehouseCode+"仓库已存在");
return false;
}
lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ConfigValue::getWarehouseCode, warehouseCode);
List<ConfigValue> configValueList = this.list(lambdaQueryWrapper);
for ( ConfigValue configValue : configValueList) {
configValue.setId(null);
configValue.setWarehouseCode(newWarehouseCode);
}
if ( this.saveBatch(configValueList) ){
log.trace("复制系统参数配置表成功,新仓库编码是:"+newWarehouseCode);
return true;
} else {
return false;
}
}
public ConfigValue getConfigValueByIdentifer(String identifier , String warehouseCode) {
LambdaQueryWrapper<ConfigValue> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ConfigValue::getWarehouseCode, warehouseCode)
.eq(ConfigValue::getIdentifier, identifier);
ConfigValue configValue = getOne(lambdaQueryWrapper);
return configValue;
}
}