ICSITEMLotService.java
3.25 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.huaheng.pc.srm.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.api.srm.domain.SRMResult;
import com.huaheng.common.exception.RunFailException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.srm.domain.ICSITEMLot;
import com.huaheng.pc.srm.mapper.ICSITEMlotMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Service
public class ICSITEMLotService extends ServiceImpl<ICSITEMlotMapper, ICSITEMLot> {
@Resource
RunFailException runFailException;
@Resource
private MaterialService materialService;
public List<ICSITEMLot> selectList(ICSITEMLot icsitemLot){
LambdaQueryWrapper<ICSITEMLot> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StringUtils.isNotEmpty(icsitemLot.getLotNO()),ICSITEMLot::getLotNO,icsitemLot.getLotNO());
return this.list(queryWrapper);
}
public ICSITEMLot selectFirstModel(ICSITEMLot icsitemLot){
LambdaQueryWrapper<ICSITEMLot> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StringUtils.isNotEmpty(icsitemLot.getLotNO()),ICSITEMLot::getLotNO,icsitemLot.getLotNO());
queryWrapper.last("limit 1");
return this.getOne(queryWrapper);
}
/**
* 获取物料条码
*
* @param icsitemLotList
* @return
*/
@Transactional(rollbackFor = Exception.class)
public SRMResult saveICSItemLotList(List<ICSITEMLot> icsitemLotList) {
SRMResult srmResult = new SRMResult();
ICSITEMLot queryIcsitemLot = new ICSITEMLot();
for (ICSITEMLot icsitemLot : icsitemLotList) {
if(StringUtils.isEmpty(icsitemLot.getItemCode())){
return srmResult.error("物料不存在");
}
Material material = materialService.getMaterialByCode(icsitemLot.getItemCode());
if(material == null){
runFailException.sendException("ID为:"+icsitemLot.getID()+"的物料条码在wms不存在");
return srmResult.error("ID为:"+icsitemLot.getID()+"的物料条码在wms不存在");
}
queryIcsitemLot.setLotNO(icsitemLot.getLotNO());
if (this.selectList(queryIcsitemLot).size()!=0){
if(!this.updateById(icsitemLot)){
runFailException.sendException("ID为:"+icsitemLot.getID()+"的物料条码更新失败");
return srmResult.error("ID为:"+icsitemLot.getID()+"的物料条码更新失败");
}
}else {
if (!this.save(icsitemLot)){
runFailException.sendException("ID为:"+icsitemLot.getID()+"的物料条码插入失败");
return srmResult.error("ID为:"+icsitemLot.getID()+"的物料条码插入失败");
}
}
}
return srmResult.success("物料条码列表插入成功");
}
}