三江项目通过地址查询编码

This commit is contained in:
Administrator 2023-04-04 14:45:10 +08:00
parent cc565109bf
commit 36d5da539d
6 changed files with 203 additions and 33 deletions

View File

@ -13,6 +13,7 @@ import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.string.StringDecoder;
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.Value;
import org.springframework.stereotype.Component;
@ -26,6 +27,7 @@ import java.nio.charset.StandardCharsets;
* @date 2020/03/17 15:45:35
*/
@Component
@Slf4j
public class TcpNettyServer {
@Autowired
private TcpNettyHandler tcpNettyHandler;
@ -35,7 +37,6 @@ public class TcpNettyServer {
@PostConstruct
private void startTcpServer() {
new Thread(() -> {
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
EventLoopGroup workerGroup = new NioEventLoopGroup(6);
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());
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
channelFuture.channel().closeFuture().addListener(new CloseListener());
} catch (Exception e) {
log.error("err", e);
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}).start();
}
}

View File

@ -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;
}
}

View File

@ -12,9 +12,11 @@ import com.zhgd.xmgl.entity.vo.ZwProjectDataVo;
import com.zhgd.xmgl.modules.basicdata.entity.*;
import com.zhgd.xmgl.modules.basicdata.mapper.BaseModuleProjectMapper;
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.ICompanyService;
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.Lifter;
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.project.entity.Project;
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.GroupByProjectTypeVo;
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.worker.entity.UfaceDev;
import com.zhgd.xmgl.modules.worker.service.*;
import com.zhgd.xmgl.util.AddressUtil;
import com.zhgd.xmgl.util.MessageUtil;
import com.zhgd.xmgl.util.ProfileJudgeUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -71,6 +76,12 @@ import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
@Autowired
private SystemProvincesServiceImpl systemProvincesService;
@Autowired
private SystemAreasMapper systemAreasMapper;
@Autowired
private ProfileJudgeUtil profileJudgeUtil;
@Autowired
private ProjectMapper projectMapper;
@Autowired
@ -162,6 +173,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override
public void saveProject(Project project) {
if (profileJudgeUtil.isSjjt()) {
if (StringUtils.isBlank(project.getCompanySn())) {
project.setCompanySn("B386480F85E84592B8E102224D090794");
}
setProjectCode(project);
}
QueryWrapper<Company> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(Company::getCompanySn, project.getCompanySn());
Company company = companyService.getOne(queryWrapper);
@ -199,6 +216,49 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
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
public void saveZwProject(ZwProjectDataVo zwProjectDataVo) {
Project project = new Project();

View 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"));
}
}

View File

@ -30,7 +30,7 @@ public class IdCardUtils {
*/
private static Boolean enable;
@Value("${hw-ocr-enable}")
@Value("${hw-ocr-enable:false}")
public void setEnable(Boolean enable) {
IdCardUtils.enable = enable;
}

View File

@ -19,7 +19,7 @@ server.tomcat.basedir=C:/jxj/prod/backEnd/tempImage/
#server.tomcat.basedir=F:/zhgd/tempImage/
#arcsoft.dllPath=F:/zhgd/dll
arcsoft.dllPath=C:/jxj/prod/backEnd/dll
security.enable=true
security.enable=false
isGetStandardData=false
isGetEnvironmentData=false
isGetFaceFeatureDate=false