From 8c635598000e40edfb3edf5934124ad48d60f62d Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期六, 21 六月 2025 19:14:50 +0800 Subject: [PATCH] 实时页面修改 --- src/main/java/com/whyc/service/InfoChangeService.java | 75 +++++++++++++++++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/whyc/service/InfoChangeService.java b/src/main/java/com/whyc/service/InfoChangeService.java new file mode 100644 index 0000000..de72572 --- /dev/null +++ b/src/main/java/com/whyc/service/InfoChangeService.java @@ -0,0 +1,75 @@ +package com.whyc.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.whyc.mapper.BattInfChangeMapper; +import com.whyc.mapper.PowerInfChangeMapper; +import com.whyc.mapper.StationInfChangeMapper; +import com.whyc.pojo.db_station.*; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +@Service +public class InfoChangeService { + @Autowired(required = false) + private StationInfChangeMapper sinfChangeMapper; + + @Autowired(required = false) + private PowerInfChangeMapper pinfChangeMapper; + + @Autowired(required = false) + private BattInfChangeMapper binfChangeMapper; + + //瀛樺叆鍙樻洿淇℃伅璁板綍 + public void addInfoChange(StationInf sinf, PowerInf pinf, BattInf binf,String updateReason) { + StationInfChange sinfChange = new StationInfChange(); + PowerInfChange pinfChange = new PowerInfChange(); + BattInfChange binfChange = new BattInfChange(); + Date updateTime = new Date(); + //灏嗕俊鎭嫹璐濊嚦瀵瑰簲鐨勫彉鏇翠俊鎭〃 + BeanUtils.copyProperties(sinf,sinfChange); + String fullName=sinf.getProvice()+"_"+sinf.getCity()+"_"+sinf.getCountry()+"_"+sinf.getStationName(); + sinfChange.setFullName(fullName); + sinfChange.setUpdateTime(updateTime); + sinfChange.setUpdateReason(updateReason); + + BeanUtils.copyProperties(pinf,pinfChange); + pinfChange.setUpdateTime(updateTime); + pinfChange.setUpdateReason(updateReason); + + BeanUtils.copyProperties(binf,binfChange); + binfChange.setUpdateTime(updateTime); + binfChange.setUpdateReason(updateReason); + + //灏嗗彉鏇磋褰曞瓨鍏ュ彉鏇磋〃 + sinfChangeMapper.insert(sinfChange); + pinfChangeMapper.insert(pinfChange); + binfChangeMapper.insert(binfChange); + } + //鑾峰彇鏈烘埧锛岀數婧愶紝鐢垫睜缁勫彉鏇磋褰� + public List<StationInfChange> getSinfChange(Integer stationId) { + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("station_id",stationId); + wrapper.orderByDesc("update_time"); + List<StationInfChange> list=sinfChangeMapper.selectList(wrapper); + return list; + } + public List<PowerInfChange> getPinfChange(Integer powerId) { + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("power_id",powerId); + wrapper.orderByDesc("update_time"); + List<PowerInfChange> list=pinfChangeMapper.selectList(wrapper); + return list; + } + + public List<BattInfChange> getBinfChange(Integer battgroupId) { + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("battgroup_id",battgroupId); + wrapper.orderByDesc("update_time"); + List<BattInfChange> list=binfChangeMapper.selectList(wrapper); + return list; + } +} \ No newline at end of file -- Gitblit v1.9.1