提交 | 用户 | 时间
|
e41062
|
1 |
package com.iailab.module.data.ind.item.service.impl; |
潘 |
2 |
|
68413a
|
3 |
import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
cf757d
|
4 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
e41062
|
5 |
import com.iailab.framework.common.pojo.PageResult; |
潘 |
6 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
7 |
import com.iailab.framework.common.util.object.BeanUtils; |
68413a
|
8 |
import com.iailab.module.data.common.enums.ItemTypeEnum; |
e41062
|
9 |
import com.iailab.module.data.ind.item.dao.IndItemDao; |
68413a
|
10 |
import com.iailab.module.data.ind.item.entity.IndItemAtomEntity; |
J |
11 |
import com.iailab.module.data.ind.item.entity.IndItemCalEntity; |
|
12 |
import com.iailab.module.data.ind.item.entity.IndItemDerEntity; |
e41062
|
13 |
import com.iailab.module.data.ind.item.entity.IndItemEntity; |
68413a
|
14 |
import com.iailab.module.data.ind.item.service.IndItemAtomService; |
e41062
|
15 |
import com.iailab.module.data.ind.item.service.IndItemService; |
潘 |
16 |
import com.iailab.module.data.ind.item.vo.IndItemPageReqVO; |
68413a
|
17 |
import com.iailab.module.data.ind.item.vo.IndItemRespVO; |
e41062
|
18 |
import com.iailab.module.data.ind.item.vo.IndItemSaveReqVO; |
68413a
|
19 |
import com.iailab.module.data.point.common.IncreaseCodeEnum; |
J |
20 |
import com.iailab.module.data.point.service.DaSequenceNumService; |
|
21 |
import org.springframework.beans.factory.annotation.Autowired; |
e41062
|
22 |
import org.springframework.stereotype.Service; |
潘 |
23 |
|
|
24 |
import java.util.Date; |
68413a
|
25 |
import java.util.List; |
e41062
|
26 |
import java.util.UUID; |
潘 |
27 |
|
|
28 |
/** |
|
29 |
* @author PanZhibao |
|
30 |
* @Description |
|
31 |
* @createTime 2024年09月11日 |
|
32 |
*/ |
|
33 |
@Service |
|
34 |
public class IndItemServiceImpl extends BaseServiceImpl<IndItemDao, IndItemEntity> implements IndItemService { |
|
35 |
|
68413a
|
36 |
@Autowired |
J |
37 |
private IndItemAtomService indItemAtomService; |
|
38 |
|
|
39 |
@Autowired |
|
40 |
private IndItemDerServiceImpl indItemDerServiceImpl; |
|
41 |
|
|
42 |
@Autowired |
|
43 |
private IndItemCalServiceImpl indItemCalServiceImpl; |
|
44 |
|
|
45 |
@Autowired |
|
46 |
private DaSequenceNumService daSequenceNumService; |
cf757d
|
47 |
|
e41062
|
48 |
@Override |
潘 |
49 |
public PageResult<IndItemEntity> page(IndItemPageReqVO reqVO) { |
|
50 |
return baseDao.selectPage(reqVO); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
cf757d
|
54 |
@DSTransactional(rollbackFor = Exception.class) |
e41062
|
55 |
public void create(IndItemSaveReqVO createReqVO) { |
潘 |
56 |
IndItemEntity entity = BeanUtils.toBean(createReqVO, IndItemEntity.class); |
|
57 |
entity.setId(UUID.randomUUID().toString()); |
68413a
|
58 |
|
cf757d
|
59 |
if (ItemTypeEnum.ATOM.getCode().equals(createReqVO.getItemType())) { |
68413a
|
60 |
IndItemAtomEntity atomEntity = BeanUtils.toBean(createReqVO.getAtomItem(), IndItemAtomEntity.class); |
J |
61 |
atomEntity.setId(UUID.randomUUID().toString()); |
|
62 |
atomEntity.setItemId(entity.getId()); |
|
63 |
indItemAtomService.insert(atomEntity); |
|
64 |
entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.IND_A.name())); |
cf757d
|
65 |
} else if (ItemTypeEnum.DER.getCode().equals(createReqVO.getItemType())) { |
68413a
|
66 |
IndItemDerEntity derEntity = BeanUtils.toBean(createReqVO.getDerItem(), IndItemDerEntity.class); |
J |
67 |
derEntity.setId(UUID.randomUUID().toString()); |
|
68 |
derEntity.setItemId(entity.getId()); |
|
69 |
indItemDerServiceImpl.insert(derEntity); |
|
70 |
entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.IND_D.name())); |
cf757d
|
71 |
} else if (ItemTypeEnum.CAL.getCode().equals(createReqVO.getItemType())) { |
68413a
|
72 |
IndItemCalEntity calEntity = BeanUtils.toBean(createReqVO.getCalItem(), IndItemCalEntity.class); |
J |
73 |
calEntity.setId(UUID.randomUUID().toString()); |
|
74 |
calEntity.setItemId(entity.getId()); |
|
75 |
indItemCalServiceImpl.insert(calEntity); |
|
76 |
entity.setItemNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.IND_C.name())); |
|
77 |
} |
e41062
|
78 |
entity.setCreateTime(new Date()); |
潘 |
79 |
baseDao.insert(entity); |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
cf757d
|
83 |
@DSTransactional(rollbackFor = Exception.class) |
e41062
|
84 |
public void update(IndItemSaveReqVO updateReqVO) { |
潘 |
85 |
IndItemEntity entity = BeanUtils.toBean(updateReqVO, IndItemEntity.class); |
|
86 |
entity.setUpdateTime(new Date()); |
015227
|
87 |
if (ItemTypeEnum.ATOM.getCode().equals(updateReqVO.getItemType())) { |
J |
88 |
IndItemAtomEntity atomEntity = BeanUtils.toBean(updateReqVO.getAtomItem(), IndItemAtomEntity.class); |
|
89 |
indItemAtomService.updateById(atomEntity); |
|
90 |
} else if (ItemTypeEnum.DER.getCode().equals(updateReqVO.getItemType())) { |
|
91 |
IndItemDerEntity derEntity = BeanUtils.toBean(updateReqVO.getDerItem(), IndItemDerEntity.class); |
|
92 |
indItemDerServiceImpl.updateById(derEntity); |
|
93 |
} else if (ItemTypeEnum.CAL.getCode().equals(updateReqVO.getItemType())) { |
|
94 |
IndItemCalEntity calEntity = BeanUtils.toBean(updateReqVO.getCalItem(), IndItemCalEntity.class); |
|
95 |
indItemCalServiceImpl.updateById(calEntity); |
|
96 |
} |
e41062
|
97 |
baseDao.updateById(entity); |
潘 |
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
public IndItemEntity get(String id) { |
|
102 |
return baseDao.selectById(id); |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
cf757d
|
106 |
public IndItemEntity getInfoByNo(String no) { |
潘 |
107 |
QueryWrapper<IndItemEntity> queryWrapper = new QueryWrapper<>(); |
|
108 |
queryWrapper.eq("item_no", no); |
|
109 |
return baseDao.selectOne(queryWrapper); |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
@DSTransactional(rollbackFor = Exception.class) |
e41062
|
114 |
public void delete(String id) { |
68413a
|
115 |
IndItemEntity entity = get(id); |
cf757d
|
116 |
if (ItemTypeEnum.ATOM.getCode().equals(entity.getItemType())) { |
68413a
|
117 |
indItemAtomService.deleteByItemId(id); |
cf757d
|
118 |
} else if (ItemTypeEnum.DER.getCode().equals(entity.getItemType())) { |
68413a
|
119 |
indItemDerServiceImpl.deleteByItemId(id); |
cf757d
|
120 |
} else if (ItemTypeEnum.CAL.getCode().equals(entity.getItemType())) { |
68413a
|
121 |
indItemCalServiceImpl.deleteByItemId(id); |
J |
122 |
} |
e41062
|
123 |
baseDao.deleteById(id); |
潘 |
124 |
} |
68413a
|
125 |
|
J |
126 |
@Override |
|
127 |
public List<IndItemRespVO> getList(IndItemPageReqVO reqVO) { |
|
128 |
return baseDao.getItemList(reqVO); |
|
129 |
} |
e41062
|
130 |
} |