From eb7a808aaf7dd0a6dd2ff70f9ef3f8ce0b1e31d1 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 22 五月 2026 18:27:32 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/gtzxinglijicun
---
server/services/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java | 143 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 143 insertions(+), 0 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java
index 93c32f3..8fe7aff 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/AreasServiceImpl.java
@@ -12,12 +12,17 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.PinYinUtil;
+import com.doumee.core.utils.geocode.MapUtil;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.AreasMapper;
+import com.doumee.dao.business.PricingRuleMapper;
import com.doumee.dao.business.model.Areas;
+import com.doumee.dao.business.model.PricingRule;
import com.doumee.service.business.AreasService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -33,6 +38,7 @@
* @author 姹熻箘韫�
* @date 2023/02/15 08:55
*/
+@Slf4j
@Service
public class AreasServiceImpl implements AreasService {
public static List<Areas> ALL_AREA_LIST;
@@ -43,6 +49,9 @@
@Autowired
private AreasMapper areasMapper;
+
+ @Autowired
+ private PricingRuleMapper pricingRuleMapper;
@Autowired
RestTemplate restTemplate ;
@@ -63,8 +72,13 @@
}
}*/
areas.setIsdeleted(Constants.ZERO);
+ areas.setCreateDate(new Date());
areasMapper.insert(areas);
areas.setCode(areas.getId().toString());
+ // 鍩庡競绾у尯鍒掕嚜鍔ㄥ~鍏呯粡绾害
+ if (Constants.equalsInteger(areas.getType(), Constants.ONE)) {
+ areas.setInfo(geocodeCity(areas));
+ }
areasMapper.updateById(areas);
//鍒锋柊缂撳瓨鏁版嵁
cacheData();
@@ -74,6 +88,11 @@
@Override
public void deleteById(Integer id) {
areasMapper.deleteById(id);
+ // 鍚屾鍒犻櫎璇ュ煄甯傚叧鑱旂殑璁′环瑙勫垯閰嶇疆
+ PricingRule deleteRule = new PricingRule();
+ deleteRule.setCityId(id);
+ QueryWrapper<PricingRule> deleteWrapper = new QueryWrapper<>(deleteRule);
+ pricingRuleMapper.delete(deleteWrapper);
//鍒锋柊缂撳瓨鏁版嵁
cacheData();
}
@@ -104,6 +123,14 @@
Areas update = new Areas();
update.setName(areas.getName());
update.setSortnum(areas.getSortnum());
+ // 鍩庡競绾у尯鍒掕嚜鍔ㄦ洿鏂扮粡绾害
+ Areas existing = areasMapper.selectById(areas.getId());
+ if (existing != null && Constants.equalsInteger(existing.getType(), Constants.ONE)) {
+ String location = MapUtil.geocode(getParentName(existing.getParentId()) + areas.getName());
+ if (location != null) {
+ update.setInfo(location);
+ }
+ }
areasMapper.update(update,wrapper);
//鍒锋柊缂撳瓨鏁版嵁
cacheData();
@@ -119,6 +146,11 @@
}
//鍒锋柊缂撳瓨鏁版嵁
cacheData();
+ }
+
+ @Override
+ public Areas getById(Integer id) {
+ return areasMapper.selectById(id);
}
@Override
@@ -518,4 +550,115 @@
return dataList;
}
+ @Override
+ public List<Areas> getOpenCityList() {
+ QueryWrapper<Areas> qw = new QueryWrapper<>();
+ qw.lambda()
+ .eq(Areas::getType, Constants.ONE)
+ .eq(Areas::getStatus, Constants.ONE)
+ .eq(Areas::getIsdeleted, Constants.ZERO)
+ .orderByAsc(Areas::getSortnum);
+ List<Areas> list = areasMapper.selectList(qw);
+ if (list != null) {
+ for (Areas c : list) {
+ c.setFullspell(PinYinUtil.getFullSpell(c.getName()));
+ c.setFirstSpell(PinYinUtil.getFirstFirstSpell(c.getName()));
+ }
+ Collections.sort(list);
+ }
+ return list;
+ }
+
+
+ @Override
+ public Areas getOpenedCityByName(String cityName) {
+ if (StringUtils.isBlank(cityName)) {
+ return null;
+ }
+ QueryWrapper<Areas> qw = new QueryWrapper<>();
+ qw.lambda()
+ .eq(Areas::getType, Constants.ONE)
+ .eq(Areas::getStatus, Constants.ONE)
+ .eq(Areas::getIsdeleted, Constants.ZERO)
+ .eq(Areas::getName, cityName)
+ .last("limit 1");
+ return areasMapper.selectOne(qw);
+ }
+
+
+ @Override
+ public Areas getOpenedCityByCode(String code) {
+ if (StringUtils.isBlank(code)) {
+ return null;
+ }
+ Areas areas = areasMapper.selectById(code);
+ if(Objects.isNull(areas)||Objects.isNull(areas.getParentId())){
+ return null;
+ }
+ Areas city = areasMapper.selectById(areas.getParentId());
+ if(Objects.isNull(city)||Constants.equalsInteger(city.getIsdeleted(),Constants.ONE)||
+ Constants.equalsInteger(city.getStatus(),Constants.ZERO)){
+ return null;
+ }
+ return city;
+ }
+
+ @Override
+ public void updateStatus(Areas areas) {
+ if (areas == null || areas.getId() == null) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ Areas update = new Areas();
+ update.setId(areas.getId());
+ update.setStatus(areas.getStatus());
+ areasMapper.updateById(update);
+ }
+
+ @Override
+ public String fillCityLocation() {
+ Areas query = new Areas();
+ query.setType(1);
+ List<Areas> cities = areasMapper.selectList(new QueryWrapper<Areas>().lambda()
+ .eq(Areas::getType, 1));
+ int success = 0, fail = 0;
+ for (Areas city : cities) {
+ if (StringUtils.isNotBlank(city.getInfo())) {
+ continue;
+ }
+ String parentName = "";
+ if (city.getParentId() != null) {
+ Areas parent = getById(city.getParentId());
+ if (parent != null) {
+ parentName = parent.getName();
+ }
+ }
+ String address = parentName + city.getName();
+ String location = MapUtil.geocode(address);
+ if (location != null) {
+ city.setInfo(location);
+ areasMapper.updateById(city);
+ success++;
+ log.info("鍩庡競缁忕含搴﹀~鍏呮垚鍔�: {} => {}", address, location);
+ } else {
+ fail++;
+ log.warn("鍩庡競缁忕含搴﹀~鍏呭け璐�: {}", address);
+ }
+ try { Thread.sleep(200); } catch (InterruptedException ignored) {}
+ }
+ return "澶勭悊瀹屾垚锛屾垚鍔�: " + success + "锛屽け璐�: " + fail + "锛屾�昏: " + cities.size();
+ }
+
+ private String getParentName(Integer parentId) {
+ if (parentId == null) {
+ return "";
+ }
+ Areas parent = getById(parentId);
+ return parent != null ? parent.getName() : "";
+ }
+
+ private String geocodeCity(Areas city) {
+ String address = getParentName(city.getParentId()) + city.getName();
+ return MapUtil.geocode(address);
+ }
+
}
--
Gitblit v1.9.3