package com.iailab.module.device.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.service.impl.CrudServiceImpl; import com.iailab.module.device.dao.DeviceHealthStateDao; import com.iailab.module.device.dto.DeviceHealthStateDTO; import com.iailab.module.device.entity.DeviceHealthStateEntity; import com.iailab.module.device.service.DeviceInfoService; import com.iailab.module.device.service.DeviceHealthEvaluateService; import com.iailab.module.device.service.DeviceHealthStateService; import org.apache.commons.lang3.StringUtils; import javax.annotation.Resource; import org.springframework.stereotype.Service; import java.util.Map; /** * 设备健康状态表 * * @author lirm ${email} * @since 1.0.0 2024-05-22 */ @Service public class DeviceHealthStateServiceImpl extends CrudServiceImpl implements DeviceHealthStateService { @Resource DeviceHealthEvaluateService deviceHealthEvaluateService; @Resource DeviceInfoService deviceInfoService; @Override public QueryWrapper getWrapper(Map params){ String id = (String)params.get("id"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), "id", id); return wrapper; } @Override public void insertHealthState(Map tMap) { int normal = Integer.parseInt(tMap.get("normal").toString()); int common = Integer.parseInt(tMap.get("common").toString()); int heavy = Integer.parseInt(tMap.get("heavy").toString()); int serious = Integer.parseInt(tMap.get("serious").toString()); int espSerious = Integer.parseInt(tMap.get("espSerious").toString()); int total_count = normal + common + heavy + serious + espSerious; tMap.put("total_count",total_count); int id = baseDao.getId(); if(id == 0){ baseDao.insertHealthState(tMap); }else{ tMap.put("id",id); baseDao.updateHealthState(tMap); } } }