代码提交

master
徐杰盟 2024-06-17 11:17:33 +08:00
parent 83081a269b
commit 68f09fe882
10 changed files with 113 additions and 62 deletions

View File

@ -43,4 +43,10 @@ comment on column "FXKH_TXL"."ADDRESS_BOOK"."IS_PASS" is '是否放行, 放行:t
# 2024年6月13日15:18:35
alter table "FXKH_TXL"."ADDRESS_BOOK_OLD" add column("SALT" VARCHAR(50));
comment on column "FXKH_TXL"."ADDRESS_BOOK_OLD"."SALT" is '';
comment on column "FXKH_TXL"."ADDRESS_BOOK_OLD"."SALT" is '';
alter table "FXKH_TXL"."QXWARNING" modify "PUBLISH_TIME" DATETIME(0);
alter table "FXKH_TXL"."QXWARNING" modify "START_TIME" DATETIME(0);
alter table "FXKH_TXL"."QXWARNING" modify "END_TIME" DATETIME(0);

View File

@ -24,12 +24,11 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -212,6 +211,7 @@ public class QXWarnController {
List<AddressBookOld> dpples = addressBookOldService.getListByAdnm2(cnnm2);
System.out.println("dpple个数" + dpples.size());
for (AddressBookOld dpple : dpples) {
dpple.decryptPhone();
WarnDppleVO warndpple = new WarnDppleVO();
warndpple.setCtnm(dto.getCtnm());
warndpple.setCnnm(cnnm);
@ -409,50 +409,53 @@ public class QXWarnController {
*/
@ApiOperation(value = "历史气象预警查询")
@PostMapping("/getHistoryWarning")
@Cacheable(value = THIS_REDIS_KEY, key = "#root.method.name+':'+#dto.toString()")
// @Cacheable(value = THIS_REDIS_KEY, key = "#root.method.name+':'+#dto.toString()")
public ResultJson<HistoryWarnsVO> getHistoryWarning(@RequestBody GroupWarningDto dto) {
List<QXWarningVO> warnList = new ArrayList<>();
HistoryWarnsVO historyWarnsVO = new HistoryWarnsVO();
ApiDto apiDto = new ApiDto();
apiDto.setStartTime(dto.getStartTime());//一年的起始时间
apiDto.setEndTime(dto.getEndTime());//当前时间
apiDto.setPageNumber(dto.getPageNumber());//第几页
apiDto.setPageSize(dto.getPageSize());//一页10个
ArrayList<ApiDto.Filter> filter = Lists.newArrayList();
// List<QXWarningVO> warnList = new ArrayList<>();
// HistoryWarnsVO historyWarnsVO = new HistoryWarnsVO();
// ApiDto apiDto = new ApiDto();
// apiDto.setStartTime(dto.getStartTime());//一年的起始时间
// apiDto.setEndTime(dto.getEndTime());//当前时间
// apiDto.setPageNumber(dto.getPageNumber());//第几页
// apiDto.setPageSize(dto.getPageSize());//一页10个
// ArrayList<ApiDto.Filter> filter = Lists.newArrayList();
//
// int pageNumber = dto.getPageNumber();
// int pageSize = dto.getPageSize();
//
// String publishUnit = dto.getPublishUnit();
// String warnSignalLevel = dto.getWarnSignalLevel();
// String warnSignalType = dto.getWarnSignalType();
// apiDto.setFilter(filter);
// String str = HttpUtil.sendPost("http://223.75.53.141:8000/shzh/met/zyqxfw/api/warning/getGroupWarning", JSON.toJSONString(apiDto));
//// String str = HttpUtil.sendPost("http://127.0.0.1:20000/shzh/met/zyqxfw/api/warning/getGroupWarning", JSON.toJSONString(apiDto));
// JSONObject json = JSON.parseObject(str);
// if (json != null && json.getInteger("code") == HttpStatus.SC_OK) {
// List<WarningData> data = json.getJSONArray("data").toJavaList(WarningData.class);
// int count = getCount2(data);
// System.out.println("历史预警数量:" + data.size());
// System.out.println("历史预警数量2" + count);
// historyWarnsVO.setCount(count);
// //查找最近10条数据,放到warnList属性上
// List<QXWarningVO> qxWarningList = null;
// //getLatestTen(data);
// if (Objects.isNull(pageNumber) || Objects.isNull(pageSize)) {
// System.out.println("pageNumber和pageSize有至少一个为null");
// qxWarningList = getLatestTen(data);
// } else {
// System.out.println("pageNumber和pageSize全不为null");
// System.out.println("pageNumber:" + pageNumber);
// System.out.println("pageSize:" + pageSize);
// qxWarningList = getPageWarning(data, pageNumber, pageSize);
// }
// historyWarnsVO.setWarnList(qxWarningList);
// return ResultJson.ok(historyWarnsVO);
// }
//
// return ResultJson.ok("");
int pageNumber = dto.getPageNumber();
int pageSize = dto.getPageSize();
return ResultJson.ok(service.page(dto));
String publishUnit = dto.getPublishUnit();
String warnSignalLevel = dto.getWarnSignalLevel();
String warnSignalType = dto.getWarnSignalType();
apiDto.setFilter(filter);
String str = HttpUtil.sendPost("http://223.75.53.141:8000/shzh/met/zyqxfw/api/warning/getGroupWarning", JSON.toJSONString(apiDto));
// String str = HttpUtil.sendPost("http://127.0.0.1:20000/shzh/met/zyqxfw/api/warning/getGroupWarning", JSON.toJSONString(apiDto));
JSONObject json = JSON.parseObject(str);
if (json != null && json.getInteger("code") == HttpStatus.SC_OK) {
List<WarningData> data = json.getJSONArray("data").toJavaList(WarningData.class);
int count = getCount2(data);
System.out.println("历史预警数量:" + data.size());
System.out.println("历史预警数量2" + count);
historyWarnsVO.setCount(count);
//查找最近10条数据,放到warnList属性上
List<QXWarningVO> qxWarningList = null;
//getLatestTen(data);
if (Objects.isNull(pageNumber) || Objects.isNull(pageSize)) {
System.out.println("pageNumber和pageSize有至少一个为null");
qxWarningList = getLatestTen(data);
} else {
System.out.println("pageNumber和pageSize全不为null");
System.out.println("pageNumber:" + pageNumber);
System.out.println("pageSize:" + pageSize);
qxWarningList = getPageWarning(data, pageNumber, pageSize);
}
historyWarnsVO.setWarnList(qxWarningList);
return ResultJson.ok(historyWarnsVO);
}
return ResultJson.ok("");
}
/**
@ -887,13 +890,13 @@ public class QXWarnController {
public ResultJson<QXWarnStatisticsVo> totalquery(@PathVariable("stm") @ApiParam(name = "stm", value = "开始时间, yyyy-MM-dd") String stmStr,
@PathVariable("etm") @ApiParam(name = "etm", value = "结束时间, yyyy-MM-dd") String etmStr) {
LocalDate stm = LocalDate.parse(stmStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate etm = LocalDate.parse(etmStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
DateTimeFormatter pattern = DateTimeFormatter.ofPattern(DateUtils.DATE_TIME_PATTERN);
LocalDateTime stm = LocalDateTime.parse(stmStr, DateTimeFormatter.ofPattern(DateUtils.DATE_TIME_PATTERN));
LocalDateTime etm = LocalDateTime.parse(etmStr, DateTimeFormatter.ofPattern(DateUtils.DATE_TIME_PATTERN));
QXWarnStatisticsVo vo = new QXWarnStatisticsVo();
String str = HttpUtil.getBySetCookie("https://shdata.cloudowr.cn/shwarn/msg/totalquery?stm=" + stm + "&etm=" + etm,
String str = HttpUtil.getBySetCookie("https://shdata.cloudowr.cn/shwarn/msg/totalquery?stm=" + stm.toLocalDate().toString() + "&etm=" + etm.toLocalDate().toString(),
"userobj=%7B%22_id%22%3A%2260a7da8809d9cfa5622920a6%22%2C%22name%22%3A%22%E9%B2%A7%E7%9F%B3%E5%80%BC%E7%8F%AD%E4%B8%93%E7%94%A8%22%2C%22phone%22%3A%2218888888888%22%2C%22utype%22%3A0%2C%22dept%22%3A%22%E9%B2%A7%E7%9F%B3%22%2C%22tm%22%3A%222024-03-23T01%3A54%3A46.225Z%22%2C%22token%22%3A%226726a6d2e96b902d23381a19dcdc18cb%22%2C%22ctm%22%3A%222021-05-21T16%3A06%3A32.707Z%22%2C%22chkc%22%3Afalse%2C%22ywjk%22%3Afalse%2C%22yywh%22%3Afalse%7D; token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3aXRoRXhwaXJlc0F0IjoxNzE4MzMzNTYzOTE3LCJleHAiOjE3MTgzMzM1NjMsInVzZXJuYW1lIjoiYWRtaW4ifQ.-leem8iPu0zzPuGtRTZ-Lp5m_mLBzX1UzJfLbDBSpjc");
JSONObject json = JSON.parseObject(str);
if (json != null && json.getInteger("ok") == 1) {
@ -941,14 +944,16 @@ public class QXWarnController {
vo.setShWarnStr(warnStr.toString());
}
List<QXWarning> list = service.getWarnAndMsg(stm.toString(), etm.toString());
List<QXWarning> list = service.getWarnAndMsg(stm.format(pattern), etm.format(pattern));
if (CollectionUtils.isNotEmpty(list)) {
StringBuilder warnStr = new StringBuilder();
warnStr.append(stm.getYear()).append("年").append(stm.getMonthValue()).append("月").append(stm.getDayOfMonth()).append("日至")
.append(etm.getYear()).append("年").append(etm.getMonthValue()).append("月").append(etm.getDayOfMonth()).append("日,");
Map<String, List<QXWarning>> map = list.stream()
List<QXWarning> qxWarnings = service.lambdaQuery().between(QXWarning::getPublishTime, stm, etm).list();
Map<String, List<QXWarning>> map = qxWarnings.stream()
.collect(Collectors.groupingBy(QXWarning::getWarnSignalLevel));
List<QXWarning> orange = map.get("橙色");
List<QXWarning> red = map.get("红色");

View File

@ -1,6 +1,8 @@
package com.whdc.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.whdc.model.dto.GroupWarningDto;
import com.whdc.model.entity.QXWarning;
import org.apache.ibatis.annotations.Param;
@ -10,5 +12,7 @@ public interface QXWarningMapper extends BaseMapper<QXWarning> {
List<QXWarning> find(@Param("dto")QXWarning dto);
List<QXWarning> findByMsgIsNull();
IPage<QXWarning> page(@Param("page") IPage<QXWarning> page, @Param("dto") GroupWarningDto dto);
List<QXWarning> getWarnAndMsg(@Param("stm") String stm,@Param("etm") String etm);
}

View File

@ -11,7 +11,7 @@ import lombok.Data;
* @version 1.0
*/
@Data
public class GroupWarningDto {
public class GroupWarningDto extends FindPageDto{
@ApiModelProperty(value = "开始时间, 格式应为yyyy-MM-dd HH:mm:ss", dataType = "java.lang.String", example = "2023-06-15 08:00:00")
private String startTime;

View File

@ -15,6 +15,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotNull;
@ -22,8 +23,6 @@ import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
import static com.whdc.utils.SymmetricEncryption.decrypt;
/**
* Description:
* Created by XuSan on 2024/6/11.
@ -36,6 +35,7 @@ import static com.whdc.utils.SymmetricEncryption.decrypt;
@Accessors(chain = true)
@ApiModel(description = "通讯录")
@TableName("FXKH_TXL.ADDRESS_BOOK_OLD")
@Slf4j
public class AddressBookOld extends Model<AddressBookOld> implements Serializable {
@ -69,7 +69,7 @@ public class AddressBookOld extends Model<AddressBookOld> implements Serializabl
@ApiModelProperty(value = "手机号")
private String phone;
@TableField("SAIT")
@TableField("SALT")
@ApiModelProperty(value = "盐")
private String salt;
@ -84,8 +84,11 @@ public class AddressBookOld extends Model<AddressBookOld> implements Serializabl
this.salt = UUID.randomUUID().toString().replaceAll("-", "");
}
try {
this.phone = decrypt(this.phone,this.salt);
if (StringUtils.isNotBlank(this.phone)){
this.phone = SymmetricEncryption.encrypt(this.phone,this.salt);
}
} catch (Exception e) {
log.info(phone + " " + salt);
throw new MyException("加密失败",e);
}
return this;
@ -93,8 +96,11 @@ public class AddressBookOld extends Model<AddressBookOld> implements Serializabl
public AddressBookOld decryptPhone(){
try {
this.phone = SymmetricEncryption.encrypt(this.phone,this.salt);
if (StringUtils.isNotBlank(this.phone) && StringUtils.isNotBlank(this.salt)){
this.phone = SymmetricEncryption.decrypt(this.phone,this.salt);
}
}catch (Exception e){
log.info(phone + " " + salt);
throw new MyException("解密失败",e);
}
return this;

View File

@ -1,11 +1,15 @@
package com.whdc.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.whdc.model.dto.GroupWarningDto;
import com.whdc.model.entity.QXWarning;
import java.util.List;
public interface IQXWarningService extends IService<QXWarning> {
List<QXWarning> find();
IPage<QXWarning> page(GroupWarningDto dto);
List<QXWarning> getWarnAndMsg(String stm,String etm);
}

View File

@ -1,7 +1,9 @@
package com.whdc.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whdc.mapper.QXWarningMapper;
import com.whdc.model.dto.GroupWarningDto;
import com.whdc.model.entity.QXWarning;
import com.whdc.service.IQXWarningService;
import lombok.extern.slf4j.Slf4j;
@ -17,6 +19,11 @@ public class QXWarningServiceImpl extends ServiceImpl<QXWarningMapper, QXWarnin
return getBaseMapper().findByMsgIsNull();
}
@Override
public IPage<QXWarning> page(GroupWarningDto dto) {
return getBaseMapper().page(dto.getPage(),dto);
}
@Override
public List<QXWarning> getWarnAndMsg(String stm, String etm) {
return getBaseMapper().getWarnAndMsg(stm,etm);

View File

@ -20,11 +20,10 @@ public class SymmetricEncryption {
private static final int KEY_SIZE = 128;
public static void main(String[] args) throws Exception {
String data = "Hello World!";
String encryptedData = encrypt(data, "password");
String decryptedData = decrypt(encryptedData, "password");
String encryptedData = encrypt("82402321", "0492716ae0314f0496d62e0de215059a");
String decryptedData = decrypt("lJM1xLd93ghNeWVTNNjjJw==", "4e1f078b917d4c7ca3e7eec1f683d3c2");
System.out.println("Original Data: " + data);
System.out.println("Original Data: " + 82402321);
System.out.println("Encrypted Data: " + encryptedData);
System.out.println("Decrypted Data: " + decryptedData);
}
@ -47,7 +46,10 @@ public class SymmetricEncryption {
private static SecretKey generateKey(String password) throws Exception {
KeyGenerator keyGenerator = KeyGenerator.getInstance(ALGORITHM);
keyGenerator.init(KEY_SIZE, new SecureRandom(password.getBytes()));
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
secureRandom.setSeed(password.getBytes());
keyGenerator.init(KEY_SIZE, secureRandom);
// keyGenerator.init(KEY_SIZE, new SecureRandom(password.getBytes()));
return new SecretKeySpec(keyGenerator.generateKey().getEncoded(), ALGORITHM);
}
}

View File

@ -30,6 +30,7 @@ spring:
filters: stat,wall,log4j #wall表示排除防火请
logSlowSql: true
#jpa配置
jpa:
properties:

View File

@ -16,6 +16,7 @@
WF.HANDLE_TIME BETWEEN #{stm} AND #{etm}
AND Q.WARN_SIGNAL_LEVEL IS NOT NULL
AND Q.CNNM IS NOT NULL
ORDER BY Q.WARNID DESC
</select>
<select id="findByMsgIsNull" resultType="com.whdc.model.vo.QXWarningVO">
SELECT
@ -24,6 +25,21 @@
FXKH_TXL.QXWARNING Q
LEFT JOIN FXKH_TXL.WARNMSG_FEEDBACK WF ON WF.WARNID = Q.WARNID
WHERE
Q.ID IS NULL
WF.ID IS NULL
ORDER BY Q.WARNID DESC
</select>
<select id="page" resultType="com.whdc.model.vo.QXWarningVO">
SELECT
Q.*,IF( WF.ID IS NOT NULL,1,0) STATUS
FROM
FXKH_TXL.QXWARNING Q
LEFT JOIN FXKH_TXL.WARNMSG_FEEDBACK WF ON WF.WARNID = Q.WARNID
WHERE
1 = 1
<if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
AND Q.PUBLISH_TIME BETWEEN #{dto.startTime} AND #{dto.endTime}
</if>
ORDER BY Q.WARNID DESC
</select>
</mapper>