shenyijian
2024-06-14 5def76eaa3392487784fdac7ba894eb185368747
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
package cn.gistack.sm.sg.service.impl;
 
import cn.gistack.sm.sg.DO.SgGxStepDO;
import cn.gistack.sm.sg.DTO.ProjectSearchDTO;
import cn.gistack.sm.sg.mapper.SgGxStepMapper;
import cn.gistack.sm.sg.service.SgGxStepService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
 
/**
 * <p>
 * 施工工序步骤表 服务实现类
 * </p>
 *
 * @author shenyijian
 * @since 2024-06-13 15:46:18
 */
@Service
public class SgGxStepServiceImpl extends ServiceImpl<SgGxStepMapper, SgGxStepDO> implements SgGxStepService {
    @Autowired
    private SgGxStepMapper sgGxStepMapper;
    @Override
    public void add(SgGxStepDO sgGxStepDO) {
    List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
    if (CollectionUtils.isNotEmpty(list)){
        if (Integer.parseInt(sgGxStepDO.getGxStepNum()) - Integer.parseInt(list.get(0).getGxStepNum()) != 1){
            throw  new ServiceException("请按顺序配置工序");
        }
    }
    this.save(sgGxStepDO);
    }
 
    @Override
    public void updateOne(SgGxStepDO sgGxStepDO) {
        this.updateById(sgGxStepDO);
    }
 
    @Override
    public void delete(String id) {
        SgGxStepDO sgGxStepDO = sgGxStepMapper.selectById(id);
        List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
        if (!sgGxStepDO.getGxStepNum().equals(list.get(0).getGxStepNum())){
            throw  new ServiceException("请按顺序删除工序步骤");
        }
        this.removeById(id);
    }
 
    @Override
    public IPage<SgGxStepDO> queryPageList(IPage<SgGxStepDO> page, ProjectSearchDTO searchDTO) {
        List<SgGxStepDO> list =  sgGxStepMapper.queryPageList(page,searchDTO);
        return page.setRecords(list);
    }
}