文件名从 ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java 修改 |
| | |
| | | package com.ruoyi.alarm.config.service.impl; |
| | | |
| | | |
| | | |
| | | import com.ruoyi.alarm.config.domain.ArdAlarmTypeConfig; |
| | | import com.ruoyi.alarm.config.mapper.ArdAlarmTypeConfigMapper; |
| | | import com.ruoyi.alarm.config.service.IArdAlarmTypeConfigService; |
| | |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | |
| | | */ |
| | | @Service |
| | | public class ArdAlarmTypeConfigServiceImpl implements IArdAlarmTypeConfigService { |
| | | @Autowired |
| | | @Resource |
| | | private ArdAlarmTypeConfigMapper ardAlarmTypeConfigMapper; |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | | /** |
| | | * 鏌ヨ鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public int insertArdAlarmTypeConfig(ArdAlarmTypeConfig ardAlarmTypeConfig) { |
| | | ardAlarmTypeConfig.setCreateBy(SecurityUtils.getUsername()); |
| | | ardAlarmTypeConfig.setCreateTime(DateUtils.getNowDate()); |
| | | ardAlarmTypeConfig.setUserId(SecurityUtils.getUserId()); |
| | | return ardAlarmTypeConfigMapper.insertArdAlarmTypeConfig(ardAlarmTypeConfig); |
| | | } |
| | |
| | | @Override |
| | | public int deleteArdAlarmTypeConfigById(String id) { |
| | | return ardAlarmTypeConfigMapper.deleteArdAlarmTypeConfigById(id); |
| | | } |
| | | /** |
| | | * 鎵归噺鎶ヨ绫诲瀷鐢ㄦ埛鍏宠仈 |
| | | * |
| | | * @param configInfo 鎶ヨ绫诲瀷鍒楄〃 |
| | | * @return 缁撴灉 |
| | | */ |
| | | @Override |
| | | public int insertArdAlarmTypeConfig(Map<String,Object> configInfo) { |
| | | String userId =(String) configInfo.get("userId"); |
| | | if(userId==null) |
| | | { |
| | | return 0; |
| | | } |
| | | ardAlarmTypeConfigMapper.deleteArdAlarmTypeConfigByCurrentUserId(userId); |
| | | List<Integer> commands=(List<Integer>) configInfo.get("commands"); |
| | | if(commands==null) |
| | | { |
| | | return 0; |
| | | } |
| | | if(commands.size()==0) |
| | | { |
| | | return 0; |
| | | } |
| | | int resNum=0; |
| | | for(Integer command :commands) |
| | | { |
| | | ArdAlarmTypeConfig config=new ArdAlarmTypeConfig(); |
| | | config.setId(IdUtils.simpleUUID()); |
| | | config.setCommand(command); |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType("alarm_type"); |
| | | SysDictData sysDictData = dictDatas.stream().filter(s -> Objects.equals(s.getDictValue(), command.toString())).findFirst().orElse(null); |
| | | config.setAlarmType(sysDictData.getDictLabel()); |
| | | config.setUserId(userId); |
| | | config.setCreateTime(DateUtils.getNowDate()); |
| | | int i = ardAlarmTypeConfigMapper.insertArdAlarmTypeConfig(config); |
| | | if(i>0) |
| | | { |
| | | resNum++; |
| | | } |
| | | } |
| | | return resNum; |
| | | } |
| | | } |