Compare commits

...

15 Commits

24 changed files with 853 additions and 393 deletions

View File

@ -83,6 +83,10 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
throw new DisabledException("用户状态不正常,请联系管理员");
}
if (DateTimeUtil.dateTimeToString(LocalDateTime.now()).compareTo(userEntity.getOverTime()) > 0) {
throw new DisabledException("该账号已过期,请联系管理员");
}
// 认证逻辑
String encryptPassword = encry256(password + userEntity.getSalt());
if (encryptPassword.equals(userEntity.getPassword())) {

View File

@ -35,8 +35,10 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.OPTIONS).permitAll()
.antMatchers("/global/configuration/**").permitAll()
.antMatchers("/push/**").permitAll()
.antMatchers("/debug").permitAll()
.antMatchers("/queryFirePoint").permitAll()
.antMatchers("/queryNotice").permitAll()//查询通知
.antMatchers(HttpMethod.POST, "/add_email_event").permitAll()//新增邮件事件
.antMatchers(HttpMethod.POST, "/api/user/updateSysUser").permitAll()
.antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll()
.antMatchers(HttpMethod.GET, "/selectGlobalConfigValue").permitAll()

View File

@ -1,25 +0,0 @@
package com.xkrs.common.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry;
import org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer;
import static org.springframework.messaging.simp.SimpMessageType.MESSAGE;
import static org.springframework.messaging.simp.SimpMessageType.SUBSCRIBE;
/**
* @author xkrs
*/
@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages
.nullDestMatcher().authenticated()
.simpSubscribeDestMatchers("/user/queue/errors").permitAll()
.simpTypeMatchers(MESSAGE, SUBSCRIBE).denyAll()
.anyMessage().denyAll();
}
}

View File

@ -0,0 +1,90 @@
package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.EmailEventDao;
import com.xkrs.model.entity.EmailEventEntity;
import com.xkrs.model.qo.EmailEventQo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Locale;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
@RestController
public class EmailEventController {
public static Logger log = LoggerFactory.getLogger(EmailEventController.class);
private final Locale locale = LocaleContextHolder.getLocale();
@Resource
private EmailEventDao emailEventDao;
@PostMapping("/add_email_event")
public String addEmailEvent(@RequestBody EmailEventQo emailEventQo) {
try {
log.info("add_email_event 添加邮件事件:" + emailEventQo.toString());
EmailEventEntity emailEventEntity = new EmailEventEntity();
emailEventEntity.setEvent(emailEventQo.getEvent());
emailEventEntity.setEmail(emailEventQo.getEmail());
emailEventEntity.setLink(emailEventQo.getLink());
emailEventEntity.setBulkId(emailEventQo.getBulkId());
emailEventEntity.setTimestamp(emailEventQo.getTimestamp());
emailEventEntity.setReason(emailEventQo.getReason());
emailEventEntity.setBounceType(emailEventQo.getBounceType());
emailEventEntity.setUsername(emailEventQo.getUsername());
emailEventEntity.setFrom(emailEventQo.getFrom());
emailEventEntity.setFromDomain(emailEventQo.getFromDomain());
emailEventEntity.setTemplateId(emailEventQo.getTemplateId());
emailEventEntity.setUseragent(emailEventQo.getUseragent());
emailEventEntity.setSubject(emailEventQo.getSubject());
emailEventEntity.setMessageId(emailEventQo.getMessageId());
emailEventEntity.setEventId(emailEventQo.getEventId());
String eventId = emailEventQo.getEventId();
if ("delivered".equals(eventId)) {
emailEventEntity.setEventDesc("递送成功,收件人邮件服务商已接收此邮件");
}
if ("dropped".equals(eventId)) {
emailEventEntity.setEventDesc("因为某种原因,这封邮件不能送达,被丢弃");
}
if ("bounce".equals(eventId)) {
emailEventEntity.setEventDesc("收件人邮件服务商拒收此邮件(一般是因为邮箱地址错误)");
}
if ("open".equals(eventId)) {
emailEventEntity.setEventDesc("收件人打开了此邮件");
}
if ("click".equals(eventId)) {
emailEventEntity.setEventDesc("收件人点击了此邮件中的链接");
}
if ("spamreport".equals(eventId)) {
emailEventEntity.setEventDesc("收件人举报了此邮件");
}
if ("unsubscribe".equals(eventId)) {
emailEventEntity.setEventDesc("收件人点击了业务方的“退订”按钮需要业务方在退订链接中包含unsubscribe关键词");
}
if ("deferred".equals(eventId)) {
emailEventEntity.setEventDesc("邮件被收件人邮件服务商延迟传递,正在重试中");
}
emailEventDao.save(emailEventEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
} catch (Exception e) {
e.printStackTrace();
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加失败", locale);
}
}
}

View File

@ -11,14 +11,17 @@ import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.AuditFireTypeQo;
import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo;
import com.xkrs.model.vo.TianDiTuGeocodeVo;
import com.xkrs.service.FirePointService;
import com.xkrs.service.StreetService;
import com.xkrs.service.impl.FirePointServiceImpl;
import com.xkrs.utils.FirePointQueryHelper;
import com.xkrs.utils.TianDiTuApiUtil;
import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.web.bind.annotation.*;
@ -94,6 +97,50 @@ public class FirePointController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale);
}
@GetMapping("/debug")
public String debug() {
//使用天地图反查填补历史数据-start
System.out.println("开始解析");
while (true) {
//查询未审核的普通火点
Specification<FirePointEntity> specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<>();
predicateList.add(criteriaBuilder.isNull(root.get("streetCode").as(String.class)));
predicateList.add(criteriaBuilder.equal(root.get("streetCode").as(String.class), ""));
predicateList.add(criteriaBuilder.isNull(root.get("streetName").as(String.class)));
predicateList.add(criteriaBuilder.equal(root.get("streetName").as(String.class), ""));
predicateList.add(criteriaBuilder.isNull(root.get("firePointAddress").as(String.class)));
predicateList.add(criteriaBuilder.equal(root.get("firePointAddress").as(String.class), ""));
return criteriaBuilder.or(predicateList.toArray(new Predicate[predicateList.size()]));
};
//未审核的普通火点列表
PageRequest pageRequest = PageRequest.of(1, 1000, Sort.by(Sort.Direction.DESC, "satelliteTime"));
List<FirePointEntity> list = firePointDao.findAll(specificationOrdinary, pageRequest).getContent();
if (list.isEmpty()) {
break;
}
for (FirePointEntity item : list) {
try {
TianDiTuGeocodeVo geocode = TianDiTuApiUtil.geocode(item.getLongitude(), item.getLatitude());
TianDiTuGeocodeVo.ResultDTO.AddressComponentDTO addressComponent = geocode.result.addressComponent;
item.setFirePointAddress(geocode.result.formattedAddress);
item.setCountyCode(addressComponent.countyCode.substring(3, 9));
item.setCountyName(addressComponent.county);
item.setStreetCode(addressComponent.townCode.substring(3, 12));
item.setStreetName(addressComponent.town);
firePointDao.saveAndFlush(item);
System.out.println("解析成功");
} catch (Exception e) {
e.printStackTrace();
System.out.println("解析失败" + item.getId());
}
}
}
//使用天地图反查填补历史数据-end
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OKKKK", locale);
}
/**
* 添加火点数据
*

View File

@ -0,0 +1,10 @@
package com.xkrs.dao;
import com.xkrs.model.entity.EmailEventEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface EmailEventDao extends JpaRepository<EmailEventEntity, Long>, JpaSpecificationExecutor<EmailEventEntity> {
}

View File

@ -0,0 +1,260 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name = "email_event")
public class EmailEventEntity implements Serializable {
/**
* 指定主键建立自增序列主键值取自序列
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "email_event_seq_gen")
@SequenceGenerator(name = "email_event_seq_gen", sequenceName = "email_event_id_seq", allocationSize = 1)
private Long id;
/**
* 事件类型详情请参见 事件类型
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String event;
/**
* 收件人地址
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String email;
/**
* 用户点击的邮件中的链接 URL仅在 event="click"时生效
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String link;
/**
* SendEmail 接囗返回的 MessageId
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String bulkId;
/**
* 事件产生的时间戳
*/
private Long timestamp;
/**
* 邮件递送失败的原因
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String reason;
/**
* 如果收件人邮件服务商拒信拒信类型取值:soft bouncelhard bounce仅在 event="bounce”的时候生效
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String bounceType;
/**
* 腾讯云账号对应的 AppID
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String username;
/**
* 发信地址(不带发件人别名)
*/
@Column(name = "email_from", length = 255, columnDefinition = "varchar(255)")
private String from;
/**
* 发信域名
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String fromDomain;
/**
* 模板 ID
*/
private Long templateId;
/**
* 用户代理提供有关用于访问邮件的设备操作系统和浏览器的信息仅对 Open Click 事件生效
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String useragent;
/**
* 邮件主题
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String subject;
/**
* smtp 协议头中的 Message-ID用户在使用 smtp API发送时可以传自己定义的邮件唯一标识符注意这个一定
* 要能够唯一标识一封邮件目符合 RFC5322标准
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String messageId;
/**
* 事件ID
* 1:delivered 递送成功收件人邮件服务商已接收此邮件
* 2:dropped 因为某种原因这封邮件不能送达被丢弃
* 3:bounce 收件人邮件服务商拒收此邮件(一般是因为邮箱地址错误)
* 4.open 收件人打开了此邮件
* 5:click 收件人点击了此邮件中的链接
* 6:spamreport 收件人举报了此邮件
* 7:unsubscribe 收件人点击了业务方的退订按钮需要业务方在退订链接中包含"unsubscribe"关键词
* 8:deferred 邮件被收件人邮件服务商延迟传递正在重试中
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String eventId;
/**
* 事件描述
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String eventDesc;
public EmailEventEntity() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getBulkId() {
return bulkId;
}
public void setBulkId(String bulkId) {
this.bulkId = bulkId;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getBounceType() {
return bounceType;
}
public void setBounceType(String bounceType) {
this.bounceType = bounceType;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getFromDomain() {
return fromDomain;
}
public void setFromDomain(String fromDomain) {
this.fromDomain = fromDomain;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public String getUseragent() {
return useragent;
}
public void setUseragent(String useragent) {
this.useragent = useragent;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
public String getEventDesc() {
return eventDesc;
}
public void setEventDesc(String eventDesc) {
this.eventDesc = eventDesc;
}
}

View File

@ -0,0 +1,212 @@
package com.xkrs.model.qo;
public class EmailEventQo {
/**
* 事件类型详情请参见 事件类型
*/
private String event;
/**
* 收件人地址
*/
private String email;
/**
* 用户点击的邮件中的链接 URL仅在 event="click"时生效
*/
private String link;
/**
* SendEmail 接囗返回的 MessageId
*/
private String bulkId;
/**
* 事件产生的时间戳
*/
private Long timestamp;
/**
* 邮件递送失败的原因
*/
private String reason;
/**
* 如果收件人邮件服务商拒信拒信类型取值:soft bouncelhard bounce仅在 event="bounce”的时候生效
*/
private String bounceType;
/**
* 腾讯云账号对应的 AppID
*/
private String username;
/**
* 发信地址(不带发件人别名)
*/
private String from;
/**
* 发信域名
*/
private String fromDomain;
/**
* 模板 ID
*/
private Long templateId;
/**
* 用户代理提供有关用于访问邮件的设备操作系统和浏览器的信息仅对 Open Click 事件生效
*/
private String useragent;
/**
* 邮件主题
*/
private String subject;
/**
* smtp 协议头中的 Message-ID用户在使用 smtp API发送时可以传自己定义的邮件唯一标识符注意这个一定
* 要能够唯一标识一封邮件目符合 RFC5322标准
*/
private String messageId;
/**
* 事件ID
* 1:delivered 递送成功收件人邮件服务商已接收此邮件
* 2:dropped 因为某种原因这封邮件不能送达被丢弃
* 3:bounce 收件人邮件服务商拒收此邮件(一般是因为邮箱地址错误)
* 4.open 收件人打开了此邮件
* 5:click 收件人点击了此邮件中的链接
* 6:spamreport 收件人举报了此邮件
* 7:unsubscribe 收件人点击了业务方的退订按钮需要业务方在退订链接中包含"unsubscribe"关键词
* 8:deferred 邮件被收件人邮件服务商延迟传递正在重试中
*/
private String eventId;
public EmailEventQo() {
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getBulkId() {
return bulkId;
}
public void setBulkId(String bulkId) {
this.bulkId = bulkId;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getBounceType() {
return bounceType;
}
public void setBounceType(String bounceType) {
this.bounceType = bounceType;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getFromDomain() {
return fromDomain;
}
public void setFromDomain(String fromDomain) {
this.fromDomain = fromDomain;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public String getUseragent() {
return useragent;
}
public void setUseragent(String useragent) {
this.useragent = useragent;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
}

View File

@ -0,0 +1,66 @@
package com.xkrs.model.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
public class TianDiTuGeocodeVo {
@JsonProperty("result")
public ResultDTO result;
@JsonProperty("msg")
public String msg;
@JsonProperty("status")
public String status;
public static class ResultDTO {
@JsonProperty("formatted_address")
public String formattedAddress;
@JsonProperty("location")
public LocationDTO location;
@JsonProperty("addressComponent")
public AddressComponentDTO addressComponent;
public static class LocationDTO {
@JsonProperty("lon")
public Double lon;
@JsonProperty("lat")
public Double lat;
}
public static class AddressComponentDTO {
@JsonProperty("address")
public String address;
@JsonProperty("town")
public String town;
@JsonProperty("nation")
public String nation;
@JsonProperty("city")
public String city;
@JsonProperty("county_code")
public String countyCode;
@JsonProperty("poi_position")
public String poiPosition;
@JsonProperty("county")
public String county;
@JsonProperty("city_code")
public String cityCode;
@JsonProperty("address_position")
public String addressPosition;
@JsonProperty("poi")
public String poi;
@JsonProperty("province_code")
public String provinceCode;
@JsonProperty("town_code")
public String townCode;
@JsonProperty("province")
public String province;
@JsonProperty("road")
public String road;
@JsonProperty("road_distance")
public Integer roadDistance;
@JsonProperty("address_distance")
public Integer addressDistance;
@JsonProperty("poi_distance")
public Integer poiDistance;
}
}
}

View File

@ -1,13 +1,12 @@
package com.xkrs.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.*;
import com.xkrs.model.entity.CountyCodeWeiXinEntity;
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.model.entity.ShanDongFirePointEntity;
import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.model.vo.TianDiTuGeocodeVo;
import com.xkrs.service.FirePointService;
import com.xkrs.service.GlobalConfigService;
import com.xkrs.service.StreetService;
@ -95,10 +94,11 @@ public class FirePointServiceImpl implements FirePointService {
return false;
}
if ("Himawari 8".equals(firePointQo.getSatelliteType())) {
if ("N".equals(firePointQo.getConfidence()) || "L".equals(firePointQo.getConfidence())) {
if ("L".equals(firePointQo.getConfidence()) || "N".equals(firePointQo.getConfidence())) {
return false;
}
}
FirePointEntity firePointEntity = new FirePointEntity();
firePointEntity.setFireCode(firePointQo.getFireCode());
firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
@ -121,33 +121,9 @@ public class FirePointServiceImpl implements FirePointService {
}
log.info("-------发现新火点");
firePointDao.save(firePointEntity);
forwardPoint(firePointEntity);
//发送消息通知
sendBroadcast(firePointEntity);
return true;
// if (firePointEntity.getCountyCode().startsWith("37")) {
// //如果开关已打开就只将未审核的火点添加到山东临时表
// log.info("-------发现新山东火点");
// ShanDongFirePointEntity shanDongFirePointByFirePoint = getShanDongFirePointByFirePoint(firePointEntity);
// ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePointByFirePoint);
// //微信消息通知火点审核工作组
// try {
// String messageContent = getMessageContent(savedShanDongFirePoint);
// WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return true;
// }
}
private void forwardPoint(FirePointEntity firePointEntity) {
try {
String url = "http://121.36.229.60:6811/insertfirepointchannelThree";
HttpClientUtils.sendHttpPostTextPlain(url, new ObjectMapper().writeValueAsString(firePointEntity));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
@ -190,19 +166,17 @@ public class FirePointServiceImpl implements FirePointService {
* 为实体类绑定地址编号名称
*/
private void bindAddress(FirePointEntity firePointEntity) {
List<String> locationList = new ArrayList<>();
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
String formattedAddress = reGeoCode.getFormatted_address();
firePointEntity.setFirePointAddress(formattedAddress);
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
firePointEntity.setCountyCode(addressComponent.getAdcode());
firePointEntity.setCountyName(addressComponent.getDistrict());
String townCode = addressComponent.getTowncode();
String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode;
firePointEntity.setStreetCode(fixedTownCode);
firePointEntity.setStreetName(addressComponent.getTownship());
try {
TianDiTuGeocodeVo geocode = TianDiTuApiUtil.geocode(firePointEntity.getLongitude(), firePointEntity.getLatitude());
TianDiTuGeocodeVo.ResultDTO.AddressComponentDTO addressComponent = geocode.result.addressComponent;
firePointEntity.setFirePointAddress(geocode.result.formattedAddress);
firePointEntity.setCountyCode(addressComponent.countyCode.substring(3, 9));
firePointEntity.setCountyName(addressComponent.county);
firePointEntity.setStreetCode(addressComponent.townCode.substring(3, 12));
firePointEntity.setStreetName(addressComponent.town);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
@ -318,18 +292,7 @@ public class FirePointServiceImpl implements FirePointService {
String countyName = firePointEntity.getCountyName();
String streetName = firePointEntity.getStreetName();
String landType = firePointEntity.getLandType();
return firePointEntity.getSatelliteType() + "发现1个火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName + "\nstreetName" + streetName + "\nlandType" + landType;
}
private String getMessageContent(ShanDongFirePointEntity firePointEntity) {
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
String satelliteTime = firePointEntity.getSatelliteTime();
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
String countyName = firePointEntity.getCountyName();
String streetName = firePointEntity.getStreetName();
String landType = firePointEntity.getLandType();
return firePointEntity.getSatelliteType() + "发现1个待审核火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName + "\nstreetName" + streetName + "\nlandType" + landType;
return "星巡-全国火情播报系统\n" + firePointEntity.getSatelliteType() + "发现1个火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName + "\nstreetName" + streetName + "\nlandType" + landType;
}
/**

View File

@ -111,15 +111,15 @@ public class StreetServiceImpl implements StreetService {
// RegionBean countyBean = new RegionBean();
// countyBean.setCode(county.get("code"));
// countyBean.setName(county.get("name"));
//// List<Map<String, String>> streetList = selectStreetList(county.get("name"));
//// List<RegionBean> streetBeanList = new ArrayList<>();
//// for (Map<String, String> street : streetList) {
//// RegionBean streetBean = new RegionBean();
//// streetBean.setCode(street.get("code"));
//// streetBean.setName(street.get("name"));
//// streetBeanList.add(streetBean);
//// }
//// countyBean.setChildren(streetBeanList);
// List<Map<String, String>> streetList = selectStreetList(county.get("code"));
// List<RegionBean> streetBeanList = new ArrayList<>();
// for (Map<String, String> street : streetList) {
// RegionBean streetBean = new RegionBean();
// streetBean.setCode(street.get("code"));
// streetBean.setName(street.get("name"));
// streetBeanList.add(streetBean);
// }
// countyBean.setChildren(streetBeanList);
// countyBeanList.add(countyBean);
// }
// cityBean.setChildren(countyBeanList);

View File

@ -126,6 +126,7 @@ public class SysUserServiceImpl implements SysUserService {
String countyCode = sysUserQo.getCountyCode();
String countyName = sysUserQo.getCountyName();
countyName = adapterCountyNameByCountyCode(countyCode);
if (TextUtils.isEmpty(countyCode)) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道编码不能为空!", locale);
}
@ -141,8 +142,10 @@ public class SysUserServiceImpl implements SysUserService {
if (streetNameList == null || streetNameList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("街道级");
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(7L)));
adapterStreetUser(sysUserEntity);
} else if ("0000".equals(countyCode.substring(2))) {
List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode);
if (proCodeList == null || proCodeList.size() == 0) {
@ -152,8 +155,10 @@ public class SysUserServiceImpl implements SysUserService {
if (proNameList == null || proNameList.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("省级");
sysUserEntity.setActiveFlag(1);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
// adapterProUser(sysUserEntity);
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode);
if (cityCodeList == null || cityCodeList.size() == 0) {
@ -163,8 +168,10 @@ public class SysUserServiceImpl implements SysUserService {
if (cityNameList == null || cityNameList.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("市级");
sysUserEntity.setActiveFlag(1);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
adapterCityUser(sysUserEntity);
} else {
List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode);
if (countyCodeList == null || countyCodeList.isEmpty()) {
@ -174,13 +181,10 @@ public class SysUserServiceImpl implements SysUserService {
if (countyNameList == null || countyNameList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("县级");
}
if (9 == countyCode.length()) {//街道账号7天后过期
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(7L)));
} else {//省市区县账号5天后过期
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
adapterCountyUser(sysUserEntity);
}
sysUserEntity.setStatusCode(0);
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
@ -209,6 +213,81 @@ public class SysUserServiceImpl implements SysUserService {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "注册成功!", locale);
}
private String adapterCountyNameByCountyCode(String countyCode) {
if (9 == countyCode.length()) {
List<StreetEntity> streetCodeList = streetDao.findByStreetCode(countyCode);
if (streetCodeList == null || streetCodeList.isEmpty()) {
return null;
}
return streetCodeList.get(0).getStreetName();
} else if ("0000".equals(countyCode.substring(2))) {
List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode);
if (proCodeList == null || proCodeList.size() == 0) {
return null;
}
return proCodeList.get(0).getProName();
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode);
if (cityCodeList == null || cityCodeList.size() == 0) {
return null;
}
return cityCodeList.get(0).getCityName();
} else {
List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode);
if (countyCodeList == null || countyCodeList.isEmpty()) {
return null;
}
return countyCodeList.get(0).getCountyName();
}
}
/**
* 适配2023-11-09到2023-11-12之间注册的街道用户
*/
private void adapterStreetUser(SysUserEntity sysUserEntity) {
if (in1109To1112()) {
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(180L)));
}
}
// private void adapterProUser(SysUserEntity sysUserEntity) {
// if (in1109To1112()) {
// sysUserEntity.setActiveFlag(1);
// sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
// }
// }
/**
* 适配2023-11-09到2023-11-12之间注册的市级用户
*/
private void adapterCityUser(SysUserEntity sysUserEntity) {
if (in1109To1112()) {
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(30L)));
}
}
/**
* 适配2023-11-09到2023-11-12之间注册的区县用户
*/
private void adapterCountyUser(SysUserEntity sysUserEntity) {
if (in1109To1112()) {
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(30L)));
}
}
/**
* 判断当前是否处于2023-11-09到2023-11-12之间注册的
*/
private boolean in1109To1112() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime start1109 = LocalDateTime.of(2023, 11, 9, 0, 0, 0, 0);
LocalDateTime end1112 = LocalDateTime.of(2023, 11, 13, 0, 0, 0, 0);
return start1109.isBefore(now) && end1112.isAfter(now);
}
/**
* 新增用户
*
@ -247,8 +326,9 @@ public class SysUserServiceImpl implements SysUserService {
if (streetNameList == null || streetNameList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("街道级");
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(7L)));
} else if ("0000".equals(countyCode.substring(2))) {
List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode);
if (proCodeList == null || proCodeList.size() == 0) {
@ -258,8 +338,9 @@ public class SysUserServiceImpl implements SysUserService {
if (proNameList == null || proNameList.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("省级");
sysUserEntity.setActiveFlag(1);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode);
if (cityCodeList == null || cityCodeList.size() == 0) {
@ -269,8 +350,9 @@ public class SysUserServiceImpl implements SysUserService {
if (cityNameList == null || cityNameList.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("市级");
sysUserEntity.setActiveFlag(1);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
} else {
List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode);
if (countyCodeList == null || countyCodeList.isEmpty()) {
@ -280,12 +362,8 @@ public class SysUserServiceImpl implements SysUserService {
if (countyNameList == null || countyNameList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
}
sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("县级");
}
if (9 == countyCode.length()) {//街道账号7天后过期
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(7L)));
} else {//省市区县账号5天后过期
sysUserEntity.setActiveFlag(0);
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
}
sysUserEntity.setStatusCode(0);

View File

@ -19,9 +19,9 @@ public class AliYunSmsUtils {
//产品域名,开发者无需替换
String domain = "dysmsapi.aliyuncs.com";
//此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
String accessKeyId = "LTAI5tMSjLfu8Xu2w6WeguFF";
String accessKeyId = "LTAI5tMa5Va4CSwFwXxKpKfc";
//修改成自己的
String accessKeySecret = "hvqM5zpi72hvX4VXM71wq6AE0XYtDI";
String accessKeySecret = "PIUhRNVcApBF3H8TzU8pM1ZI6fjvWQ";
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");

View File

@ -0,0 +1,41 @@
package com.xkrs.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xkrs.model.vo.TianDiTuGeocodeVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
public class TianDiTuApiUtil {
private static final Logger log = LoggerFactory.getLogger(TianDiTuApiUtil.class);
public static TianDiTuGeocodeVo geocode(double longitude, double latitude) {
try {
Map<String, Object> jsonObject = new HashMap<>();
jsonObject.put("lon", longitude);
jsonObject.put("lat", latitude);
jsonObject.put("ver", 1);
String jsonParams = new JSONObject(jsonObject).toString();
String encodedParams = URLEncoder.encode(jsonParams, "UTF-8");
String url = "http://api.tianditu.gov.cn/geocoder?postStr=" + encodedParams + "&type=geocode&tk=e16fa4bdf9a5f59195239ea28622e3d5";
return JSON.parseObject(HttpClientUtils.sendHttpGet(url), TianDiTuGeocodeVo.class);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
TianDiTuGeocodeVo geocode = geocode(110.89, 36.78);
}
}

View File

@ -1,25 +0,0 @@
package com.xkrs.websocket.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
/**
* websocket广播配置
* @author xkrs
*/
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketBrokerConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/endPointClientServer").withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/ws");
}
}

View File

@ -1,16 +0,0 @@
package com.xkrs.websocket.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* @author xkrs
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter(){
return new ServerEndpointExporter();
}
}

View File

@ -1,18 +0,0 @@
package com.xkrs.websocket.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author xkrs
*/
@RestController
@RequestMapping("/test")
public class TestController {
@GetMapping("/hello")
public String sayHello(){
return "asdasd";
}
}

View File

@ -1,24 +0,0 @@
package com.xkrs.websocket.controller.websocket;
import com.xkrs.websocket.service.WebSocketServer;
import org.springframework.web.bind.annotation.*;
/**
* @author xkrs
*/
@RestController
@RequestMapping("/api/socket")
public class WebSocketController {
@GetMapping("/sendAll")
public String sendAll(@RequestParam String msg) {
WebSocketServer.broadInfo(msg);
return "success";
}
@RequestMapping(value = "/sendOne", method = RequestMethod.GET)
public String sendOne(@RequestParam String msg, @RequestParam String session) {
WebSocketServer.sendMsg(msg, session);
return "success";
}
}

View File

@ -1,17 +0,0 @@
package com.xkrs.websocket.controller.websocketbroker;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* @author xkrs
*/
@Configuration
public class ViewController extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/ws").setViewName("/ws");
}
}

View File

@ -1,21 +0,0 @@
package com.xkrs.websocket.controller.websocketbroker;
import com.xkrs.websocket.websocket.ClientServerMessage;
import com.xkrs.websocket.websocket.ServerClientMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
/**
* @author xkrs
*/
@Controller
public class WebSocketBrokerController {
@MessageMapping("/hello")
@SendTo("/ws/getResponse")
public ServerClientMessage say(ClientServerMessage message) throws InterruptedException {
Thread.sleep(3000);
return new ServerClientMessage("hello," + message.getName() + "!");
}
}

View File

@ -1,128 +0,0 @@
package com.xkrs.websocket.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author xkrs
*/
@Component
@ServerEndpoint(value = "/ws/asset")
public class WebSocketServer {
@PostConstruct
public void init() {
System.out.println("websocketBroker loading......");
}
private static Logger log = LoggerFactory.getLogger(WebSocketServer.class);
private static final AtomicInteger ONLINE_COUNT = new AtomicInteger(0);
private static CopyOnWriteArraySet<Session> sessionSet = new CopyOnWriteArraySet<>();
/**
* 连接建立
*/
@OnOpen
public void onOpen(Session session) {
sessionSet.add(session);
//在线加1
int cnt = ONLINE_COUNT.incrementAndGet();
//log.info("have a new connect:{}", cnt);
//sendMsg(session, "connect success");
}
/**
* 连接关闭
*
* @param session
*/
@OnClose
public void onClose(Session session) {
sessionSet.remove(session);
//在线减1
int cnt = ONLINE_COUNT.decrementAndGet();
log.info("have a connect close:{}", cnt);
}
/**
* 收到客户端消息后调用的方法
*
* @param session
* @param msg
*/
@OnMessage
public void onMessage(String msg, Session session) {
log.info("receive the msg:{}", msg);
}
private static void sendMsg(Session session, String msg) {
try {
session.getBasicRemote().sendText(String.format(msg));
} catch (IOException e) {
log.error("发送信息出错:{}", e.getMessage());
e.printStackTrace();
}
}
private static void sendDate(Session session, Map map) {
try {
session.getBasicRemote().sendObject(map);
} catch (IOException | EncodeException e) {
log.error("发送信息出错:{}", e.getMessage());
e.printStackTrace();
}
}
/**
* 指定session发送
*/
public static void sendMsg(String msg, String sessionId) {
Session session = null;
for (Session s : sessionSet) {
if (s.getId().equals(sessionId)) {
session = s;
break;
}
}
if (session != null) {
sendMsg(session, msg);
} else {
log.warn("not find your session");
}
}
/**
* 群发消息
*/
public static void broadInfo(String msg) {
for (Session s : sessionSet) {
synchronized (sessionSet){
if (s.isOpen()) {
sendMsg(s, msg);
}
}
}
}
/**
* 群发map消息
* @param map
*/
public static void broadInfoMap(Map map) {
for (Session s : sessionSet) {
if (s.isOpen()) {
sendDate(s, map);
}
}
}
}

View File

@ -1,18 +0,0 @@
package com.xkrs.websocket.websocket;
/**
* @author xkrs
*/
public class ClientServerMessage {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String name;
}

View File

@ -1,21 +0,0 @@
package com.xkrs.websocket.websocket;
/**
* @author xkrs
*/
public class ServerClientMessage {
public String getResponseMsg() {
return responseMsg;
}
public void setResponseMsg(String responseMsg) {
this.responseMsg = responseMsg;
}
private String responseMsg;
public ServerClientMessage(String responseMsg) {
this.responseMsg = responseMsg;
}
}

View File

@ -1,7 +1,7 @@
server.port = 6801
## 数据源配置
spring.datasource.url = jdbc:postgresql://8.142.26.238:5432/fire_point
spring.datasource.url = jdbc:postgresql://8.142.26.238:5432/fire_point_new
spring.datasource.userName = fire_manage
spring.datasource.password = fire456
spring.datasource.driverClassName = org.postgresql.Driver