提交 | 用户 | 时间
|
7e21bc
|
1 |
package com.iailab.module.pms.coalquality.modules.detection.service.impl; |
J |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
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; |
8d3ff6
|
7 |
import com.iailab.framework.common.util.object.ConvertUtils; |
7e21bc
|
8 |
import com.iailab.module.pms.coalquality.modules.detection.dao.QualityDetectionDao; |
J |
9 |
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityDetectionDTO; |
|
10 |
import com.iailab.module.pms.coalquality.modules.detection.entity.QualityDetectionEntity; |
|
11 |
import com.iailab.module.pms.coalquality.modules.detection.service.QualityDetectionService; |
|
12 |
import com.iailab.module.pms.coalquality.modules.detection.vo.DetectionPageReqVO; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.springframework.stereotype.Service; |
|
15 |
import org.springframework.transaction.annotation.Transactional; |
|
16 |
import org.springframework.util.CollectionUtils; |
|
17 |
|
|
18 |
import java.util.Arrays; |
|
19 |
import java.util.Date; |
|
20 |
import java.util.HashMap; |
|
21 |
import java.util.Map; |
|
22 |
|
|
23 |
/** |
|
24 |
* 煤质检测 |
|
25 |
* |
|
26 |
* @author PanZhibao |
|
27 |
* @Description |
|
28 |
* @createTime 2023年02月07日 13:15:00 |
|
29 |
*/ |
|
30 |
@Service |
|
31 |
public class QualityDetectionServiceImpl extends BaseServiceImpl<QualityDetectionDao, QualityDetectionEntity> |
|
32 |
implements QualityDetectionService { |
|
33 |
|
|
34 |
private Map<String, String> prefixMap = new HashMap<>(); |
|
35 |
|
|
36 |
private String BUSINESS_CODE = "QualityDetection"; |
|
37 |
|
|
38 |
@Override |
|
39 |
public PageResult<QualityDetectionDTO> page(DetectionPageReqVO reqVO) { |
|
40 |
PageResult<QualityDetectionEntity> page = baseDao.selectPage(reqVO); |
|
41 |
|
|
42 |
return BeanUtils.toBean(page, QualityDetectionDTO.class); |
|
43 |
} |
|
44 |
|
|
45 |
|
|
46 |
@Override |
|
47 |
public QualityDetectionDTO get(String id) { |
|
48 |
QualityDetectionEntity entity = baseDao.selectById(id); |
|
49 |
|
|
50 |
return ConvertUtils.sourceToTarget(entity, QualityDetectionDTO.class); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public void save(QualityDetectionDTO dto) { |
|
55 |
if (CollectionUtils.isEmpty(prefixMap)) { |
|
56 |
prefixMap.put("ym", "10"); |
|
57 |
prefixMap.put("cpm", "20"); |
|
58 |
prefixMap.put("spm", "30"); |
|
59 |
} |
|
60 |
QualityDetectionEntity entity = ConvertUtils.sourceToTarget(dto, QualityDetectionEntity.class); |
8d3ff6
|
61 |
// entity.setCode(prefixMap.get(dto.getType()) + serialNumUtils.getByBusinessDate(BUSINESS_CODE + dto.getType(), dto.getRq(), 4)); |
7e21bc
|
62 |
entity.setCreateDate(new Date()); |
J |
63 |
// entity.setCreator(SecurityUser.getUserId().toString()); |
|
64 |
insert(entity); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public void update(QualityDetectionDTO dto) { |
|
69 |
QualityDetectionEntity entity = ConvertUtils.sourceToTarget(dto, QualityDetectionEntity.class); |
|
70 |
entity.setUpdateDate(new Date()); |
|
71 |
// entity.setUpdater(SecurityUser.getUserId().toString()); |
|
72 |
updateById(entity); |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
@Transactional(rollbackFor = Exception.class) |
|
77 |
public void delete(String[] ids) { |
|
78 |
baseDao.deleteByIds(Arrays.asList(ids)); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public Long cheack(QualityDetectionDTO dto) { |
|
83 |
String id = dto.getId(); |
|
84 |
String code = dto.getCode(); |
|
85 |
|
|
86 |
QueryWrapper<QualityDetectionEntity> queryWrapper = new QueryWrapper<>(); |
|
87 |
queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
|
88 |
queryWrapper.and(wrapper -> wrapper.eq("code", code)); |
|
89 |
return baseDao.selectCount(queryWrapper); |
|
90 |
} |
|
91 |
|
|
92 |
} |