三江项目通过地址查询编码
This commit is contained in:
parent
cc565109bf
commit
36d5da539d
@ -13,6 +13,7 @@ import io.netty.channel.socket.SocketChannel;
|
|||||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||||
import io.netty.handler.codec.string.StringDecoder;
|
import io.netty.handler.codec.string.StringDecoder;
|
||||||
import io.netty.handler.codec.string.StringEncoder;
|
import io.netty.handler.codec.string.StringEncoder;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -26,6 +27,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
* @date 2020/03/17 15:45:35
|
* @date 2020/03/17 15:45:35
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class TcpNettyServer {
|
public class TcpNettyServer {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TcpNettyHandler tcpNettyHandler;
|
private TcpNettyHandler tcpNettyHandler;
|
||||||
@ -35,7 +37,6 @@ public class TcpNettyServer {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void startTcpServer() {
|
private void startTcpServer() {
|
||||||
new Thread(() -> {
|
|
||||||
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
|
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
|
||||||
EventLoopGroup workerGroup = new NioEventLoopGroup(6);
|
EventLoopGroup workerGroup = new NioEventLoopGroup(6);
|
||||||
try {
|
try {
|
||||||
@ -55,16 +56,14 @@ public class TcpNettyServer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//监听器,当服务绑定成功后执行
|
//监听器,当服务绑定成功后执行
|
||||||
ChannelFuture channelFuture = serverBootstrap.bind(port).sync().addListener(new BindListener());
|
ChannelFuture channelFuture = serverBootstrap.bind(port).addListener(new BindListener());
|
||||||
//监听器,当停止服务后执行。
|
//监听器,当停止服务后执行。
|
||||||
channelFuture.channel().closeFuture().sync().addListener(new CloseListener());
|
channelFuture.channel().closeFuture().addListener(new CloseListener());
|
||||||
} catch (InterruptedException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("err:", e);
|
||||||
} finally {
|
|
||||||
bossGroup.shutdownGracefully();
|
bossGroup.shutdownGracefully();
|
||||||
workerGroup.shutdownGracefully();
|
workerGroup.shutdownGracefully();
|
||||||
}
|
}
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
package com.zhgd.xmgl.modules.project.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class WSSsdrAddress implements Serializable {
|
||||||
|
/**
|
||||||
|
* 省
|
||||||
|
*/
|
||||||
|
private String province;
|
||||||
|
/**
|
||||||
|
* 市
|
||||||
|
*/
|
||||||
|
private String city;
|
||||||
|
/**
|
||||||
|
* 区/县/镇
|
||||||
|
*/
|
||||||
|
private String county;
|
||||||
|
/**
|
||||||
|
* 街道/村
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
public WSSsdrAddress(String province, String city, String county, String address) {
|
||||||
|
//if (StringUtils.isBlank(province) ||
|
||||||
|
// StringUtils.isBlank(city) ||
|
||||||
|
// StringUtils.isBlank(county) ||
|
||||||
|
// StringUtils.isBlank(address)) {
|
||||||
|
// throw new RuntimeException("客户联系地址出错");
|
||||||
|
//}
|
||||||
|
this.province = province;
|
||||||
|
this.city = city;
|
||||||
|
this.county = county;
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,9 +12,11 @@ import com.zhgd.xmgl.entity.vo.ZwProjectDataVo;
|
|||||||
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
||||||
import com.zhgd.xmgl.modules.basicdata.mapper.BaseModuleProjectMapper;
|
import com.zhgd.xmgl.modules.basicdata.mapper.BaseModuleProjectMapper;
|
||||||
import com.zhgd.xmgl.modules.basicdata.mapper.CompanyConfigMapper;
|
import com.zhgd.xmgl.modules.basicdata.mapper.CompanyConfigMapper;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.mapper.SystemAreasMapper;
|
||||||
import com.zhgd.xmgl.modules.basicdata.service.IBaseModuleService;
|
import com.zhgd.xmgl.modules.basicdata.service.IBaseModuleService;
|
||||||
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
|
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
|
||||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.service.impl.SystemProvincesServiceImpl;
|
||||||
import com.zhgd.xmgl.modules.bigdevice.entity.GantryCrane;
|
import com.zhgd.xmgl.modules.bigdevice.entity.GantryCrane;
|
||||||
import com.zhgd.xmgl.modules.bigdevice.entity.Lifter;
|
import com.zhgd.xmgl.modules.bigdevice.entity.Lifter;
|
||||||
import com.zhgd.xmgl.modules.bigdevice.entity.Tower;
|
import com.zhgd.xmgl.modules.bigdevice.entity.Tower;
|
||||||
@ -32,6 +34,7 @@ import com.zhgd.xmgl.modules.environment.service.IEnvironmentDevService;
|
|||||||
import com.zhgd.xmgl.modules.massrebound.service.IFunctionRoomService;
|
import com.zhgd.xmgl.modules.massrebound.service.IFunctionRoomService;
|
||||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||||
import com.zhgd.xmgl.modules.project.entity.ProjectConfig;
|
import com.zhgd.xmgl.modules.project.entity.ProjectConfig;
|
||||||
|
import com.zhgd.xmgl.modules.project.entity.WSSsdrAddress;
|
||||||
import com.zhgd.xmgl.modules.project.entity.vo.GroupByProjectProgressVo;
|
import com.zhgd.xmgl.modules.project.entity.vo.GroupByProjectProgressVo;
|
||||||
import com.zhgd.xmgl.modules.project.entity.vo.GroupByProjectTypeVo;
|
import com.zhgd.xmgl.modules.project.entity.vo.GroupByProjectTypeVo;
|
||||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectDurationVO;
|
import com.zhgd.xmgl.modules.project.entity.vo.ProjectDurationVO;
|
||||||
@ -47,7 +50,9 @@ import com.zhgd.xmgl.modules.video.entity.VideoItem;
|
|||||||
import com.zhgd.xmgl.modules.video.mapper.VideoItemMapper;
|
import com.zhgd.xmgl.modules.video.mapper.VideoItemMapper;
|
||||||
import com.zhgd.xmgl.modules.worker.entity.UfaceDev;
|
import com.zhgd.xmgl.modules.worker.entity.UfaceDev;
|
||||||
import com.zhgd.xmgl.modules.worker.service.*;
|
import com.zhgd.xmgl.modules.worker.service.*;
|
||||||
|
import com.zhgd.xmgl.util.AddressUtil;
|
||||||
import com.zhgd.xmgl.util.MessageUtil;
|
import com.zhgd.xmgl.util.MessageUtil;
|
||||||
|
import com.zhgd.xmgl.util.ProfileJudgeUtil;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -71,6 +76,12 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||||
|
@Autowired
|
||||||
|
private SystemProvincesServiceImpl systemProvincesService;
|
||||||
|
@Autowired
|
||||||
|
private SystemAreasMapper systemAreasMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProfileJudgeUtil profileJudgeUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -162,6 +173,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveProject(Project project) {
|
public void saveProject(Project project) {
|
||||||
|
if (profileJudgeUtil.isSjjt()) {
|
||||||
|
if (StringUtils.isBlank(project.getCompanySn())) {
|
||||||
|
project.setCompanySn("B386480F85E84592B8E102224D090794");
|
||||||
|
}
|
||||||
|
setProjectCode(project);
|
||||||
|
}
|
||||||
QueryWrapper<Company> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Company> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(Company::getCompanySn, project.getCompanySn());
|
queryWrapper.lambda().eq(Company::getCompanySn, project.getCompanySn());
|
||||||
Company company = companyService.getOne(queryWrapper);
|
Company company = companyService.getOne(queryWrapper);
|
||||||
@ -199,6 +216,49 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||||||
projectConfigMapper.insert(config);
|
projectConfigMapper.insert(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 三江:我通过判断项目地址,取出里面省、市、区,然后查找并设置编码
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
private void setProjectCode(Project project) {
|
||||||
|
String address = project.getProjectAddress();
|
||||||
|
WSSsdrAddress wsSsdrAddress = AddressUtil.resolveAddress(address);
|
||||||
|
String province = wsSsdrAddress.getProvince();
|
||||||
|
String city = wsSsdrAddress.getCity();
|
||||||
|
String county = wsSsdrAddress.getCounty();
|
||||||
|
List<EntityMap> addressTreeList = systemProvincesService.selectProvincesCityList();
|
||||||
|
if (addressTreeList != null) {
|
||||||
|
for (EntityMap provinceMap : addressTreeList) {
|
||||||
|
String name = provinceMap.get("name");
|
||||||
|
if (Objects.equals(name, province)) {
|
||||||
|
project.setProvincesCode(provinceMap.get("code"));
|
||||||
|
List<EntityMap> cityMapList = provinceMap.get("childrenlist");
|
||||||
|
if (cityMapList != null) {
|
||||||
|
for (EntityMap cityMap : cityMapList) {
|
||||||
|
String cityName = cityMap.get("name");
|
||||||
|
if (Objects.equals(cityName, city)) {
|
||||||
|
project.setCityCode(cityMap.get("code"));
|
||||||
|
List<EntityMap> areaMapList = cityMap.get("childrenlist");
|
||||||
|
if (areaMapList != null) {
|
||||||
|
for (EntityMap areaMap : areaMapList) {
|
||||||
|
String areaName = cityMap.get("name");
|
||||||
|
if (Objects.equals(areaName, county)) {
|
||||||
|
project.setAreaCode(areaMap.get("code"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveZwProject(ZwProjectDataVo zwProjectDataVo) {
|
public void saveZwProject(ZwProjectDataVo zwProjectDataVo) {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
|
|||||||
67
src/main/java/com/zhgd/xmgl/util/AddressUtil.java
Normal file
67
src/main/java/com/zhgd/xmgl/util/AddressUtil.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package com.zhgd.xmgl.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
|
import com.zhgd.xmgl.modules.project.entity.WSSsdrAddress;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址工具类
|
||||||
|
*/
|
||||||
|
public class AddressUtil {
|
||||||
|
|
||||||
|
private AddressUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从地址串中解析提取出省市区等信息
|
||||||
|
*
|
||||||
|
* @param address 地址信息
|
||||||
|
* @return 解析后的地址Map
|
||||||
|
*/
|
||||||
|
private static Map<String, String> addressResolution(String address) {
|
||||||
|
//1.地址的正则表达式
|
||||||
|
String regex = "(?<province>[^省]+省|.+自治区|[^澳门]+澳门|[^香港]+香港|[^市]+市)?(?<city>[^自治州]+自治州|[^特别行政区]+特别行政区|[^市]+市|.*?地区|.*?行政单位|.+盟|市辖区|[^县]+县)(?<county>[^县]+县|[^市]+市|[^镇]+镇|[^区]+区|[^乡]+乡|.+场|.+旗|.+海域|.+岛)?(?<address>.*)";
|
||||||
|
//2、创建匹配规则
|
||||||
|
Matcher m = Pattern.compile(regex).matcher(address);
|
||||||
|
String province;
|
||||||
|
String city;
|
||||||
|
String county;
|
||||||
|
String detailAddress;
|
||||||
|
Map<String, String> map = new HashMap<>(16);
|
||||||
|
|
||||||
|
while (m.find()) {
|
||||||
|
//加入省
|
||||||
|
province = m.group("province");
|
||||||
|
map.put("province", province == null ? "" : province.trim());
|
||||||
|
//加入市
|
||||||
|
city = m.group("city");
|
||||||
|
map.put("city", city == null ? "" : city.trim());
|
||||||
|
//加入区
|
||||||
|
county = m.group("county");
|
||||||
|
map.put("county", county == null ? "" : county.trim());
|
||||||
|
//详细地址
|
||||||
|
detailAddress = m.group("address");
|
||||||
|
map.put("address", detailAddress == null ? "" : detailAddress.trim());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地址获取解析后的地址对象
|
||||||
|
*
|
||||||
|
* @param address 解析前地址Str
|
||||||
|
* @return 解析后地址对象
|
||||||
|
*/
|
||||||
|
public static WSSsdrAddress resolveAddress(String address) {
|
||||||
|
if (CharSequenceUtil.isBlank(address)) {
|
||||||
|
throw new RuntimeException("客户联系地址出错");
|
||||||
|
}
|
||||||
|
Map<String, String> addressMap = addressResolution(address);
|
||||||
|
return new WSSsdrAddress(addressMap.get("province"), addressMap.get("city"), addressMap.get("county"), addressMap.get("address"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -30,7 +30,7 @@ public class IdCardUtils {
|
|||||||
*/
|
*/
|
||||||
private static Boolean enable;
|
private static Boolean enable;
|
||||||
|
|
||||||
@Value("${hw-ocr-enable}")
|
@Value("${hw-ocr-enable:false}")
|
||||||
public void setEnable(Boolean enable) {
|
public void setEnable(Boolean enable) {
|
||||||
IdCardUtils.enable = enable;
|
IdCardUtils.enable = enable;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ server.tomcat.basedir=C:/jxj/prod/backEnd/tempImage/
|
|||||||
#server.tomcat.basedir=F:/zhgd/tempImage/
|
#server.tomcat.basedir=F:/zhgd/tempImage/
|
||||||
#arcsoft.dllPath=F:/zhgd/dll
|
#arcsoft.dllPath=F:/zhgd/dll
|
||||||
arcsoft.dllPath=C:/jxj/prod/backEnd/dll
|
arcsoft.dllPath=C:/jxj/prod/backEnd/dll
|
||||||
security.enable=true
|
security.enable=false
|
||||||
isGetStandardData=false
|
isGetStandardData=false
|
||||||
isGetEnvironmentData=false
|
isGetEnvironmentData=false
|
||||||
isGetFaceFeatureDate=false
|
isGetFaceFeatureDate=false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user