提交 | 用户 | 时间
|
7e21bc
|
1 |
package com.iailab.module.pms.coalquality.modules.detection.service.impl; |
J |
2 |
|
|
3 |
|
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
6 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
7 |
import com.iailab.framework.common.util.object.ConvertUtils; |
|
8 |
import com.iailab.module.pms.coalquality.modules.detection.dao.QualityQuickDao; |
|
9 |
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityQuickDTO; |
|
10 |
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityQuickItemDTO; |
|
11 |
import com.iailab.module.pms.coalquality.modules.detection.entity.QualityQuickEntity; |
|
12 |
import com.iailab.module.pms.coalquality.modules.detection.service.QualityQuickItemService; |
|
13 |
import com.iailab.module.pms.coalquality.modules.detection.service.QualityQuickService; |
|
14 |
import com.iailab.module.pms.coalquality.modules.detection.vo.QuickPageReqVO; |
|
15 |
import lombok.extern.slf4j.Slf4j; |
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.stereotype.Service; |
|
18 |
import org.springframework.transaction.annotation.Transactional; |
|
19 |
|
|
20 |
import java.util.Arrays; |
|
21 |
import java.util.HashMap; |
|
22 |
import java.util.List; |
|
23 |
import java.util.Map; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author DongYukun |
|
27 |
* @Description |
|
28 |
* @createTime 2023年12月27日 9:53:00 |
|
29 |
*/ |
|
30 |
@Slf4j |
|
31 |
@Service |
|
32 |
public class QualityQuickServiceImpl extends BaseServiceImpl<QualityQuickDao, QualityQuickEntity> |
|
33 |
implements QualityQuickService { |
|
34 |
|
|
35 |
private String BUSINESS_CODE = "QualityQuick"; |
|
36 |
|
|
37 |
@Autowired |
|
38 |
private QualityQuickItemService qualityQuickItemService; |
|
39 |
|
|
40 |
@Override |
|
41 |
public PageResult<QualityQuickDTO> page(QuickPageReqVO reqVO) { |
|
42 |
PageResult<QualityQuickEntity> page = baseDao.selectPage(reqVO); |
|
43 |
|
|
44 |
return BeanUtils.toBean(page, QualityQuickDTO.class); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public QualityQuickDTO get(String id) { |
|
49 |
QualityQuickEntity entity = baseDao.selectById(id); |
|
50 |
QualityQuickDTO dto = ConvertUtils.sourceToTarget(entity, QualityQuickDTO.class); |
|
51 |
Map<String, Object> parmas = new HashMap<>(1); |
|
52 |
parmas.put("lsh", dto.getLsh()); |
|
53 |
List<QualityQuickItemDTO> itemList = qualityQuickItemService.queryList(parmas); |
|
54 |
dto.setItemList(itemList); |
|
55 |
return dto; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public void save(QualityQuickDTO dto) { |
8d3ff6
|
60 |
//dto.setLsh(serialNumUtils.getByBusinessDate(BUSINESS_CODE, dto.getDatetime(), 4)); |
7e21bc
|
61 |
QualityQuickEntity entity = ConvertUtils.sourceToTarget(dto, QualityQuickEntity.class); |
J |
62 |
insert(entity); |
|
63 |
dto.getItemList().stream().forEach( |
|
64 |
item->{ |
|
65 |
item.setLsh(dto.getLsh()); |
|
66 |
qualityQuickItemService.save(item); |
|
67 |
} |
|
68 |
); |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void update(QualityQuickDTO dto) { |
|
73 |
QualityQuickEntity entity = ConvertUtils.sourceToTarget(dto, QualityQuickEntity.class); |
|
74 |
updateById(entity); |
|
75 |
qualityQuickItemService.deleteByLsh(dto.getLsh()); |
|
76 |
|
|
77 |
dto.getItemList().forEach( |
|
78 |
item->{ |
|
79 |
item.setLsh(dto.getLsh()); |
|
80 |
qualityQuickItemService.save(item); |
|
81 |
} |
|
82 |
); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
@Transactional(rollbackFor = Exception.class) |
|
88 |
public void delete(String[] ids) { |
|
89 |
QualityQuickEntity dto = baseDao.selectById(ids[0]); |
|
90 |
baseDao.deleteByIds(Arrays.asList(ids)); |
|
91 |
qualityQuickItemService.deleteByLsh(dto.getLsh()); |
|
92 |
} |
|
93 |
|
|
94 |
|
|
95 |
} |