ConstructionTeamServiceImpl.java
3.84 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
80
81
82
83
84
85
86
package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.text.StrUtil;
import org.springframework.stereotype.Service;
import vion.dto.ConstructionTeamDTO;
import vion.dto.RContractTeamDTO;
import vion.mapper.ConstructionTeamMapper;
import vion.model.ConstructionTeam;
import vion.model.Contract;
import vion.model.RContractTeam;
import vion.service.IConstructionTeamService;
import vion.service.IRContractTeamService;
import vion.vo.ConstructionTeamVO;
import vion.vo.RContractTeamVO;
import java.util.List;
/**
* @author vion
* @date 2023/12/26
*/
@Service
@RequiredArgsConstructor
public class ConstructionTeamServiceImpl extends MPJBaseServiceImpl<ConstructionTeamMapper, ConstructionTeam> implements IConstructionTeamService {
private final IRContractTeamService contractTeamService;
private final Converter converter;
@Override
public Page<ConstructionTeamVO> list(ConstructionTeamDTO dto) {
Page<ConstructionTeam> constructionTeamList = this.lambdaQuery(converter.convert(dto, ConstructionTeam.class))
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<ConstructionTeamVO> voList = converter.convert(constructionTeamList.getRecords(), ConstructionTeamVO.class);
return Page.<ConstructionTeamVO>of(constructionTeamList.getCurrent(), constructionTeamList.getSize(), constructionTeamList.getTotal()).setRecords(voList);
}
@Override
public ConstructionTeamVO getVOById(Long id) {
return converter.convert(this.getById(id), ConstructionTeamVO.class);
}
@Override
public Object save(ConstructionTeamDTO dto) {
ConstructionTeam constructionTeam = converter.convert(dto, ConstructionTeam.class);
return this.save(constructionTeam) ? constructionTeam.getId() : "新增失败";
}
@Override
public String updateById(ConstructionTeamDTO dto) {
ConstructionTeam constructionTeam = converter.convert(dto, ConstructionTeam.class);
return this.updateById(constructionTeam) ? "更新成功" : "更新失败";
}
@Override
public Page<RContractTeamVO> list(RContractTeamDTO dto) {
var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, RContractTeam.class))
.selectAll(RContractTeam.class)
.selectAs(Contract::getContractNo, RContractTeamVO::getContractNo)
.selectAs(Contract::getName, RContractTeamVO::getContractName)
.selectAs(Contract::getStatus, RContractTeamVO::getContractStatus)
.selectAs(ConstructionTeam::getName, RContractTeamVO::getTeamName)
.leftJoin(Contract.class, Contract::getId, RContractTeam::getContractId)
.leftJoin(ConstructionTeam.class, ConstructionTeam::getId, RContractTeam::getCtId)
.like(StrUtil.isNotBlank(dto.getContractNo()), Contract::getContractNo, dto.getContractNo())
.like(StrUtil.isNotBlank(dto.getContractName()), Contract::getName, dto.getContractName())
.orderByAsc(RContractTeam::getStatus)
.orderByDesc(RContractTeam::getCreateTime);
return contractTeamService.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), RContractTeamVO.class, wrapper);
}
@Override
public String assignTeam(RContractTeamDTO dto) {
RContractTeam rContractTeam = converter.convert(dto, RContractTeam.class);
return contractTeamService.updateById(rContractTeam) ? "分配施工队成功。" : "分配施工队失败";
}
@Override
public String delContractTeamById(Long id) {
return contractTeamService.removeById(id) ? "删除成功" : "删除失败";
}
}