ReceiptPreferenceService.java
2.05 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
package com.huaheng.pc.config.receiptPreference.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.pc.config.cycleCountPreference.domain.CycleCountPreference;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.receiptPreference.mapper.ReceiptPreferenceMapper;
import com.huaheng.pc.config.receiptPreference.domain.ReceiptPreference;
import org.springframework.transaction.annotation.Transactional;
@Service
public class ReceiptPreferenceService extends ServiceImpl<ReceiptPreferenceMapper, ReceiptPreference> {
/**
* 复制盘点首选项表
*
* @param warehouseCode 原仓库编码
* @param newWarehouseCode 新仓库编码
* @return 是否复制成功
*/
@Transactional
public boolean receiptPreferenceCopy(String warehouseCode, String newWarehouseCode) {
log.trace("开始入库首选项表");
LambdaQueryWrapper<ReceiptPreference> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ReceiptPreference::getWarehouseCode, newWarehouseCode);
if (!this.list(lambdaQueryWrapper).isEmpty()){
log.error(newWarehouseCode+"仓库已存在");
return false;
}
lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ReceiptPreference::getWarehouseCode, warehouseCode);
List<ReceiptPreference> receiptPreferenceList = this.list(lambdaQueryWrapper);
for ( ReceiptPreference receiptPreference : receiptPreferenceList) {
receiptPreference.setId(null);
receiptPreference.setWarehouseCode(newWarehouseCode);
}
if ( this.saveBatch(receiptPreferenceList) ){
log.trace("复制入库首选项表成功,新仓库编码是:"+newWarehouseCode);
return true;
} else {
return false;
}
}
}