Merge remote-tracking branch 'origin/cjl' into qa
# Conflicts:
# screen-api/pom.xml
11 files added
13 files modified
| | |
| | | <version>1.5.1</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>5.3.0</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
New file |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.moral.api.entity.CityConfigAqi; |
| | | import com.moral.api.pojo.enums.ChangeEnum; |
| | | import com.moral.api.pojo.enums.InvestigationEnum; |
| | | import com.moral.api.pojo.enums.StateEnum; |
| | | import com.moral.api.pojo.enums.YesOrNo; |
| | | import com.moral.api.pojo.vo.DictionaryVo; |
| | | import com.moral.constant.ResultMessage; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName DictController |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 11:39 |
| | | * @Version 1.0 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dict") |
| | | @Api(tags = {"字典"}) |
| | | public class DictController { |
| | | @GetMapping("list") |
| | | |
| | | public ResultMessage<DictionaryVo> list() { |
| | | DictionaryVo dictionaryVo = new DictionaryVo() |
| | | .setStateEnums(StateEnum.values()) |
| | | .setChangeEnum(ChangeEnum.values()) |
| | | .setInvestigationEnum(InvestigationEnum.values()) |
| | | .setYesOrNo(YesOrNo.values()) |
| | | ; |
| | | return ResultMessage.ok(dictionaryVo); |
| | | } |
| | | |
| | | } |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.awt.geom.GeneralPath; |
| | | import java.awt.geom.Point2D; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo); |
| | | } |
| | | |
| | | @GetMapping("UAVTest") |
| | | public ResultMessage UAVTest(BigDecimal lat, BigDecimal lon, String batch){ |
| | | historySecondUavService.UAVTest(lat, lon, batch); |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.api.exception.BusinessException; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName InvestigationEnum |
| | | * @Description TODO |
| | | * @Author @cjl |
| | | * @Date 2023-09-20 14:47 |
| | | * @Version 1.0 |
| | | */ |
| | | @Getter |
| | | @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| | | public enum AllocationApproveEnum implements IntegerValueEnum{ |
| | | /** |
| | | *新建 |
| | | */ |
| | | NEW_BUILT(10, "新建"), |
| | | /** |
| | | *整改中 |
| | | */ |
| | | UNDER_RECTIFICATION(20, "整改中"), |
| | | /** |
| | | *审批中 |
| | | */ |
| | | IN_APPROVAL(30, "审批中"), |
| | | /** |
| | | *通过 |
| | | */ |
| | | PASS(40, "通过"), |
| | | /** |
| | | *拒绝 |
| | | */ |
| | | REFUSE(50, "拒绝"), |
| | | |
| | | ; |
| | | |
| | | @EnumValue |
| | | public final Integer value; |
| | | public final String name; |
| | | |
| | | AllocationApproveEnum(Integer value, String name) { |
| | | this.value = value; |
| | | this.name = name; |
| | | } |
| | | |
| | | private static Map<Integer, AllocationApproveEnum> valueMap = new HashMap<>(); |
| | | static { |
| | | for (AllocationApproveEnum v : AllocationApproveEnum.values()) { |
| | | valueMap.put(v.value, v); |
| | | } |
| | | } |
| | | @JsonCreator |
| | | public static AllocationApproveEnum getByValue(Integer value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | AllocationApproveEnum result = valueMap.get(value); |
| | | if (result == null) { |
| | | throw new BusinessException("枚举转换异常" + value); |
| | | } |
| | | return result; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.api.exception.BusinessException; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName StateEnum |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 11:11 |
| | | * @Version 1.0 |
| | | */ |
| | | @Getter |
| | | @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| | | public enum ChangeEnum implements IntegerValueEnum { |
| | | |
| | | /** |
| | | *立行整改 |
| | | */ |
| | | IMMEDIATELY(1, "立行整改"), |
| | | /** |
| | | *限期整改 |
| | | */ |
| | | DEADLINE(2, "限期整改"), |
| | | ; |
| | | |
| | | @EnumValue |
| | | public final Integer value; |
| | | public final String name; |
| | | |
| | | ChangeEnum(Integer value, String name) { |
| | | this.value = value; |
| | | this.name = name; |
| | | } |
| | | |
| | | private static Map<Integer, ChangeEnum> valueMap = new HashMap<>(); |
| | | static { |
| | | for (ChangeEnum v : ChangeEnum.values()) { |
| | | valueMap.put(v.value, v); |
| | | } |
| | | } |
| | | @JsonCreator |
| | | public static ChangeEnum getByValue(Integer value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | ChangeEnum result = valueMap.get(value); |
| | | if (result == null) { |
| | | throw new BusinessException("枚举转换异常" + value); |
| | | } |
| | | return result; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | /** |
| | | * @ClassName IntegerValueEnum |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 11:35 |
| | | * @Version 1.0 |
| | | */ |
| | | public interface IntegerValueEnum { |
| | | |
| | | /** |
| | | * 获得value |
| | | * |
| | | * @return |
| | | */ |
| | | Integer getValue(); |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.api.exception.BusinessException; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName InvestigationEnum |
| | | * @Description TODO |
| | | * @Author @cjl |
| | | * @Date 2023-09-20 14:47 |
| | | * @Version 1.0 |
| | | */ |
| | | @Getter |
| | | @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| | | public enum InvestigationEnum implements IntegerValueEnum{ |
| | | /** |
| | | *立行整改 |
| | | */ |
| | | SCENE(1, "现场"), |
| | | /** |
| | | *限期整改 |
| | | */ |
| | | TRAVELING_VEHICLE(2, "走航"), |
| | | |
| | | UAV(3, "无人机"), |
| | | ; |
| | | |
| | | @EnumValue |
| | | public final Integer value; |
| | | public final String name; |
| | | |
| | | InvestigationEnum(Integer value, String name) { |
| | | this.value = value; |
| | | this.name = name; |
| | | } |
| | | |
| | | private static Map<Integer, InvestigationEnum> valueMap = new HashMap<>(); |
| | | static { |
| | | for (InvestigationEnum v : InvestigationEnum.values()) { |
| | | valueMap.put(v.value, v); |
| | | } |
| | | } |
| | | @JsonCreator |
| | | public static InvestigationEnum getByValue(Integer value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | InvestigationEnum result = valueMap.get(value); |
| | | if (result == null) { |
| | | throw new BusinessException("枚举转换异常" + value); |
| | | } |
| | | return result; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.api.exception.BusinessException; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName StateEnum |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 11:11 |
| | | * @Version 1.0 |
| | | */ |
| | | @Getter |
| | | @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| | | public enum StateEnum implements IntegerValueEnum { |
| | | /** |
| | | *未生效 |
| | | */ |
| | | NOT_EFFECTIVE(10, "未生效"), |
| | | /** |
| | | *已生效 |
| | | */ |
| | | TAKE_EFFECT(20, "已生效"); |
| | | |
| | | @EnumValue |
| | | public final Integer value; |
| | | public final String name; |
| | | |
| | | StateEnum(Integer value, String name) { |
| | | this.value = value; |
| | | this.name = name; |
| | | } |
| | | |
| | | private static Map<Integer, StateEnum> valueMap = new HashMap<>(); |
| | | static { |
| | | for (StateEnum v : StateEnum.values()) { |
| | | valueMap.put(v.value, v); |
| | | } |
| | | } |
| | | @JsonCreator |
| | | public static StateEnum getByValue(Integer value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | StateEnum result = valueMap.get(value); |
| | | if (result == null) { |
| | | throw new BusinessException("枚举转换异常" + value); |
| | | } |
| | | return result; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | /** |
| | | * @ClassName StringValueEnum |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 11:36 |
| | | * @Version 1.0 |
| | | */ |
| | | public interface StringValueEnum { |
| | | |
| | | /** |
| | | * 获得value |
| | | * |
| | | * @return |
| | | */ |
| | | String getValue(); |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonCreator; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.api.exception.BusinessException; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName StateEnum |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 11:11 |
| | | * @Version 1.0 |
| | | */ |
| | | @Getter |
| | | @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| | | public enum YesOrNo implements IntegerValueEnum { |
| | | /** |
| | | *未生效 |
| | | */ |
| | | YES(1, "是"), |
| | | /** |
| | | *已生效 |
| | | */ |
| | | No(0, "否"); |
| | | |
| | | @EnumValue |
| | | public final Integer value; |
| | | public final String name; |
| | | |
| | | YesOrNo(Integer value, String name) { |
| | | this.value = value; |
| | | this.name = name; |
| | | } |
| | | |
| | | private static Map<Integer, YesOrNo> valueMap = new HashMap<>(); |
| | | static { |
| | | for (YesOrNo v : YesOrNo.values()) { |
| | | valueMap.put(v.value, v); |
| | | } |
| | | } |
| | | @JsonCreator |
| | | public static YesOrNo getByValue(Integer value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | YesOrNo result = valueMap.get(value); |
| | | if (result == null) { |
| | | throw new BusinessException("枚举转换异常" + value); |
| | | } |
| | | return result; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.vo; |
| | | |
| | | import com.moral.api.pojo.enums.ChangeEnum; |
| | | import com.moral.api.pojo.enums.InvestigationEnum; |
| | | import com.moral.api.pojo.enums.StateEnum; |
| | | import com.moral.api.pojo.enums.YesOrNo; |
| | | import com.moral.api.utils.BeanConverts; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @ClassName DictionaryVo |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 13:30 |
| | | * @Version 1.0 |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @ApiModel(value = "字典选项 - VO", description = "字典选项 - VO") |
| | | public class DictionaryVo { |
| | | |
| | | private List<Map<String, Object>> StateEnums; |
| | | |
| | | private List<Map<String, Object>> InvestigationEnum; |
| | | |
| | | private List<Map<String, Object>> ChangeEnum; |
| | | private List<Map<String, Object>> YesOrNo; |
| | | |
| | | |
| | | |
| | | |
| | | public static List<Map<String, Object>> enumArray2Map(Enum[] enums) { |
| | | List<Map<String, Object>> mapList = Arrays.asList(enums).stream().map(BeanConverts::objToMapNonJson).collect(Collectors.toList()); |
| | | mapList.stream().map(map -> map.remove("declaringClass")).collect(Collectors.toList()); |
| | | return mapList; |
| | | } |
| | | |
| | | public DictionaryVo setStateEnums(StateEnum[] enumResult) { |
| | | this.StateEnums = enumArray2Map(enumResult); |
| | | return this; |
| | | } |
| | | |
| | | public DictionaryVo setInvestigationEnum(com.moral.api.pojo.enums.InvestigationEnum[] stateEnum) { |
| | | this.InvestigationEnum = enumArray2Map(stateEnum); |
| | | return this; |
| | | } |
| | | |
| | | public DictionaryVo setChangeEnum(com.moral.api.pojo.enums.ChangeEnum[] enumResult) { |
| | | this.ChangeEnum = enumArray2Map(enumResult); |
| | | return this; |
| | | } |
| | | |
| | | public DictionaryVo setYesOrNo(com.moral.api.pojo.enums.YesOrNo[] enumResult) { |
| | | this.YesOrNo = enumArray2Map(enumResult); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.moral.api.pojo.dto.uav.UAVQueryTimeSlotDTO; |
| | | import com.moral.api.pojo.form.uav.UAVQueryTimeSlotForm; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | List<HistorySecondUav> queryDataByBatch(String batch); |
| | | |
| | | |
| | | boolean UAVTest(BigDecimal lat, BigDecimal lon, String batch); |
| | | } |
| | |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.time.Duration; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.OptionalDouble; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.DoubleStream; |
| | | |
| | |
| | | CityAqiMonthly cityAqiMonthly = cityAqiMonthlyMapper.selectOne(cityAqiMonthlyQueryWrapper); |
| | | Double compositeIndex = null; |
| | | String compositeIndexYearOnYear = null; |
| | | Integer pm25 = null; |
| | | Double pm25 = null; |
| | | String pm25YearOnYear = null; |
| | | if (cityAqiMonthly != null) { |
| | | Map<String, Object> aqiMap = JSONObject.parseObject(cityAqiMonthly.getValue(), Map.class); |
| | |
| | | |
| | | //3.PM2.5浓度 |
| | | if (aqiMap.get("PM2_5") != null) { |
| | | pm25 = Integer.parseInt(aqiMap.get("PM2_5").toString()); |
| | | pm25 = Objects.nonNull(aqiMap.get("PM2_5"))?Double.parseDouble(aqiMap.get("PM2_5").toString()):0d; |
| | | } |
| | | currentRankingResult.put("PM2_5", pm25 + "ug/m³"); |
| | | |
| | |
| | | Map<Integer, Map<String, Object>> monthlyCumulativeResult = null; |
| | | Double cityCompositeIndex = null; |
| | | String cityCompositeIndexYearOnYear = null; |
| | | Integer cityPM25 = null; |
| | | Double cityPM25 = null; |
| | | String cityPM25YearOnYear = null; |
| | | if (!"1".equals(month)) { |
| | | Map<String, Object> cumulativeRankingResult = new HashMap<>(); |
| | |
| | | cityCompositeIndexYearOnYear = cityMap.get("compositeIndex_yearOnYear").toString(); |
| | | } |
| | | //地级市PM2.5 |
| | | cityPM25 = (int) Double.parseDouble(cityMap.get("PM2_5").toString()); |
| | | cityPM25 = Double.parseDouble(cityMap.get("PM2_5").toString()); |
| | | if (cityMap.get("PM2_5_yearOnYear") != null) { |
| | | cityPM25YearOnYear = cityMap.get("PM2_5_yearOnYear").toString(); |
| | | } |
| | |
| | | * @param pm25YearOnYear 中心城区(地级市)pm2.5同比 |
| | | * @description 获取本期所有县市区与中心城区(地级市)因子对比情况 |
| | | */ |
| | | private Map<String, Object> getAreaCurrentMonthResult(Map<Integer, String> areasMap, List<CityAqiMonthly> areaData, Double compositeIndex, String compositeIndexYearOnYear, Integer pm25, String pm25YearOnYear) { |
| | | private Map<String, Object> getAreaCurrentMonthResult(Map<Integer, String> areasMap, List<CityAqiMonthly> areaData, Double compositeIndex, String compositeIndexYearOnYear, Double pm25, String pm25YearOnYear) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("compositeIndex", compositeIndex); |
| | | result.put("compositeIndexYearOnYear", compositeIndexYearOnYear); |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.HistorySecondUavMapper; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean UAVTest(BigDecimal lat, BigDecimal lon, String batch) { |
| | | List<HistorySecondUav> list = new ArrayList<>(); |
| | | |
| | | QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("batch", batch); |
| | | wrapper.select("value,mac,time,organization_id"); |
| | | wrapper.orderByAsc("time"); |
| | | List<HistorySecondUav> datas = historySecondUavMapper.selectList(wrapper); |
| | | Date time =DateUtils.addDays(datas.get(2).getTime(),0); |
| | | //String bat = "2023-08-08 14:42:20"; |
| | | for(HistorySecondUav g : datas){ |
| | | HistorySecondUav historySecondUav = new HistorySecondUav(); |
| | | historySecondUav.setTime(DateUtils.addDays(g.getTime(),0)); |
| | | historySecondUav.setMac(g.getMac()); |
| | | historySecondUav.setBatch(time); |
| | | historySecondUav.setOrganizationId(g.getOrganizationId()); |
| | | Map<String, Object> data = JSON.parseObject(g.getValue(), Map.class); |
| | | Map<String, Object> dataResult = new HashMap<>(); |
| | | dataResult = data; |
| | | dataResult.put("flylat",Objects.isNull(data.get("flylat"))||data.get("flylat").toString().equals("0")?0d:Double.parseDouble(String.format("%.10f",Double.parseDouble(data.get("flylat").toString())+lat.doubleValue()))); |
| | | dataResult.put("flylon",Objects.isNull(data.get("flylon"))||data.get("flylon").toString().equals("0")?0d:Double.parseDouble(String.format("%.10f",Double.parseDouble(data.get("flylon").toString())+lon.doubleValue()))); |
| | | /*if(Objects.nonNull(data.get("a21026"))&& !data.get("a21026").toString().equals("0")){ |
| | | Double a21026D = Double.parseDouble(data.get("a21026").toString()); |
| | | if( a21026D>15){ |
| | | a21026D = a21026D -10; |
| | | } |
| | | dataResult.put("a21026",Double.parseDouble(String.format("%.4f",a21026D))); |
| | | } |
| | | if(Objects.nonNull(data.get("a21004"))&& !data.get("a21004").toString().equals("0")){ |
| | | Double a21024D = Double.parseDouble(data.get("a21004").toString()); |
| | | if( a21024D>100){ |
| | | a21024D = a21024D -100; |
| | | } |
| | | dataResult.put("a21004",Double.parseDouble(String.format("%.4f",a21024D))); |
| | | }*/ |
| | | historySecondUav.setValue(JSONObject.toJSONString(dataResult)); |
| | | list.add(historySecondUav); |
| | | } |
| | | this.saveBatch(list); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.text.NumberFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | List<Map<String, Object>> devices = deviceService.getDevicesByOrganizationId(organizationId); |
| | | Set<Map<String, Object>> result = new HashSet<>(); |
| | | for (Map<String, Object> device : devices) { |
| | | if(Objects.nonNull(device)&&Objects.nonNull(device.get("professions"))&&device.containsKey("professions")){ |
| | | List<Map<String, Object>> professions = (List<Map<String, Object>>) device.get("professions"); |
| | | result.addAll(professions); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
New file |
| | |
| | | package com.moral.api.utils; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.SerializationFeature; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | |
| | | import java.beans.BeanInfo; |
| | | import java.beans.IntrospectionException; |
| | | import java.beans.Introspector; |
| | | import java.beans.PropertyDescriptor; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | import java.util.stream.StreamSupport; |
| | | |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @ClassName BeanConverts |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 13:41 |
| | | * @Version 1.0 |
| | | */ |
| | | @Slf4j |
| | | @SuppressWarnings("unchecked") |
| | | public class BeanConverts { |
| | | private static ObjectMapper objectMapper = new ObjectMapper(); |
| | | static{ |
| | | |
| | | //序列化的时候序列对象的所有属性 |
| | | objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS); |
| | | |
| | | //反序列化的时候如果多了其他属性,不抛出异常 |
| | | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| | | |
| | | //如果是空对象的时候,不抛异常 |
| | | objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); |
| | | |
| | | //属性为null的转换 |
| | | objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); |
| | | } |
| | | |
| | | private BeanConverts() { |
| | | } |
| | | |
| | | /** |
| | | * BeanUtils.copyProperties 增强 |
| | | * 拷贝时,source 值为空则不拷贝 |
| | | * |
| | | * @param source 源数据 |
| | | * @param target 目标数据 |
| | | * @param ignoreProperties 忽略属性 |
| | | */ |
| | | public static void copyPropertiesIgnoreNull(Object source, Object target, String... ignoreProperties) { |
| | | Set<String> ignoreSet = new HashSet<>(); |
| | | if (ignoreProperties != null) { |
| | | ignoreSet.addAll(Arrays.asList(ignoreProperties)); |
| | | } |
| | | ignoreSet.addAll(getObjectNullFieldName(source)); |
| | | BeanUtils.copyProperties(source, target, ignoreSet.toArray(new String[0])); |
| | | } |
| | | |
| | | /** |
| | | * 获取对象字段值为null 的字段名称集合 |
| | | * |
| | | * @param object 源数据 |
| | | * @return 字段名称集合 |
| | | */ |
| | | public static List<String> getObjectNullFieldName(Object object) { |
| | | BeanMap beanMap = BeanMap.create(object); |
| | | List<String> fieldNameList = new ArrayList<>(); |
| | | for (Object key : beanMap.keySet()) { |
| | | if (beanMap.get(key) == null) { |
| | | fieldNameList.add(key.toString()); |
| | | } |
| | | } |
| | | return fieldNameList; |
| | | } |
| | | |
| | | /** |
| | | * 将对象转换为map |
| | | * 不转换空值字段 |
| | | * |
| | | * @param obj 对象 |
| | | * @return 键值对 |
| | | */ |
| | | public static Map<String, Object> objToMapIgnoreNull(Object obj) { |
| | | return objToMap(obj, true); |
| | | } |
| | | |
| | | /** |
| | | * 将对象转换为map |
| | | * |
| | | * @param obj 对象 |
| | | * @return 键值对 |
| | | */ |
| | | public static Map<String, Object> objToMap(Object obj) { |
| | | return objToMap(obj, false); |
| | | } |
| | | |
| | | /** |
| | | * 将对象转换为map |
| | | * |
| | | * @param obj 对象 |
| | | * @param ignoreNull 忽略空值字段 |
| | | * @return 键值对 |
| | | */ |
| | | private static Map<String, Object> objToMap(Object obj, boolean ignoreNull) { |
| | | return JSONUtil.parseObj(obj, ignoreNull); |
| | | } |
| | | |
| | | /** |
| | | * entity 转换 |
| | | * |
| | | * @param obj 源对象 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <T> T cloneShallow(Object obj, Class<T> clazz) { |
| | | if (obj == null) { |
| | | return null; |
| | | } |
| | | T t = BeanUtils.instantiateClass(clazz); |
| | | BeanUtils.copyProperties(obj, t); |
| | | return t; |
| | | } |
| | | |
| | | /** |
| | | * entity 集合转换 |
| | | * |
| | | * @param collection 源对象集合 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象集合 |
| | | */ |
| | | public static <T> List<T> cloneShallow(Collection<?> collection, Class<T> clazz) { |
| | | return collection.stream().map(item -> convert(item, clazz)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * entity 转换 |
| | | * |
| | | * @param obj 源对象 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <T> T convert(Object obj, Class<T> clazz) { |
| | | |
| | | return objectMapper.convertValue(obj, clazz); |
| | | } |
| | | |
| | | public static <T> T convert(Object obj, TypeReference<T> type) { |
| | | return objectMapper.convertValue(obj, type); |
| | | } |
| | | |
| | | /** |
| | | * entity 转换 |
| | | * |
| | | * @param optional 源对象 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <T> T convert(Optional<?> optional, Class<T> clazz) { |
| | | return optional.map(obj -> convert(obj, clazz)).orElseGet(null); |
| | | } |
| | | |
| | | /** |
| | | * entity 集合转换 |
| | | * |
| | | * @param collection 源对象集合 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象集合 |
| | | */ |
| | | public static <T> List<T> convert(Collection<?> collection, Class<T> clazz) { |
| | | return JSONArray.parseArray(JSONArray.toJSONString(collection), clazz); |
| | | } |
| | | |
| | | /** |
| | | * entity 集合转换 |
| | | * |
| | | * @param iterable 实体集合 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象集合 |
| | | */ |
| | | public static <T> List<T> convert(Iterable<?> iterable, Class<T> clazz) { |
| | | return convert(StreamSupport.stream(iterable.spliterator(), false), clazz); |
| | | } |
| | | |
| | | /** |
| | | * entity 集合转换 |
| | | * |
| | | * @param stream 实体集合流 |
| | | * @param clazz 目标类型 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象集合 |
| | | */ |
| | | public static <T> List<T> convert(Stream<?> stream, Class<T> clazz) { |
| | | return stream.map(entity -> convert(entity, clazz)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * map 转对象 |
| | | * |
| | | * @param clazz 目标类型 |
| | | * @param collection 键值对集合 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象集合 |
| | | */ |
| | | public static <T> List<T> mapToObj(Class<T> clazz, Collection<Map<String, Object>> collection) { |
| | | return collection.stream().map(map -> BeanConverts.mapToObj(clazz, map)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * map 转对象 |
| | | * |
| | | * @param clazz 目标类型 |
| | | * @param map 键值对 |
| | | * @param <T> 泛型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <T> T mapToObj(Class<T> clazz, Map<String, Object> map) { |
| | | T d = BeanUtils.instantiateClass(clazz); |
| | | BeanInfo beanInfo; |
| | | try { |
| | | beanInfo = Introspector.getBeanInfo(d.getClass()); |
| | | } catch (IntrospectionException e) { |
| | | log.warn(e.getMessage(), e); |
| | | return null; |
| | | } |
| | | PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); |
| | | for (PropertyDescriptor property : propertyDescriptors) { |
| | | Method setter = property.getWriteMethod(); |
| | | if (setter == null) { |
| | | continue; |
| | | } |
| | | Object value = map.get(property.getName()); |
| | | if (value == null) { |
| | | continue; |
| | | } else if (value instanceof Timestamp) { |
| | | if (property.getPropertyType().equals(LocalDate.class)) { |
| | | value = ((Timestamp) value).toLocalDateTime().toLocalDate(); |
| | | } else { |
| | | value = ((Timestamp) value).toLocalDateTime(); |
| | | } |
| | | } else if (property.getPropertyType().equals(BigDecimal.class)) { |
| | | value = BigDecimal.valueOf((double) value); |
| | | } |
| | | try { |
| | | setter.invoke(d, value); |
| | | } catch (Exception e) { |
| | | log.warn(e.getMessage(), e); |
| | | } |
| | | } |
| | | return d; |
| | | } |
| | | |
| | | /** |
| | | * 对象集合中取出两个字段,组成map |
| | | * |
| | | * @param collection 对象集合 |
| | | * @param keyProperty key属性值 |
| | | * @param valueProperty value属性值 |
| | | * @param <E> 泛型 |
| | | * @return 属性值map |
| | | */ |
| | | public static <E> Map<String, E> propertyToMap(Collection collection, String keyProperty, String valueProperty) { |
| | | Map<String, E> map = new LinkedHashMap<>(); |
| | | if (collection.isEmpty()) { |
| | | return map; |
| | | } |
| | | Object obj = collection.iterator().next(); |
| | | BeanInfo beanInfo; |
| | | try { |
| | | beanInfo = Introspector.getBeanInfo(obj.getClass()); |
| | | } catch (IntrospectionException e) { |
| | | log.warn(e.getMessage(), e); |
| | | return map; |
| | | } |
| | | PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); |
| | | Method keyGetter = null; |
| | | Method valueGetter = null; |
| | | for (PropertyDescriptor property : propertyDescriptors) { |
| | | if (keyProperty.equals(property.getName()) && property.getReadMethod() != null) { |
| | | keyGetter = property.getReadMethod(); |
| | | } else if (valueProperty.equals(property.getName()) && property.getReadMethod() != null) { |
| | | valueGetter = property.getReadMethod(); |
| | | } |
| | | } |
| | | if (keyGetter == null || valueGetter == null) { |
| | | return map; |
| | | } |
| | | for (Object item : collection) { |
| | | try { |
| | | map.put(keyGetter.invoke(item).toString(), (E) valueGetter.invoke(item)); |
| | | } catch (IllegalAccessException | InvocationTargetException e) { |
| | | log.warn(e.getMessage(), e); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 将对象转换为map |
| | | * |
| | | * @param obj 对象 |
| | | * @return 键值对 |
| | | */ |
| | | public static Map<String, Object> objToMapNonJson(Object obj) { |
| | | Map<String, Object> map = new HashMap<>(8); |
| | | if (obj != null) { |
| | | BeanMap beanMap = BeanMap.create(obj); |
| | | for (Object key : beanMap.keySet()) { |
| | | Object value = beanMap.get(key); |
| | | map.put(key.toString(), value); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.utils; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import java.io.IOException; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | /** |
| | | * @ClassName JsonUtils |
| | | * @Description TODO |
| | | * @Author @lizijie |
| | | * @Date 2023-09-20 13:43 |
| | | * @Version 1.0 |
| | | */ |
| | | public class JsonUtils { |
| | | private static ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | /** |
| | | * 对象转json字符串 |
| | | * |
| | | * @param object |
| | | * @return |
| | | */ |
| | | public static String objectToJson(Object object) { |
| | | return objectToJson(object, null); |
| | | } |
| | | |
| | | /** |
| | | * 对象转json字符串 |
| | | * |
| | | * @param object 需要转换json的对象 |
| | | * @param defaultStr 如果抛异常的默认字符串 |
| | | * @return |
| | | */ |
| | | public static String objectToJson(Object object, String defaultStr) { |
| | | try { |
| | | return objectMapper.writeValueAsString(object); |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return defaultStr; |
| | | } |
| | | |
| | | /** |
| | | * json字符串转对象实体 |
| | | * |
| | | * @param jsonStr json字符串 |
| | | * @param object 转换异常的默认对象 |
| | | * @param <T> 泛型 |
| | | * @return |
| | | */ |
| | | public static <T> T jsonToObject(String jsonStr, T object) { |
| | | try { |
| | | return objectMapper.readValue(jsonStr, new TypeReference<T>() { |
| | | }); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return object; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * json字符串转对象实体 |
| | | * |
| | | * @param jsonStr json字符串 |
| | | * @param t 实体类的类型 |
| | | * @param <T> 泛型 |
| | | * @return |
| | | */ |
| | | public static <T> T jsonToObject(String jsonStr, Class<T> t) { |
| | | try { |
| | | return objectMapper.readValue(jsonStr, t); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * json字符串转对象实体 |
| | | * |
| | | * @param jsonStr json字符串 |
| | | * @param typeReference |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> T jsonToObject(String jsonStr, TypeReference<T> typeReference) { |
| | | try { |
| | | return objectMapper.readValue(jsonStr, typeReference); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * json字符串转Map |
| | | * |
| | | * @param jsonStr |
| | | * @param t |
| | | * @param v |
| | | * @param <K> |
| | | * @param <V> |
| | | * @return |
| | | */ |
| | | public static <K, V> Map<K, V> jsonToMap(String jsonStr, Class<K> t, Class<V> v) { |
| | | try { |
| | | return objectMapper.readValue(jsonStr, new TypeReference<Map<K, V>>() { |
| | | }); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | public static <K, V> Map<K, V> objectToMap(Object object, Class<K> t, Class<V> v) { |
| | | try { |
| | | return objectMapper.readValue(objectToJson(object), new TypeReference<Map<K, V>>() { |
| | | }); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * json字符串转集合 |
| | | * |
| | | * @param jsonStr json字符串 |
| | | * @param objectClass 类信息 |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> List<T> jsonToList(String jsonStr, Class<T> objectClass) { |
| | | try { |
| | | return objectMapper.readValue(jsonStr, new TypeReference<List<T>>() { |
| | | }); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | public static <T> List<T> convert(Collection<?> collection, Class<T> clazz) { |
| | | return jsonToList(objectToJson(collection), clazz); |
| | | } |
| | | } |
| | |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | @GetMapping("updateGuid") |
| | | @ApiOperation(value = "更新站点编号", notes = "更新站点编号") |
| | | public ResultMessage updateGuid(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id, |
| | | @RequestParam @ApiParam(value = "guid",name = "站点编号") String guid) { |
| | | |
| | | govMonitorPointService.updateList(id,guid); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "delete", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public ResultMessage delete(@RequestBody Map map) { |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | import com.moral.api.entity.Device; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | DeviceVO selectDeviceInfoById(Integer deviceId); |
| | | |
| | | List<Device> queryDeviceUnitAlarmInfo(); |
| | | List<Device> queryDeviceUnitAlarmInfo(@Param("region") String mac); |
| | | |
| | | } |
| | |
| | | @Transactional |
| | | void update(GovMonitorPoint govMonitorPoint); |
| | | |
| | | void updateList(Integer id,String guid); |
| | | |
| | | /** |
| | | *@Description: 删除政府站点 |
| | | *@Param: [id] |
| | |
| | | //设备信息存入redis |
| | | setDeviceInfoToRedis(mac, deviceInfo); |
| | | //刷新deviceInfo缓存 |
| | | CacheUtils.refreshDeviceAlarmInfo(); |
| | | CacheUtils.refreshDeviceAlarmInfo(mac); |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | |
| | | public void setRedisDevice() { |
| | | List<Device> list = lambdaQuery().eq(Device::getIsDelete,0).list(); |
| | | for(Device d : list){ |
| | | redisTemplate.opsForHash().delete(RedisConstants.DEVICE, d.getMac()); |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(d.getId()); |
| | | setDeviceInfoToRedis(d.getMac(), deviceInfo); |
| | | } |
| | |
| | | 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.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SysArea; |
| | | import com.moral.api.exception.BusinessException; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.GovMonitorPointMapper; |
| | | import com.moral.api.mapper.SysAreaMapper; |
| | |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.RegionCodeUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private OrganizationService organizationService; |
| | | |
| | | @Resource |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired(required = false) |
| | | private DeviceMapper deviceMapper; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void updateList(Integer id, String guid) { |
| | | ExecutorService executorService = Executors.newFixedThreadPool(2); |
| | | QueryWrapper<GovMonitorPoint> wrapper_govMonitorPoint = new QueryWrapper<>(); |
| | | wrapper_govMonitorPoint.eq("is_delete", Constants.NOT_DELETE); |
| | | wrapper_govMonitorPoint.eq("id", id); |
| | | List<GovMonitorPoint> govMonitorPoints = govMonitorPointMapper.selectList(wrapper_govMonitorPoint); |
| | | if (govMonitorPoints.size() == 0) { |
| | | throw new BusinessException("站点不存在!"); |
| | | } |
| | | GovMonitorPoint govMonitorPoint = govMonitorPoints.get(0); |
| | | String oldGuid = govMonitorPoint.getGuid(); |
| | | LambdaQueryChainWrapper<Device> wrapper = deviceService.lambdaQuery(); |
| | | wrapper.eq(Device::getIsDelete,0); |
| | | wrapper.eq(Device::getGuid,oldGuid); |
| | | List<Device> list = wrapper.list(); |
| | | list.forEach(it->it.setGuid(guid)); |
| | | |
| | | deviceService.updateBatchById(list); |
| | | |
| | | govMonitorPoint.setGuid(guid); |
| | | 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(oldGuid).append("->").append(guid).append(";"); |
| | | } |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | for(Device d : list){ |
| | | executorService.submit(()->{ |
| | | redisTemplate.opsForHash().delete(RedisConstants.DEVICE, d.getMac()); |
| | | Map<String, Object> deviceInfo = deviceService.selectDeviceInfoById(d.getId()); |
| | | redisTemplate.opsForHash().put(RedisConstants.DEVICE, d.getMac(), deviceInfo); |
| | | |
| | | }); |
| | | } |
| | | // 关闭线程池 |
| | | executorService.shutdown(); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Integer id) { |
| | | UpdateWrapper<GovMonitorPoint> wrapper_delete = new UpdateWrapper<>(); |
| | | wrapper_delete.eq("id", id).set("is_delete", Constants.DELETE); |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | |
| | | |
| | | public static void refreshDeviceAlarmInfo() { |
| | | |
| | | refreshDeviceAlarmInfo(null); |
| | | |
| | | |
| | | } |
| | | public static void refreshDeviceAlarmInfo(String mac){ |
| | | if(StringUtils.isEmpty(mac)){ |
| | | //删除缓存 |
| | | redisTemplate.delete(RedisConstants.DEVICE_INFO); |
| | | }else { |
| | | redisTemplate.opsForHash().delete(RedisConstants.DEVICE_INFO,mac); |
| | | } |
| | | //重新添加缓存 |
| | | List<Device> devices = deviceMapper.queryDeviceUnitAlarmInfo(); |
| | | List<Device> devices = deviceMapper.queryDeviceUnitAlarmInfo(mac); |
| | | |
| | | Map<String, SysDictData> unitMap = sysDictDataService.getDictDatasByType("unit"); |
| | | //查询对应的单位名称以及转换公式 |
| | | Map<String,Device> result = new HashMap<>(); |
| | |
| | | redisTemplate.opsForHash().putAll(RedisConstants.DEVICE_INFO,result); |
| | | } |
| | | |
| | | |
| | | |
| | | public static void refreshSpecialDeviceAlarmInfo() { |
| | | //删除缓存 |
| | | redisTemplate.delete(RedisConstants.SPECIAL_DEVICE_INFO); |
| | |
| | | on |
| | | d.`device_version_id` = oua.`version_id` and d.`organization_id` = oua.`organization_id` and oua.`is_delete` = 0 |
| | | where |
| | | d.`is_delete` = 0; |
| | | d.`is_delete` = 0 |
| | | <if test="mac != null and mac != '' "> |
| | | and d.mac = #{mac} |
| | | </if> |
| | | </select> |
| | | |
| | | |