提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.modular.em.equipmentStatus.service.impl; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; |
|
4 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
5 |
import cn.stylefeng.guns.modular.em.equipmentStatus.entity.EquipmentStatus; |
|
6 |
import cn.stylefeng.guns.modular.em.equipmentStatus.mapper.EquipmentStatusMapper; |
|
7 |
import cn.stylefeng.guns.modular.em.equipmentStatus.model.params.EquipmentStatusParam; |
|
8 |
import cn.stylefeng.guns.modular.em.equipmentStatus.model.result.EquipmentStatusResult; |
|
9 |
import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
|
10 |
import cn.stylefeng.guns.sys.modular.system.service.DictService; |
|
11 |
import cn.stylefeng.guns.sys.modular.system.service.DictTypeService; |
|
12 |
import cn.stylefeng.roses.core.util.ToolUtil; |
|
13 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
14 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
15 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.stereotype.Service; |
|
18 |
|
|
19 |
import java.io.Serializable; |
|
20 |
import java.util.List; |
|
21 |
|
|
22 |
/** |
|
23 |
* <p> |
|
24 |
* 设备状态 服务实现类 |
|
25 |
* </p> |
|
26 |
* |
|
27 |
* @author cl |
|
28 |
* @since 2022-10-28 |
|
29 |
*/ |
|
30 |
@Service |
|
31 |
public class EquipmentStatusServiceImpl extends ServiceImpl<EquipmentStatusMapper, EquipmentStatus> implements EquipmentStatusService { |
|
32 |
@Autowired |
|
33 |
DictTypeService typeService; |
|
34 |
|
|
35 |
@Override |
|
36 |
public void add(EquipmentStatusParam param){ |
|
37 |
EquipmentStatus entity = getEntity(param); |
|
38 |
this.save(entity); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public void delete(EquipmentStatusParam param){ |
|
43 |
this.removeById(getKey(param)); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void update(EquipmentStatusParam param){ |
|
48 |
EquipmentStatus oldEntity = getOldEntity(param); |
|
49 |
EquipmentStatus newEntity = getEntity(param); |
|
50 |
ToolUtil.copyProperties(newEntity, oldEntity); |
|
51 |
this.updateById(newEntity); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public EquipmentStatusResult findBySpec(EquipmentStatusParam param){ |
|
56 |
return null; |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public List<EquipmentStatusResult> findListBySpec(EquipmentStatusParam param){ |
|
61 |
return this.baseMapper.customList(param); |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public LayuiPageInfo findPageBySpec(EquipmentStatusParam param){ |
|
66 |
Page pageContext = getPageContext(); |
|
67 |
IPage page = this.baseMapper.customPageList(pageContext, param); |
|
68 |
List<EquipmentStatusResult> results = page.getRecords(); |
|
69 |
for (EquipmentStatusResult result : results) { |
|
70 |
switch(result.getStatus()) { |
|
71 |
case "1" : |
|
72 |
result.setStatus("运行"); |
|
73 |
break; |
|
74 |
case "2" : |
|
75 |
result.setStatus("待机"); |
|
76 |
break; |
|
77 |
case "3" : |
|
78 |
result.setStatus("报警"); |
|
79 |
break; |
|
80 |
default: |
|
81 |
} |
|
82 |
|
|
83 |
} |
|
84 |
return LayuiPageFactory.createPageInfo(page); |
|
85 |
} |
|
86 |
|
|
87 |
private Serializable getKey(EquipmentStatusParam param){ |
|
88 |
return param.getId(); |
|
89 |
} |
|
90 |
|
|
91 |
private Page getPageContext() { |
|
92 |
return LayuiPageFactory.defaultPage(); |
|
93 |
} |
|
94 |
|
|
95 |
private EquipmentStatus getOldEntity(EquipmentStatusParam param) { |
|
96 |
return this.getById(getKey(param)); |
|
97 |
} |
|
98 |
|
|
99 |
private EquipmentStatus getEntity(EquipmentStatusParam param) { |
|
100 |
EquipmentStatus entity = new EquipmentStatus(); |
|
101 |
ToolUtil.copyProperties(param, entity); |
|
102 |
return entity; |
|
103 |
} |
|
104 |
|
|
105 |
} |