package cn.stylefeng.guns.modular.em.equipmentStatus.service.impl; import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; import cn.stylefeng.guns.modular.em.equipmentStatus.entity.EquipmentStatus; import cn.stylefeng.guns.modular.em.equipmentStatus.mapper.EquipmentStatusMapper; import cn.stylefeng.guns.modular.em.equipmentStatus.model.params.EquipmentStatusParam; import cn.stylefeng.guns.modular.em.equipmentStatus.model.result.EquipmentStatusResult; import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; import cn.stylefeng.guns.sys.modular.system.service.DictService; import cn.stylefeng.guns.sys.modular.system.service.DictTypeService; import cn.stylefeng.roses.core.util.ToolUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.Serializable; import java.util.List; /** *

* 设备状态 服务实现类 *

* * @author cl * @since 2022-10-28 */ @Service public class EquipmentStatusServiceImpl extends ServiceImpl implements EquipmentStatusService { @Autowired DictTypeService typeService; @Override public void add(EquipmentStatusParam param){ EquipmentStatus entity = getEntity(param); this.save(entity); } @Override public void delete(EquipmentStatusParam param){ this.removeById(getKey(param)); } @Override public void update(EquipmentStatusParam param){ EquipmentStatus oldEntity = getOldEntity(param); EquipmentStatus newEntity = getEntity(param); ToolUtil.copyProperties(newEntity, oldEntity); this.updateById(newEntity); } @Override public EquipmentStatusResult findBySpec(EquipmentStatusParam param){ return null; } @Override public List findListBySpec(EquipmentStatusParam param){ return this.baseMapper.customList(param); } @Override public LayuiPageInfo findPageBySpec(EquipmentStatusParam param){ Page pageContext = getPageContext(); IPage page = this.baseMapper.customPageList(pageContext, param); List results = page.getRecords(); for (EquipmentStatusResult result : results) { switch(result.getStatus()) { case "1" : result.setStatus("运行"); break; case "2" : result.setStatus("待机"); break; case "3" : result.setStatus("报警"); break; default: } } return LayuiPageFactory.createPageInfo(page); } private Serializable getKey(EquipmentStatusParam param){ return param.getId(); } private Page getPageContext() { return LayuiPageFactory.defaultPage(); } private EquipmentStatus getOldEntity(EquipmentStatusParam param) { return this.getById(getKey(param)); } private EquipmentStatus getEntity(EquipmentStatusParam param) { EquipmentStatus entity = new EquipmentStatus(); ToolUtil.copyProperties(param, entity); return entity; } }