| | |
| | | import com.xiaopeng.api.model.operation.XpElectronicFenceArea; |
| | | import com.xiaopeng.api.model.operation.XpPoint; |
| | | import com.xiaopeng.api.query.operation.ElectronicPageListQuery; |
| | | import com.xiaopeng.api.model.operation.XpRegion; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.utils.DateUtils; |
| | |
| | | import com.xiaopeng.operation.mapper.XpElectronicFenceAreaMapper; |
| | | import com.xiaopeng.operation.mapper.XpElectronicFenceMapper; |
| | | import com.xiaopeng.operation.mapper.XpPointMapper; |
| | | import com.xiaopeng.api.query.operation.ElectronicPageListQuery; |
| | | import com.xiaopeng.operation.mapper.XpRegionMapper; |
| | | import com.xiaopeng.operation.service.IXpElectronicFenceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.operation.service.IXpRegionService; |
| | | import com.xiaopeng.operation.utils.PolygonOverlapService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import net.sourceforge.pinyin4j.PinyinHelper; |
| | | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | |
| | | private MongoTemplate mongoTemplate; |
| | | @Autowired |
| | | private XpPointMapper xpPointMapper; |
| | | @Autowired |
| | | private XpRegionMapper xpRegionMapper; |
| | | |
| | | @Override |
| | | public PageInfo<XpElectronicFence> pageList(ElectronicPageListQuery query) { |
| | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | public static String getPinyinInitials(String chinese) { |
| | | StringBuilder pinyinInitials = new StringBuilder(); |
| | | for (char c : chinese.toCharArray()) { |
| | | // 获取拼音数组(多音字会返回多个拼音) |
| | | String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c); |
| | | if (pinyinArray != null && pinyinArray.length > 0) { |
| | | // 取第一个拼音的首字母 |
| | | pinyinInitials.append(pinyinArray[0].charAt(0)); |
| | | } |
| | | } |
| | | return pinyinInitials.toString(); |
| | | } |
| | | @Override |
| | | public R addElectronic(ElectronicFenceAddDto dto) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | xpElectronicFence.setCityCode(dto.getCityCode()); |
| | | // 生成围栏id 规则:城市首字母-类型简写-4位自增流水号(如 SZ-OP-001),支持复制;数据停用或删除后,流水号不回收 |
| | | XpRegion xpRegion = xpRegionMapper.selectOne(new LambdaQueryWrapper<XpRegion>() |
| | | .eq(XpRegion::getCode, dto.getCityCode())); |
| | | String name = xpRegion.getName(); |
| | | this.save(xpElectronicFence); |
| | | // 根据城市中文名,截取前两位的首字母并且大写 |
| | | // 截取前两个字符 |
| | | String prefix = name.substring(0, 2); |
| | | // 获取拼音首字母并大写 |
| | | String result = getPinyinInitials(prefix).toUpperCase(); |
| | | xpElectronicFence.setElectronicNumber(result + "-OP-" + String.format("%04d", xpElectronicFence.getId())); |
| | | if (dto.getStatus() == 0) { |
| | | xpElectronicFence.setStatus(0); |
| | | } else if (dto.getStatus() == 1) { |
| | |
| | | xpGeoFencingPolygon.setFenceId(String.valueOf(xpElectronicFence.getId())); |
| | | xpGeoFencingPolygon.setName(xpElectronicFence.getElectronicName()); |
| | | xpGeoFencingPolygon.setAreaId(String.valueOf(newElectronicFenceArea.getId())); |
| | | xpGeoFencingPolygon.setCityCode("510100"); |
| | | xpGeoFencingPolygon.setCityCode(xpElectronicFence.getCityCode()); |
| | | xpGeoFencingPolygon.setOperationStrategy(xpElectronicFence.getOperationStrategy()); |
| | | // 将围栏点转换为GeoJSON多边形 |
| | | GeoJsonPolygon geoJsonPolygon = convertToGeoJsonPolygon(newElectronicFenceArea.getFencePoints()); |