|
@@ -16,7 +16,9 @@
|
|
|
*/
|
|
|
package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmDaPharmacy;
|
|
@@ -30,6 +32,7 @@ import com.qunzhixinxi.hnqz.admin.service.WmDaPharmacyService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageStatusService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.util.MapUtil;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -154,6 +157,8 @@ public class WmDaPharmacyServiceImpl extends ServiceImpl<WmDaPharmacyMapper, WmD
|
|
|
}
|
|
|
wmDaPharmacy.setCreateTime(now);
|
|
|
wmDaPharmacy.setCreateUser(userId);
|
|
|
+ // 根据地址转换经纬度
|
|
|
+ this.convertToLatAndLong(wmDaPharmacy);
|
|
|
this.save(wmDaPharmacy);
|
|
|
}else if("2".equals(compareResult)){//信息不一致
|
|
|
//对比药店和调研信息,只有所属地区不一样
|
|
@@ -182,6 +187,8 @@ public class WmDaPharmacyServiceImpl extends ServiceImpl<WmDaPharmacyMapper, WmD
|
|
|
wmDaPharmacy.setAddress(wmTaskContent.getTemp4());
|
|
|
wmDaPharmacy.setUpdateTime(now);
|
|
|
wmDaPharmacy.setUpdateUser(userId);
|
|
|
+ // 根据地址转换经纬度
|
|
|
+ this.convertToLatAndLong(wmDaPharmacy);
|
|
|
//更新药店信息;
|
|
|
this.updateById(wmDaPharmacy);
|
|
|
}
|
|
@@ -235,5 +242,40 @@ public class WmDaPharmacyServiceImpl extends ServiceImpl<WmDaPharmacyMapper, WmD
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量转换经纬度
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void parseAddress() {
|
|
|
+ List<WmDaPharmacy> list = this.list(Wrappers.<WmDaPharmacy>lambdaQuery().isNull(WmDaPharmacy::getLatitude));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ list.forEach(wmDaPharmacy -> {
|
|
|
+ this.convertToLatAndLong(wmDaPharmacy);
|
|
|
+ this.saveOrUpdate(wmDaPharmacy);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据地址转换经纬度
|
|
|
+ *
|
|
|
+ * @param wmDaPharmacy
|
|
|
+ */
|
|
|
+ private void convertToLatAndLong(WmDaPharmacy wmDaPharmacy) {
|
|
|
+ String fullAddress = wmDaPharmacy.getProvince() + wmDaPharmacy.getCity() + wmDaPharmacy.getArea()
|
|
|
+ + wmDaPharmacy.getAddress();
|
|
|
+ JSONObject jsonObject = MapUtil.getLatAndLogByName(fullAddress);
|
|
|
+ if (jsonObject != null) {
|
|
|
+ wmDaPharmacy.setProvince(jsonObject.getString("province"));
|
|
|
+ wmDaPharmacy.setCity(jsonObject.getString("city"));
|
|
|
+ wmDaPharmacy.setArea(jsonObject.getString("district"));
|
|
|
+ String location = jsonObject.getString("location");
|
|
|
+ if (null != location && location.split(",").length > 0) {
|
|
|
+ wmDaPharmacy.setLongitude(location.split(",")[0]);
|
|
|
+ wmDaPharmacy.setLatitude(location.split(",")[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|