lizijie
2021-09-10 f4ea57b76cfad4e350adaafe6338165be7e8e6ba
screen-manage/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.GovMonitorPoint;
@@ -17,10 +18,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -138,6 +141,7 @@
        return resultMap;
    }
    @Transactional
    @Override
    public void insert(GovMonitorPoint govMonitorPoint) {
        int count = govMonitorPointMapper.insert(govMonitorPoint);
@@ -152,6 +156,64 @@
        }
    }
    @Transactional
    @Override
    public void update(GovMonitorPoint govMonitorPoint) {
        Integer id = govMonitorPoint.getId();
        GovMonitorPoint oldGovMonitorPoint = govMonitorPointMapper.selectById(id);
        govMonitorPointMapper.updateById(govMonitorPoint);
        //删除redis
        delGovMonitorPointInfoFromRedis(id.toString());
        //更新redis
        setGovMonitorPointInfoToRedis(id.toString(),selectGovMonitorPointInfoById(id));
        //操作日志记录
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        StringBuilder content = new StringBuilder();
        content.append("修改了政府站点:").append("id:").append(govMonitorPoint.getId()+";");
        if (!ObjectUtils.isEmpty(govMonitorPoint.getGuid())){
            content.append("guid:").append(oldGovMonitorPoint.getGuid()).append("->").append(govMonitorPoint.getGuid()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getName())){
            content.append("name:").append(oldGovMonitorPoint.getName()).append("->").append(govMonitorPoint.getName()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getLongitude())){
            content.append("longitude:").append(oldGovMonitorPoint.getLongitude()).append("->").append(govMonitorPoint.getLongitude()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getLatitude())){
            content.append("latitude:").append(oldGovMonitorPoint.getLatitude()).append("->").append(govMonitorPoint.getLatitude()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getProvinceCode())){
            content.append("provinceCode:").append(oldGovMonitorPoint.getProvinceCode()).append("->").append(govMonitorPoint.getProvinceCode()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getCityCode())){
            content.append("cityCode:").append(oldGovMonitorPoint.getCityCode()).append("->").append(govMonitorPoint.getCityCode()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getAreaCode())){
            content.append("areaCode:").append(oldGovMonitorPoint.getAreaCode()).append("->").append(govMonitorPoint.getAreaCode()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getStationLevel())){
            content.append("stationLevel:").append(oldGovMonitorPoint.getStationLevel()).append("->").append(govMonitorPoint.getStationLevel()).append(";");
        }
        if (!ObjectUtils.isEmpty(govMonitorPoint.getDesc())){
            content.append("desc:").append(oldGovMonitorPoint).append("->").append(govMonitorPoint.getDesc()).append(";");
        }
        logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE);
    }
    @Override
    public void delete(Integer id) {
        UpdateWrapper<GovMonitorPoint> wrapper_delete = new UpdateWrapper<>();
        wrapper_delete.eq("id",id).set("is_delete",Constants.DELETE);
        govMonitorPointMapper.update(null,wrapper_delete);
        //删除redis
        delGovMonitorPointInfoFromRedis(id.toString());
        //操作日志记录
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        StringBuilder content = new StringBuilder();
        content.append("删除了设备:").append("id:").append(id).append(";");
        logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE);
    }
    @Override
    public GovMonitorPoint selectGovMonitorPointInfoById(int id) {
        GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectById(id);