Browse Source

Merge branch 'refs/heads/feature-v1.3.0' into feature-v1.4.0

# Conflicts:
#	shuili-admin/src/main/java/com/kms/web/controller/system/SysLoginController.java
#	shuili-common/src/main/java/com/shuili/common/utils/ip/IpUtils.java
master_tdsql
hxh 9 months ago
parent
commit
28aaf0f08f
  1. 3
      pom.xml
  2. 10
      shuili-admin/src/main/java/com/kms/web/controller/common/CommonController.java
  3. 47
      shuili-admin/src/main/java/com/kms/web/controller/system/SysLoginController.java
  4. 370
      shuili-common/src/main/java/com/shuili/common/utils/ip/IpUtils.java
  5. 8
      shuili-system/src/main/java/com/kms/yxgh/df/dto/DfRecordDetailDto.java
  6. 2
      shuili-system/src/main/java/com/kms/yxgh/df/dto/DfRecordSimpleDto.java
  7. 3
      shuili-system/src/main/java/com/kms/yxgh/df/dto/DfSubPlanSimpleDto.java
  8. 5
      shuili-system/src/main/java/com/kms/yxgh/df/mapper/DfPlanMapper.java
  9. 38
      shuili-system/src/main/java/com/kms/yxgh/df/service/DfRecordService.java
  10. 2
      sql/sy/v1.3.0/全量脚本/v1.3.0-all.sql
  11. 1
      sql/sy/v1.3.0/增量脚本/v1.3.0-update.sql

3
pom.xml

@ -47,7 +47,7 @@
<oshi.version>3.9.1</oshi.version>
<swagger.version>2.9.2</swagger.version>
<io-swagger.version>1.6.2</io-swagger.version>
<commons.io.version>2.11.0</commons.io.version>
<commons.io.version>2.16.1</commons.io.version>
<commons.fileupload.version>1.5</commons.fileupload.version>
<poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version>
@ -55,7 +55,6 @@
<jna.version>5.8.0</jna.version>
<fastdfs.version>1.27.2</fastdfs.version>
<libthrift.version>0.10.0</libthrift.version>
</properties>
<dependencies>

10
shuili-admin/src/main/java/com/kms/web/controller/common/CommonController.java

@ -171,16 +171,6 @@ public class CommonController {
}
@PostMapping("/logout")
@SaCheckLogin
public AjaxResult logout() {
// 登录保存缓存
StpUtil.logout();
//删除缓存
return AjaxResult.success();
}
/**
* 从fastDfs 使用文件路径
*/

47
shuili-admin/src/main/java/com/kms/web/controller/system/SysLoginController.java

@ -1,6 +1,7 @@
package com.kms.web.controller.system;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -97,27 +98,41 @@ public class SysLoginController extends BaseController {
// permissionService.setUserMenuFromPortal("1", menus);
// }
@PostMapping("/login-proxy")
@Data
public static class ProxyInfo {
private String type;
private String url;
}
@GetMapping("/login-proxy")
@ApiOperation("登陆代理")
public ModelAndView loginProxy(HttpServletRequest httpRequest) {
public AjaxResult loginProxy() {
if (StringUtils.isNotBlank(this.portalUrl)) {
RedirectView redirectView = new RedirectView(this.portalUrl);
return new ModelAndView(redirectView);
return AjaxResult.success(new ProxyInfo() {{
setType("redirect");
setUrl(portalUrl);
}});
} else {
String ip = getRealIp(httpRequest);
if (IpUtils.UNKNOWN.equals(ip)) {
throw new RuntimeException("获取登陆ip失败");
}
String loginPath = "#/login";
if (ip.endsWith("/")) {
ip = ip + loginPath;
} else {
ip = ip + "/" + loginPath;
}
log.debug("重定向地址:{}", ip);
return new ModelAndView(new RedirectView(ip));
String loginPath = "login";
return AjaxResult.success(new ProxyInfo() {{
setType("local");
setUrl(loginPath);
}});
}
}
@PostMapping("/logout")
@SaCheckLogin
public AjaxResult logout() {
// 登录保存缓存
StpUtil.logout();
//删除缓存
return AjaxResult.success();
}
public String getRealIp(HttpServletRequest request) {
String ip = request.getHeader("X-Forwarded-For");

370
shuili-common/src/main/java/com/shuili/common/utils/ip/IpUtils.java

@ -44,189 +44,189 @@ public class IpUtils {
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip);
}
public static boolean internalIp(String ip) {
byte[] addr = textToNumericFormatV4(ip);
return internalIp(addr) || "127.0.0.1".equals(ip);
}
private static boolean internalIp(byte[] addr) {
if (StringUtils.isNull(addr) || addr.length < 2) {
return true;
}
final byte b0 = addr[0];
final byte b1 = addr[1];
// 10.x.x.x/8
final byte SECTION_1 = 0x0A;
// 172.16.x.x/12
final byte SECTION_2 = (byte) 0xAC;
final byte SECTION_3 = (byte) 0x10;
final byte SECTION_4 = (byte) 0x1F;
// 192.168.x.x/16
final byte SECTION_5 = (byte) 0xC0;
final byte SECTION_6 = (byte) 0xA8;
switch (b0) {
case SECTION_1:
return true;
case SECTION_2:
if (b1 >= SECTION_3 && b1 <= SECTION_4) {
return true;
}
case SECTION_5:
switch (b1) {
case SECTION_6:
return true;
}
default:
return false;
}
}
/**
* 将IPv4地址转换成字节
*
* @param text IPv4地址
* @return byte 字节
*/
public static byte[] textToNumericFormatV4(String text) {
if (text.length() == 0) {
return null;
}
byte[] bytes = new byte[4];
String[] elements = text.split("\\.", -1);
try {
long l;
int i;
switch (elements.length) {
case 1:
l = Long.parseLong(elements[0]);
if ((l < 0L) || (l > 4294967295L)) {
return null;
}
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 2:
l = Integer.parseInt(elements[0]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[0] = (byte) (int) (l & 0xFF);
l = Integer.parseInt(elements[1]);
if ((l < 0L) || (l > 16777215L)) {
return null;
}
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 3:
for (i = 0; i < 2; ++i) {
l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
l = Integer.parseInt(elements[2]);
if ((l < 0L) || (l > 65535L)) {
return null;
}
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 4:
for (i = 0; i < 4; ++i) {
l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
break;
default:
return null;
}
} catch (NumberFormatException e) {
return null;
}
return bytes;
}
public static String getMacByIp(String ip) {
String macAddr = null;
try {
Process process = Runtime.getRuntime().exec("nbtstat -a " + ip);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
Pattern pattern = Pattern.compile("([A-F0-9]{2}-){5}[A-F0-9]{2}");
Matcher matcher;
for (String strLine = br.readLine(); strLine != null; strLine = br.readLine()) {
matcher = pattern.matcher(strLine);
if (matcher.find()) {
macAddr = matcher.group();
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(macAddr);
return macAddr;
}
public static String getHostIp() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
}
return "127.0.0.1";
}
public static String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
}
return "未知";
}
/*
* 验证IP是否属于某个IP段
*
* ipSection IP段'-'分隔 ip 所验证的IP号码
*
*/
public static boolean ipExistsInRange(String ip, String ipStrat, String ipEnd) {
ip = ip.trim();
String beginIP = ipStrat.trim();
String endIP = ipEnd.trim();
return getIp2long(beginIP) <= getIp2long(ip) && getIp2long(ip) <= getIp2long(endIP);
}
public static long getIp2long(String ip) {
ip = ip.trim();
String[] ips = ip.split("\\.");
long ip2long = 0L;
for (int i = 0; i < 4; ++i) {
ip2long = ip2long << 8 | Integer.parseInt(ips[i]);
}
return ip2long;
}
public static long getIp2long2(String ip) {
ip = ip.trim();
String[] ips = ip.split("\\.");
long ip1 = Integer.parseInt(ips[0]);
long ip2 = Integer.parseInt(ips[1]);
long ip3 = Integer.parseInt(ips[2]);
long ip4 = Integer.parseInt(ips[3]);
long ip2long = 1L * ip1 * 256 * 256 * 256 + ip2 * 256 * 256 + ip3 * 256 + ip4;
return ip2long;
}
public static boolean internalIp(String ip) {
byte[] addr = textToNumericFormatV4(ip);
return internalIp(addr) || "127.0.0.1".equals(ip);
}
private static boolean internalIp(byte[] addr) {
if (StringUtils.isNull(addr) || addr.length < 2) {
return true;
}
final byte b0 = addr[0];
final byte b1 = addr[1];
// 10.x.x.x/8
final byte SECTION_1 = 0x0A;
// 172.16.x.x/12
final byte SECTION_2 = (byte) 0xAC;
final byte SECTION_3 = (byte) 0x10;
final byte SECTION_4 = (byte) 0x1F;
// 192.168.x.x/16
final byte SECTION_5 = (byte) 0xC0;
final byte SECTION_6 = (byte) 0xA8;
switch (b0) {
case SECTION_1:
return true;
case SECTION_2:
if (b1 >= SECTION_3 && b1 <= SECTION_4) {
return true;
}
case SECTION_5:
switch (b1) {
case SECTION_6:
return true;
}
default:
return false;
}
}
/**
* 将IPv4地址转换成字节
*
* @param text IPv4地址
* @return byte 字节
*/
public static byte[] textToNumericFormatV4(String text) {
if (text.length() == 0) {
return null;
}
byte[] bytes = new byte[4];
String[] elements = text.split("\\.", -1);
try {
long l;
int i;
switch (elements.length) {
case 1:
l = Long.parseLong(elements[0]);
if ((l < 0L) || (l > 4294967295L)) {
return null;
}
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 2:
l = Integer.parseInt(elements[0]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[0] = (byte) (int) (l & 0xFF);
l = Integer.parseInt(elements[1]);
if ((l < 0L) || (l > 16777215L)) {
return null;
}
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 3:
for (i = 0; i < 2; ++i) {
l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
l = Integer.parseInt(elements[2]);
if ((l < 0L) || (l > 65535L)) {
return null;
}
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 4:
for (i = 0; i < 4; ++i) {
l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
break;
default:
return null;
}
} catch (NumberFormatException e) {
return null;
}
return bytes;
}
public static String getMacByIp(String ip) {
String macAddr = null;
try {
Process process = Runtime.getRuntime().exec("nbtstat -a " + ip);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
Pattern pattern = Pattern.compile("([A-F0-9]{2}-){5}[A-F0-9]{2}");
Matcher matcher;
for (String strLine = br.readLine(); strLine != null; strLine = br.readLine()) {
matcher = pattern.matcher(strLine);
if (matcher.find()) {
macAddr = matcher.group();
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(macAddr);
return macAddr;
}
public static String getHostIp() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
}
return "127.0.0.1";
}
public static String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
}
return "未知";
}
/*
* 验证IP是否属于某个IP段
*
* ipSection IP段'-'分隔 ip 所验证的IP号码
*
*/
public static boolean ipExistsInRange(String ip, String ipStrat, String ipEnd) {
ip = ip.trim();
String beginIP = ipStrat.trim();
String endIP = ipEnd.trim();
return getIp2long(beginIP) <= getIp2long(ip) && getIp2long(ip) <= getIp2long(endIP);
}
public static long getIp2long(String ip) {
ip = ip.trim();
String[] ips = ip.split("\\.");
long ip2long = 0L;
for (int i = 0; i < 4; ++i) {
ip2long = ip2long << 8 | Integer.parseInt(ips[i]);
}
return ip2long;
}
public static long getIp2long2(String ip) {
ip = ip.trim();
String[] ips = ip.split("\\.");
long ip1 = Integer.parseInt(ips[0]);
long ip2 = Integer.parseInt(ips[1]);
long ip3 = Integer.parseInt(ips[2]);
long ip4 = Integer.parseInt(ips[3]);
long ip2long = 1L * ip1 * 256 * 256 * 256 + ip2 * 256 * 256 + ip3 * 256 + ip4;
return ip2long;
}
}

8
shuili-system/src/main/java/com/kms/yxgh/df/dto/DfRecordDetailDto.java

@ -46,7 +46,7 @@ public class DfRecordDetailDto {
private String dikeType;
@ApiModelProperty("状态")
private String status = "0";
private String status;
@ApiModelProperty("隐患状态")
private String handleStatus;
@ -108,11 +108,13 @@ public class DfRecordDetailDto {
private String createName;
@ApiModelProperty("所有巡查项目")
private Long allItem;
private Long allItem = 0L;
private Long remaining = 0L;
@ApiModelProperty("当前已巡查项")
public Long getCurrentItem() {
return (long) Optional.ofNullable(this.items).map(List::size).orElse(0);
return allItem - remaining;
}

2
shuili-system/src/main/java/com/kms/yxgh/df/dto/DfRecordSimpleDto.java

@ -76,9 +76,11 @@ public class DfRecordSimpleDto {
@ApiModelProperty("记录结束时间")
private Date endDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("子项开始时间")
private Date subPlanStartDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("子项结束时间")
private Date subPlanEndDate;

3
shuili-system/src/main/java/com/kms/yxgh/df/dto/DfSubPlanSimpleDto.java

@ -43,6 +43,9 @@ public class DfSubPlanSimpleDto {
@ApiModelProperty("子计划名称")
private String subPlanName;
@ApiModelProperty("路线类型")
private String lineType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("子计划开始时间")
private Date subPlanStartDate;

5
shuili-system/src/main/java/com/kms/yxgh/df/mapper/DfPlanMapper.java

@ -13,7 +13,6 @@ import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -107,10 +106,10 @@ public interface DfPlanMapper extends BaseMapper<DfPlan> {
"AND exists (select 1 from bs_sgc_df_xsjhzx zx where zx.operator_uid = #{searchDto.user}) " +
"</if>" +
"<if test='searchDto != null and searchDto.isStart != null and searchDto.isStart == true'>" +
"AND r.remaining > 0 " +
"AND r.id is not null " +
"</if>" +
"<if test='searchDto != null and searchDto.isStart != null and searchDto.isStart == false'>" +
"AND r.remaining = 0 " +
"AND r.id is null " +
"</if>" +
"ORDER BY last_time desc,sub.start_date " +
"</script>")

38
shuili-system/src/main/java/com/kms/yxgh/df/service/DfRecordService.java

@ -91,6 +91,7 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> {
throw new DfException("巡查记录不存在");
}
record.setStatus("1");
record.setEndDate(new Date());
this.getBaseMapper().updateById(record);
return this.getDetailById(id);
}
@ -151,26 +152,28 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> {
DfRecord record = this.getBaseMapper().selectById(id);
if (record != null) {
DfRecordDetailDto dto = BeanCopyUtils.copy(record, DfRecordDetailDto.class);
Wrapper<DfRecordItem> wp = Wrappers.<DfRecordItem>lambdaQuery().eq(DfRecordItem::getRecordId, id);
List<DfRecordItem> items = recordItemService.list(wp);
if (CollectionUtil.isNotEmpty(items) && dto != null) {
if (dto != null) {
DfCheckingLine line = checkingLineMapper.selectById(record.getLineId());
dto.setEntries(Optional.ofNullable(line).map(DfCheckingLine::getPoints).orElse(""));
dto.setCreateName(userService.userName(dto.getCreateUid()));
dto.setItems(StreamUtils.toList(items, r -> {
DfRecordItemDto itemDto = BeanCopyUtils.copy(r, DfRecordItemDto.class);
if (itemDto != null) {
itemDto.setParts(Arrays.stream(StringUtils.split(r.getParts(), PART_SEPARATOR))
.sorted(Comparator.comparingInt(String::length)).collect(Collectors.toList()));
DfRecordItem.Doc doc = r.getDocObj();
if (doc != null) {
itemDto.setProblemImages(doc.getProblemImages());
itemDto.setHandleImages(doc.getHandleImages());
itemDto.setProblemVoices(doc.getProblemVoices());
Wrapper<DfRecordItem> wp = Wrappers.<DfRecordItem>lambdaQuery().eq(DfRecordItem::getRecordId, id);
List<DfRecordItem> items = recordItemService.list(wp);
if (CollectionUtil.isNotEmpty(items)) {
dto.setItems(StreamUtils.toList(items, r -> {
DfRecordItemDto itemDto = BeanCopyUtils.copy(r, DfRecordItemDto.class);
if (itemDto != null) {
itemDto.setParts(Arrays.stream(StringUtils.split(r.getParts(), PART_SEPARATOR))
.sorted(Comparator.comparingInt(String::length)).collect(Collectors.toList()));
DfRecordItem.Doc doc = r.getDocObj();
if (doc != null) {
itemDto.setProblemImages(doc.getProblemImages());
itemDto.setHandleImages(doc.getHandleImages());
itemDto.setProblemVoices(doc.getProblemVoices());
}
}
}
return itemDto;
}));
return itemDto;
}));
}
if (line != null && StringUtils.isNotBlank(line.getXcId())) {
dto.setAllItem((long) dfCheckingItemMapper.selectCount(Wrappers.<DfCheckingItem>lambdaQuery().eq(DfCheckingItem::getXcId, line.getXcId())));
}
@ -190,6 +193,7 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> {
if (line == null) {
throw new DfException("巡查路线不存在");
}
record = Optional.ofNullable(BeanCopyUtils.copy(dfRecord, DfRecord.class)).orElse(record);
int itemCount = dfCheckingItemMapper.selectCount(Wrappers.<DfCheckingItem>lambdaQuery().eq(DfCheckingItem::getXcId, line.getXcId()));
record.setHandleStatus(handleStatus(dfRecord));
record.setRemaining((long) itemCount - dfRecord.getItems().size());
@ -199,7 +203,7 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> {
.collect(Collectors.toList());
recordItemService.saveOrUpdateBatch(items);
}
this.baseMapper.updateById(BeanCopyUtils.copy(dfRecord, DfRecord.class));
this.baseMapper.updateById(record);
return dfRecord;
}

2
sql/sy/v1.3.0/全量脚本/v1.3.0-all.sql

@ -96,7 +96,7 @@ CREATE TABLE `bs_sgc_df_xsjhjl` (
`SCOPE` varchar(50) COLLATE utf8mb4_general_ci COMMENT '巡查范围',
`NAME` varchar(50) COLLATE utf8mb4_general_ci NOT NULL COMMENT '巡查记录名称',
`HANDLE_STATUS` int NOT NULL COMMENT '处置状态',
`STATUS` int NOT NULL COMMENT '记录状态',
`STATUS` int COMMENT '记录状态',
`REMARK` text COLLATE utf8mb4_general_ci COMMENT '备注',
`CREATE_UID` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间',

1
sql/sy/v1.3.0/增量脚本/v1.3.0-update.sql

@ -1,4 +1,5 @@
SET NAMES utf8mb4;
ALTER TABLE bs_sgc_df_xsjhjl MODIFY COLUMN STATUS int NULL COMMENT '状态';
CREATE TABLE `bs_sgc_df_xslx` (
`ID` int NOT NULL AUTO_INCREMENT COMMENT '堤防巡视检查路线查编号',

Loading…
Cancel
Save