| | |
| | | import com.whyc.mapper.AlarmVoiceSetMapper; |
| | | import com.whyc.pojo.AlarmVoiceSet; |
| | | import com.whyc.pojo.BattalarmData; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.File; |
| | | import java.util.List; |
| | | |
| | |
| | | @Resource |
| | | private AlarmVoiceSetMapper mapper; |
| | | |
| | | public Response InsertNextTimeInterval(AlarmVoiceSet set) { |
| | | int userId = ActionUtil.getUser().getUId().intValue(); |
| | | public Response InsertNextTimeInterval(AlarmVoiceSet set, HttpServletRequest request) { |
| | | //int userId = ActionUtil.getUser().getUId().intValue(); |
| | | HttpSession session = request.getSession(); |
| | | Object obj=session.getAttribute("user"); |
| | | UserInf user = new UserInf(); |
| | | if(obj==null){ |
| | | user.setUName("未登录的用户账号"); |
| | | user.setUId(0L); |
| | | user.setURole(0); |
| | | }else{ |
| | | user=(UserInf) obj; |
| | | } |
| | | |
| | | int userId = user.getUId().intValue(); |
| | | long currentTimeMillis = System.currentTimeMillis(); |
| | | Integer nextTimeInterval = set.getNextTimeInterval(); |
| | | long nextTimestamp = currentTimeMillis+nextTimeInterval*60*1000; |
| | | set.setNextTimestamp(nextTimestamp); |
| | | set.setUserId(userId); |
| | | set.setStatus(1); |
| | | set.setUserId(user.getUId().intValue()); |
| | | set.setStatus(0); |
| | | Integer battGroupId = set.getBattGroupId(); |
| | | Long deviceId = set.getDeviceId(); |
| | | Long powerDeviceId = set.getPowerDeviceId(); |
| | | Integer alarmType = set.getAlarmType(); |
| | | //查询所有语音文件中存在的,更新语音文件下次时间戳 |
| | | //获取绝对文件夹路径 |
| | | String readSuffixPath = "wav" + File.separator + "alarm" + File.separator + userId + File.separator; |
| | | String readSuffixPath = "wav" + File.separator + "alarm" + File.separator + user.getUId().intValue() + File.separator; |
| | | String readDirPath = CommonUtil.getRootFile() + readSuffixPath; |
| | | File readDir = new File(readDirPath); |
| | | String[] arr = readDir.list(); |
| | |
| | | if(alarmVoiceSetDb!=null){ //修改 |
| | | UpdateWrapper<AlarmVoiceSet> update = Wrappers.update(); |
| | | update.set("next_time_interval", nextTimeInterval).set("next_timestamp",nextTimestamp).eq("id",alarmVoiceSetDb.getId()); |
| | | mapper.update(null,update); |
| | | mapper.update((AlarmVoiceSet) ActionUtil.objeNull,update); |
| | | }else{ //新增 |
| | | mapper.insert(set); |
| | | } |
| | |
| | | public void delete(Integer id) { |
| | | UpdateWrapper<AlarmVoiceSet> update = Wrappers.update(); |
| | | update.set("status",0).eq("id",id); |
| | | mapper.update(null,update); |
| | | mapper.update((AlarmVoiceSet) ActionUtil.objeNull,update); |
| | | } |
| | | |
| | | public List<AlarmVoiceSet> getAllByUserId(Long userId) { |