ke
2024-07-19 08a962d2925baa255207fdf979e6fee794f1773b
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package cn.gistack.sm.sg.service.impl;
 
import cn.gistack.sm.sg.DO.SgDeviceDO;
import cn.gistack.sm.sg.DO.SgGxStepDO;
import cn.gistack.sm.sg.DO.SgProgressReportDO;
import cn.gistack.sm.sg.DTO.SgDeviceSearchDTO;
import cn.gistack.sm.sg.mapper.SgDeviceMapper;
import cn.gistack.sm.sg.mapper.SgGxStepMapper;
import cn.gistack.sm.sg.mapper.SgProgressReportMapper;
import cn.gistack.sm.sg.service.SgDeviceService;
import org.springblade.core.log.exception.ServiceException;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
/**
 * <p>
 * 施工项目子设备 服务实现类
 * </p>
 *
 * @author shenyijian
 * @since 2024-06-13 11:51:20
 */
@Service
public class SgDeviceServiceImpl extends ServiceImpl<SgDeviceMapper, SgDeviceDO> implements SgDeviceService {
    @Autowired
    private SgGxStepMapper sgGxStepMapper;
 
    @Autowired
    private SgProgressReportMapper sgProgressReportMapper;
 
 
    @Override
    public IPage<SgDeviceDO> queryPageList(IPage<SgDeviceDO> page, SgDeviceSearchDTO searchDTO) {
        List<SgDeviceDO> sgDeviceDOS = baseMapper.queryPageList(page,searchDTO);
        return page.setRecords(sgDeviceDOS);
    }
 
    /**
     * 根据项目id查询下下面的设备list
     *
     * @param programId
     * @return
     */
    @Override
    public List<SgDeviceDO> getDeviceList(String programId) {
        List<SgDeviceDO> list = new ArrayList<>();
        QueryWrapper<SgDeviceDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("program_id", programId);
        SgDeviceDO sg1 = new SgDeviceDO();
        sg1.setId((long) 999);
        sg1.setDeviceName("施工准备");
        sg1.setDeviceType("sgzb");
        sg1.setStatus(0);
        list.add(sg1);
 
        List<SgDeviceDO> sgDeviceDOS = baseMapper.selectList(queryWrapper);
        if (CollectionUtils.isNotEmpty(sgDeviceDOS)) {
            list.addAll(sgDeviceDOS);
        }
 
        SgDeviceDO sg2 = new SgDeviceDO();
        sg2.setId((long) 998);
        sg2.setDeviceName("施工验收");
        sg2.setDeviceType("sgys");
        sg2.setStatus(0);
        list.add(sg2);
 
        return list;
    }
 
    @Override
    public SgDeviceDO getSgDeviceById(String id) {
        return baseMapper.getSgDeviceById(id);
    }
 
    @Override
    public List<SgGxStepDO> queryStepList(String deviceId) {
        if(deviceId.equals("998")){
            return sgGxStepMapper.queryStepLists("sgys");
        }else if (deviceId.equals("999")){
            return sgGxStepMapper.queryStepLists("sgzb");
        }
        List<SgGxStepDO> sgGxStepDOS = sgGxStepMapper.queryStepList(deviceId);
        return sgGxStepDOS;
    }
 
    @Override
    public boolean saveById(SgDeviceDO sgDeviceDO) {
        QueryWrapper<SgProgressReportDO> queryWrapper = new QueryWrapper<>();
        SgProgressReportDO sgProgressReportDO = sgProgressReportMapper.selectOne(queryWrapper.eq("profram_id", sgDeviceDO.getProgramId()).eq("gx_step_id",26));
        if (sgProgressReportDO != null) {
            if(sgProgressReportDO.getStatus().equals(2)){
                throw new ServiceException("施工验收完成不能增加设备");
            }
        }
 
        return save(sgDeviceDO);
    }
}