提交 | 用户 | 时间
|
7e21bc
|
1 |
package com.iailab.module.pms.coalquality.modules.analysis.service.impl; |
J |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.iailab.framework.common.constant.Constant; |
|
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; |
|
8 |
import com.iailab.framework.common.util.object.ConvertUtils; |
|
9 |
import com.iailab.framework.tenant.core.aop.TenantIgnore; |
|
10 |
import com.iailab.module.pms.coalquality.modules.analysis.dao.CoalWashCurvesDao; |
|
11 |
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesDTO; |
|
12 |
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesDetDTO; |
|
13 |
import com.iailab.module.pms.coalquality.modules.analysis.entity.CoalWashCurvesEntity; |
|
14 |
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesDetService; |
|
15 |
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesService; |
|
16 |
import com.iailab.module.pms.coalquality.modules.analysis.vo.WashCurvesPageReqVO; |
|
17 |
import org.apache.commons.lang3.StringUtils; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.stereotype.Service; |
|
20 |
import org.springframework.transaction.annotation.Transactional; |
|
21 |
import org.springframework.util.CollectionUtils; |
|
22 |
|
|
23 |
import java.text.DecimalFormat; |
|
24 |
import java.util.*; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author PanZhibao |
|
28 |
* @Description |
|
29 |
* @createTime 2023年01月16日 15:58:00 |
|
30 |
*/ |
|
31 |
@Service |
|
32 |
public class CoalWashCurvesServiceImpl extends BaseServiceImpl<CoalWashCurvesDao, CoalWashCurvesEntity> |
|
33 |
implements CoalWashCurvesService { |
|
34 |
@Autowired |
|
35 |
private CoalWashCurvesDetService coalWashCurvesDetService; |
|
36 |
|
|
37 |
private DecimalFormat df = new DecimalFormat("00"); |
|
38 |
|
|
39 |
private String BUSINESS_CODE = "CoalWashCurves"; |
|
40 |
|
|
41 |
@Override |
|
42 |
@TenantIgnore |
|
43 |
public PageResult<CoalWashCurvesDTO> page(WashCurvesPageReqVO washCurvesPageReqVO) { |
|
44 |
PageResult<CoalWashCurvesEntity> page = baseDao.selectPage(washCurvesPageReqVO); |
|
45 |
|
|
46 |
return BeanUtils.toBean(page, CoalWashCurvesDTO.class); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public CoalWashCurvesDTO get(String id) { |
|
51 |
CoalWashCurvesEntity entity = baseDao.selectById(id); |
|
52 |
CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class); |
|
53 |
Map<String, Object> parmas = new HashMap<>(1); |
|
54 |
parmas.put("curvesId", dto.getId()); |
|
55 |
List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas); |
|
56 |
dto.setDetList(detList); |
|
57 |
return dto; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public CoalWashCurvesDTO getLastByMz(String mz) { |
|
62 |
// if (StringUtils.isBlank(mz)) { |
|
63 |
// return new CoalWashCurvesDTO(); |
|
64 |
// } |
|
65 |
QueryWrapper<CoalWashCurvesEntity> wrapper = new QueryWrapper<>(); |
|
66 |
wrapper.eq(StringUtils.isNotBlank(mz), "mz", mz).orderByDesc(Constant.CREATE_DATE).last("limit 0, 1"); |
|
67 |
List<CoalWashCurvesEntity> list = baseDao.selectList(wrapper); |
|
68 |
if (CollectionUtils.isEmpty(list)) { |
|
69 |
return null; |
|
70 |
} |
|
71 |
|
|
72 |
CoalWashCurvesEntity entity = list.get(0); |
|
73 |
CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class); |
|
74 |
Map<String, Object> parmas = new HashMap<>(1); |
|
75 |
parmas.put("curvesId", dto.getId()); |
|
76 |
List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas); |
|
77 |
dto.setDetList(detList); |
|
78 |
return dto; |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public CoalWashCurvesDTO getByMzAndRq(String mz, String syrq) { |
|
83 |
// if (StringUtils.isBlank(mz)) { |
|
84 |
// return new CoalWashCurvesDTO(); |
|
85 |
// } |
|
86 |
QueryWrapper<CoalWashCurvesEntity> wrapper = new QueryWrapper<>(); |
|
87 |
wrapper.eq(StringUtils.isNotBlank(mz), "mz", mz) |
|
88 |
.eq(StringUtils.isNotBlank(syrq),"syrq",syrq); |
|
89 |
List<CoalWashCurvesEntity> list = baseDao.selectList(wrapper); |
|
90 |
if (CollectionUtils.isEmpty(list)) { |
|
91 |
return null; |
|
92 |
} |
|
93 |
|
|
94 |
CoalWashCurvesEntity entity = list.get(0); |
|
95 |
CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class); |
|
96 |
Map<String, Object> parmas = new HashMap<>(1); |
|
97 |
parmas.put("curvesId", dto.getId()); |
|
98 |
List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas); |
|
99 |
dto.setDetList(detList); |
|
100 |
return dto; |
|
101 |
} |
|
102 |
@Override |
|
103 |
@Transactional(rollbackFor = Exception.class) |
|
104 |
public void save(CoalWashCurvesDTO dto) { |
|
105 |
// String a = serialNumUtils.getByBusiness( BUSINESS_CODE,4); |
|
106 |
dto.setCode(dto.getNy().replace("-", "") ); |
|
107 |
CoalWashCurvesEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesEntity.class); |
|
108 |
entity.setId(UUID.randomUUID().toString()); |
|
109 |
entity.setCreateDate(new Date()); |
|
110 |
// entity.setCreator(SecurityUser.getUserId().toString()); |
|
111 |
insert(entity); |
|
112 |
|
|
113 |
List<CoalWashCurvesDetDTO> detList = dto.getDetList(); |
|
114 |
// if (!CollectionUtils.isEmpty(detList)) { |
|
115 |
// for (int i = 0; i < detList.size(); i++) { |
|
116 |
// detList.get(i).setCode(entity.getCode() + df.format(i + 1)); |
|
117 |
// detList.get(i).setCurvesId(entity.getId()); |
|
118 |
// } |
|
119 |
// coalWashCurvesDetService.saveList(detList); |
|
120 |
// } |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
@Transactional(rollbackFor = Exception.class) |
|
125 |
public void update(CoalWashCurvesDTO dto) { |
|
126 |
CoalWashCurvesEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesEntity.class); |
|
127 |
entity.setUpdateDate(new Date()); |
|
128 |
// entity.setUpdater(SecurityUser.getUserId().toString()); |
|
129 |
updateById(entity); |
|
130 |
|
|
131 |
List<CoalWashCurvesDetDTO> detList = dto.getDetList(); |
|
132 |
// if (!CollectionUtils.isEmpty(detList)) { |
|
133 |
// detList.forEach(item -> { |
|
134 |
// item.setCurvesId(entity.getId()); |
|
135 |
// }); |
|
136 |
// coalWashCurvesDetService.updateList(detList); |
|
137 |
// } |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
@Transactional(rollbackFor = Exception.class) |
|
142 |
public void delete(String[] ids) { |
|
143 |
baseDao.deleteByIds(Arrays.asList(ids)); |
|
144 |
// coalWashCurvesDetService.deleteByCurvesIds(Arrays.asList(ids)); |
|
145 |
} |
|
146 |
|
|
147 |
} |