Commit 5d78743b authored by hanbing's avatar hanbing

Merge remote-tracking branch 'origin/master'

parents 556070c0 9a9e61d0
package net.wanji.web.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfigurer implements WebMvcConfigurer {
/**
* 跨域支持
* @param registry
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "DELETE", "PUT")
.allowedHeaders("*")
.maxAge(3600 * 24);
}
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ package net.wanji.web.controller; ...@@ -4,6 +4,7 @@ package net.wanji.web.controller;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import net.wanji.web.common.Result; import net.wanji.web.common.Result;
import net.wanji.web.po.AreaTreePO;
import net.wanji.web.po.CrossInfoPO; import net.wanji.web.po.CrossInfoPO;
import net.wanji.web.po.PageResultPO; import net.wanji.web.po.PageResultPO;
import net.wanji.web.service.TBaseCrossInfoService; import net.wanji.web.service.TBaseCrossInfoService;
...@@ -11,10 +12,7 @@ import net.wanji.web.vo.BaseCrossInfoVO; ...@@ -11,10 +12,7 @@ import net.wanji.web.vo.BaseCrossInfoVO;
import net.wanji.web.vo.CrossInfoVO; import net.wanji.web.vo.CrossInfoVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -36,13 +34,13 @@ public class TBaseCrossInfoController { ...@@ -36,13 +34,13 @@ public class TBaseCrossInfoController {
@ApiOperation(value = "路网管理-路口管理-查询", notes = "路网管理-路口管理-查询") @ApiOperation(value = "路网管理-路口管理-查询", notes = "路网管理-路口管理-查询")
@PostMapping("/list") @PostMapping("/list")
public Result<PageResultPO<CrossInfoPO>> list(@RequestBody CrossInfoVO crossInfoVO) { public Result<PageResultPO<CrossInfoPO>> list(@RequestBody @Validated CrossInfoVO crossInfoVO) {
return crossInfoService.selectAll(crossInfoVO); return crossInfoService.selectAll(crossInfoVO);
} }
@ApiOperation(value = "路网管理-路口管理-修改", notes = "路网管理-路口管理-修改") @ApiOperation(value = "路网管理-路口管理-修改", notes = "路网管理-路口管理-修改")
@PostMapping("/updateOne") @PostMapping("/updateOne")
public Result<String> updateOne(@RequestBody @Validated BaseCrossInfoVO crossInfoPO) { public Result<String> updateOne(@RequestBody @Validated(BaseCrossInfoVO.Update.class) BaseCrossInfoVO crossInfoPO) {
return crossInfoService.updateOne(crossInfoPO); return crossInfoService.updateOne(crossInfoPO);
} }
...@@ -54,8 +52,14 @@ public class TBaseCrossInfoController { ...@@ -54,8 +52,14 @@ public class TBaseCrossInfoController {
@ApiOperation(value = "路网管理-路口管理-增加", notes = "路网管理-路口管理-增加") @ApiOperation(value = "路网管理-路口管理-增加", notes = "路网管理-路口管理-增加")
@PostMapping("/addOne") @PostMapping("/addOne")
public Result<String> addOne(@RequestBody @Validated BaseCrossInfoVO crossInfoPO) { public Result<String> addOne(@RequestBody @Validated(BaseCrossInfoVO.Save.class) BaseCrossInfoVO crossInfoPO) {
return crossInfoService.addOne(crossInfoPO); return crossInfoService.addOne(crossInfoPO);
} }
@ApiOperation(value = "路网管理-路口管理-区域名称下拉框", notes = "路网管理-路口管理-区域名称下拉框")
@GetMapping("/areaTree")
public Result<List<AreaTreePO>> areaTree() {
return crossInfoService.areaTree();
}
} }
package net.wanji.web.mapper; package net.wanji.web.mapper;
import net.wanji.web.entity.TBaseAreaInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.web.entity.TBaseAreaInfo;
import net.wanji.web.po.AreaTreePO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* <p> * <p>
* 区域基础表 Mapper 接口 * 区域基础表 Mapper 接口
...@@ -29,4 +32,7 @@ public interface TBaseAreaInfoMapper extends BaseMapper<TBaseAreaInfo> { ...@@ -29,4 +32,7 @@ public interface TBaseAreaInfoMapper extends BaseMapper<TBaseAreaInfo> {
int updateByPrimaryKeyWithBLOBs(TBaseAreaInfo record); int updateByPrimaryKeyWithBLOBs(TBaseAreaInfo record);
int updateByPrimaryKey(TBaseAreaInfo record); int updateByPrimaryKey(TBaseAreaInfo record);
List<AreaTreePO> selectAreaTree();
} }
package net.wanji.web.po;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* <p>
* 区域基础表
* </p>
*
* @author wj
* @since 2022-11-28
*/
@Getter
@Setter
public class AreaTreePO {
/**
* 行政区划代码
*/
private Integer areaCode;
/**
* 行政区划名称
*/
private String areaName;
private Integer parentCode;
private List<AreaTreePO> children;
}
package net.wanji.web.po; package net.wanji.web.po;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
...@@ -8,6 +8,7 @@ import net.wanji.web.entity.TBaseAreaInfo; ...@@ -8,6 +8,7 @@ import net.wanji.web.entity.TBaseAreaInfo;
import net.wanji.web.entity.TBaseCrossInfo; import net.wanji.web.entity.TBaseCrossInfo;
import net.wanji.web.mapper.TBaseAreaInfoMapper; import net.wanji.web.mapper.TBaseAreaInfoMapper;
import net.wanji.web.mapper.TBaseCrossInfoMapper; import net.wanji.web.mapper.TBaseCrossInfoMapper;
import net.wanji.web.po.AreaTreePO;
import net.wanji.web.po.CrossInfoPO; import net.wanji.web.po.CrossInfoPO;
import net.wanji.web.po.PageResultPO; import net.wanji.web.po.PageResultPO;
import net.wanji.web.vo.BaseCrossInfoVO; import net.wanji.web.vo.BaseCrossInfoVO;
...@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -86,16 +89,29 @@ public class TBaseCrossInfoService extends ServiceImpl<TBaseCrossInfoMapper, TBa ...@@ -86,16 +89,29 @@ public class TBaseCrossInfoService extends ServiceImpl<TBaseCrossInfoMapper, TBa
} }
private TBaseCrossInfo getBaseCrossInfo(BaseCrossInfoVO crossInfoPO) { private TBaseCrossInfo getBaseCrossInfo(BaseCrossInfoVO crossInfoPO) {
QueryWrapper<TBaseAreaInfo> queryWrapper = new QueryWrapper<>(); if (crossInfoPO.getAreaCode() == null) {
queryWrapper.like("name", crossInfoPO.getAreaName()); QueryWrapper<TBaseAreaInfo> queryWrapper = new QueryWrapper<>();
// 查询areaCode queryWrapper.like("name", crossInfoPO.getAreaName());
List<TBaseAreaInfo> tBaseAreaInfos = areaInfoMapper.selectList(queryWrapper); // 查询areaCode
if (tBaseAreaInfos != null && tBaseAreaInfos.size() > 0) { List<TBaseAreaInfo> tBaseAreaInfos = areaInfoMapper.selectList(queryWrapper);
crossInfoPO.setAreaCode(tBaseAreaInfos.get(0).getCode()); if (tBaseAreaInfos != null && tBaseAreaInfos.size() > 0) {
crossInfoPO.setAreaCode(tBaseAreaInfos.get(0).getCode());
}
}
if (crossInfoPO.getAreaName() == null) {
QueryWrapper<TBaseAreaInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", crossInfoPO.getAreaCode());
List<TBaseAreaInfo> tBaseAreaInfos = areaInfoMapper.selectList(queryWrapper);
if (tBaseAreaInfos != null && tBaseAreaInfos.size() > 0) {
crossInfoPO.setAreaName(tBaseAreaInfos.get(0).getName());
}
} }
TBaseCrossInfo record = new TBaseCrossInfo(); TBaseCrossInfo record = new TBaseCrossInfo();
BeanUtils.copyProperties(crossInfoPO, record); BeanUtils.copyProperties(crossInfoPO, record);
record.setGmtModified(new Date()); record.setGmtModified(new Date());
if (record.getLocation() == null) {
record.setLocation("null");
}
return record; return record;
} }
...@@ -109,4 +125,26 @@ public class TBaseCrossInfoService extends ServiceImpl<TBaseCrossInfoMapper, TBa ...@@ -109,4 +125,26 @@ public class TBaseCrossInfoService extends ServiceImpl<TBaseCrossInfoMapper, TBa
crossInfoMapper.deleteBatchIds(ids); crossInfoMapper.deleteBatchIds(ids);
return Result.success("删除成功"); return Result.success("删除成功");
} }
/**
* 区域名称下拉框
*
* @return {@link Result}<{@link AreaTreePO}>
*/
public Result<List<AreaTreePO>> areaTree() {
List<AreaTreePO> infos = areaInfoMapper.selectAreaTree();
// 构建树
Map<Integer, List<AreaTreePO>> parentCodeMap = infos.stream().collect(Collectors.groupingBy(AreaTreePO::getParentCode));
for (AreaTreePO info : infos) {
for (Integer parentCode : parentCodeMap.keySet()) {
if (info.getAreaCode().equals(parentCode)) {
info.setChildren(parentCodeMap.get(parentCode));
break;
}
}
}
infos = infos.stream().filter(po -> po.getParentCode() == null).collect(Collectors.toList());
return Result.success(infos);
}
} }
...@@ -24,74 +24,86 @@ public class BaseCrossInfoVO { ...@@ -24,74 +24,86 @@ public class BaseCrossInfoVO {
* 路口ID * 路口ID
*/ */
@ApiModelProperty(value = "路口ID", required = true) @ApiModelProperty(value = "路口ID", required = true)
@NotNull(message = "路口ID不可为空") @NotNull(message = "路口ID不可为空", groups = Update.class)
private String id; private String id;
/** /**
* 路口名称 * 路口名称
*/ */
@ApiModelProperty(value = "路口名称", required = true) @ApiModelProperty(value = "路口名称", required = true)
@NotNull(message = "路口名称不可为空") @NotNull(message = "路口名称不可为空", groups = {Save.class, Update.class})
private String name; private String name;
/** /**
* 路口类型 * 路口类型
*/ */
@ApiModelProperty(value = "路口类型", required = true) @ApiModelProperty(value = "路口类型", required = true)
@NotNull(message = "路口类型不可为空") @NotNull(message = "路口类型不可为空", groups = {Save.class, Update.class})
private Integer type; private Integer type;
/** /**
* 路口级别 * 路口级别
*/ */
@ApiModelProperty(value = "路口级别", required = true) @ApiModelProperty(value = "路口级别", required = true)
@NotNull(message = "路口级别不可为空") @NotNull(message = "路口级别不可为空", groups = {Save.class, Update.class})
private Integer level; private Integer level;
/** /**
* 行政区划代码 * 行政区划代码
*/ */
@ApiModelProperty(value = "行政区划代码") @ApiModelProperty(value = "行政区划代码")
@NotNull(message = "行政区划代码不可为空", groups = {Save.class, Update.class})
private Integer areaCode; private Integer areaCode;
/** /**
* 行政区划名称 * 行政区划名称
*/ */
@ApiModelProperty(value = "行政区划名称", required = true) @ApiModelProperty(value = "行政区划名称", required = true)
@NotNull(message = "行政区划名称不可为空") private String areaName;
private Integer areaName;
/** /**
* 路口位置 * 路口位置
*/ */
@ApiModelProperty(value = "路口位置", required = true) @ApiModelProperty(value = "路口位置", required = true)
@NotNull(message = "路口位置不可为空") //@NotNull(message = "路口位置不可为空", groups = {Save.class, Update.class})
private String location; private String location;
/** /**
* 是否信控路口:1是;0否 * 是否信控路口:1是;0否
*/ */
@ApiModelProperty(value = "是否信控路口:1是;0否", required = true) @ApiModelProperty(value = "是否信控路口:1是;0否", required = true)
@NotNull(message = "是否信控路口不可为空") @NotNull(message = "是否信控路口不可为空", groups = {Save.class, Update.class})
@Max(value = 1, message = "是否信控路口:1是;0否") @Max(value = 1, message = "是否信控路口:1是;0否", groups = {Save.class, Update.class})
@Min(value = 0, message = "是否信控路口:1是;0否") @Min(value = 0, message = "是否信控路口:1是;0否", groups = {Save.class, Update.class})
private Integer isSignal; private Integer isSignal;
/** /**
* 是否启动优化:1是;0否 * 是否启动优化:1是;0否
*/ */
@ApiModelProperty(value = "是否启动优化:1是;0否", required = true) @ApiModelProperty(value = "是否启动优化:1是;0否", required = true)
@NotNull(message = "是否启动优化不可为空") @NotNull(message = "是否启动优化不可为空", groups = {Save.class, Update.class})
@Max(value = 1, message = "是否启动优化:1是;0否") @Max(value = 1, message = "是否启动优化:1是;0否", groups = {Save.class, Update.class})
@Min(value = 0, message = "是否启动优化:1是;0否") @Min(value = 0, message = "是否启动优化:1是;0否", groups = {Save.class, Update.class})
private Integer isStart; private Integer isStart;
/** /**
* 是否下发方案:1是;0否 * 是否下发方案:1是;0否
*/ */
@ApiModelProperty(value = "是否下发方案:1是;0否", required = true) @ApiModelProperty(value = "是否下发方案:1是;0否", required = true)
@NotNull(message = "是否下发方案不可为空") @NotNull(message = "是否下发方案不可为空", groups = {Save.class, Update.class})
@Max(value = 1, message = "是否下发方案:1是;0否") @Max(value = 1, message = "是否下发方案:1是;0否", groups = {Save.class, Update.class})
@Min(value = 0, message = "是否下发方案:1是;0否") @Min(value = 0, message = "是否下发方案:1是;0否", groups = {Save.class, Update.class})
private Integer isSend; private Integer isSend;
/**
* 保存的时候校验分组
*/
public interface Save {
}
/**
* 更新的时候校验分组
*/
public interface Update {
}
} }
...@@ -4,10 +4,6 @@ import io.swagger.annotations.ApiModel; ...@@ -4,10 +4,6 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/** /**
* @author wj * @author wj
* @date 2022/11/28 9:42:39 * @date 2022/11/28 9:42:39
...@@ -20,41 +16,36 @@ public class CrossInfoVO { ...@@ -20,41 +16,36 @@ public class CrossInfoVO {
* 路口名称 * 路口名称
*/ */
@ApiModelProperty(value = "路口名称", required = true) @ApiModelProperty(value = "路口名称", required = true)
@NotNull(message = "路口名称不可为空")
private String name; private String name;
/**
* 行政区划代码
*/
@ApiModelProperty(value = "行政区划代码", required = true)
private Integer areaCode;
/** /**
* 行政区划名称 * 行政区划名称
*/ */
@ApiModelProperty(value = "行政区划名称", required = true) @ApiModelProperty(value = "行政区划名称", required = true)
@NotNull(message = "行政区划名称不可为空")
private String areaName; private String areaName;
/** /**
* 是否信控路口:1是;0否 * 是否信控路口:1是;0否
*/ */
@ApiModelProperty(value = "是否信控路口:1是;0否", required = true) @ApiModelProperty(value = "是否信控路口:1是;0否", required = true)
@NotNull(message = "是否信控路口不可为空")
@Max(value = 1, message = "是否信控路口:1是;0否")
@Min(value = 0, message = "是否信控路口:1是;0否")
private Integer isSignal; private Integer isSignal;
/** /**
* 是否启动优化:1是;0否 * 是否启动优化:1是;0否
*/ */
@ApiModelProperty(value = "是否启动优化:1是;0否", required = true) @ApiModelProperty(value = "是否启动优化:1是;0否", required = true)
@NotNull(message = "是否启动优化不可为空")
@Max(value = 1, message = "是否启动优化:1是;0否")
@Min(value = 0, message = "是否启动优化:1是;0否")
private Integer isStart; private Integer isStart;
/** /**
* 是否下发方案:1是;0否 * 是否下发方案:1是;0否
*/ */
@ApiModelProperty(value = "是否下发方案:1是;0否", required = true) @ApiModelProperty(value = "是否下发方案:1是;0否", required = true)
@NotNull(message = "是否下发方案不可为空")
@Max(value = 1, message = "是否下发方案:1是;0否")
@Min(value = 0, message = "是否下发方案:1是;0否")
private Integer isSend; private Integer isSend;
@ApiModelProperty(value = "当前页") @ApiModelProperty(value = "当前页")
......
...@@ -15,6 +15,7 @@ spring: ...@@ -15,6 +15,7 @@ spring:
master: master:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://10.100.1.74:3306/t_signal_control?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'&useSSL=false&useCursorFetch=true url: jdbc:mysql://10.100.1.74:3306/t_signal_control?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'&useSSL=false&useCursorFetch=true
# url: jdbc:mysql://10.102.1.112:53306/t_signal_control?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'&useSSL=false&useCursorFetch=true
username: root username: root
password: Wanji300552 password: Wanji300552
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
......
...@@ -155,4 +155,7 @@ ...@@ -155,4 +155,7 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="selectAreaTree" resultType="net.wanji.web.po.AreaTreePO">
select code areaCode, name areaName, parent parentCode from t_base_area_info
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -191,6 +191,9 @@ ...@@ -191,6 +191,9 @@
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and c.name like concat('%',#{name},'%') and c.name like concat('%',#{name},'%')
</if> </if>
<if test="areaCode != null and areaCode != ''">
and a.code = #{areaCode}
</if>
<if test="areaName != null and areaName != ''"> <if test="areaName != null and areaName != ''">
and a.name = #{areaName} and a.name = #{areaName}
</if> </if>
...@@ -216,6 +219,9 @@ ...@@ -216,6 +219,9 @@
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and c.name like concat('%',#{name},'%') and c.name like concat('%',#{name},'%')
</if> </if>
<if test="areaCode != null and areaCode != ''">
and a.code = #{areaCode}
</if>
<if test="areaName != null and areaName != ''"> <if test="areaName != null and areaName != ''">
and a.name = #{areaName} and a.name = #{areaName}
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment