whycxzp
2021-03-29 bdd37ecd210e60021179e4e11719425a478731fd
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.mapper.DeviceMaintainMapper;
import com.whyc.pojo.DeviceMaintain;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Service
public class DeviceMaintainService {
 
    @Resource
    private DeviceMaintainMapper mapper;
 
    public Response get(Integer deviceId) {
        QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.eq("status",1).eq("device_id",deviceId);
        DeviceMaintain deviceMaintain = mapper.selectOne(wrapper);
        return new Response().set(1,deviceMaintain);
    }
 
    public Response add(DeviceMaintain deviceMaintain) {
        mapper.insert(deviceMaintain);
        return new Response().set(1,"创建成功");
    }
 
    public Response update(DeviceMaintain deviceMaintain) {
        mapper.updateById(deviceMaintain);
        return new Response().set(1,"修改成功");
    }
 
    public Response confirm(DeviceMaintain deviceMaintain) {
        //确认维护,维护状态更新为0
        deviceMaintain.setStatus(0);
        deviceMaintain.setActualTime(new Date());
        mapper.updateById(deviceMaintain);
        return new Response().set(1,"确认成功");
    }
 
    public Response getRecord(Integer deviceId) {
        QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.select("actual_time","actual_owner2","content").eq("status",0).eq("device_id",deviceId);
        List<DeviceMaintain> deviceMaintains = mapper.selectList(wrapper);
        return new Response().set(1,deviceMaintains);
    }
 
    public Response getPage(Integer pageNum, Integer pageSize) {
        QueryWrapper<Object> wrapper = Wrappers.query();
        return null;
    }
}