|
@@ -4,7 +4,8 @@ import com.caimei.mapper.cmMapper.AuthMapper;
|
|
|
import com.caimei.mapper.ldmMapper.LdmMapper;
|
|
|
import com.caimei.model.po.CmBrandAuthPo;
|
|
|
import com.caimei.model.po.LdmDataPo;
|
|
|
-import com.caimei.service.auth.ShopService;
|
|
|
+import com.caimei.model.po.TownPo;
|
|
|
+import com.caimei.module.base.entity.po.Town;
|
|
|
import com.caimei.service.auth.UploadService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -17,7 +18,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
@@ -42,9 +43,9 @@ public class LdmTask {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 每天凌晨1点读取ldm数据库机构数据,存入采美数据库中
|
|
|
+ * 每天凌晨2点读取ldm数据库机构数据,存入采美数据库中
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0 2 * * ?")
|
|
|
+ @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
public void readLdmData() {
|
|
|
AtomicReference<Integer> ldmLatestClubId = new AtomicReference<>(authMapper.getLdmLatestClubId());
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>开始同步,ldmLatestClubId:" + ldmLatestClubId.get());
|
|
@@ -62,42 +63,70 @@ public class LdmTask {
|
|
|
|
|
|
String regId1 = ldmData.getRegId1();
|
|
|
if (StringUtils.isNotEmpty(regId1)) {
|
|
|
- Integer provinceId = authMapper.getProvinceId(regId1);
|
|
|
+ String provinceName = authMapper.getProvinceName(regId1);
|
|
|
+ if (StringUtils.isNotEmpty(provinceName) && provinceName.length() > 2) {
|
|
|
+ provinceName = provinceName.substring(0, provinceName.length() - 1).trim();
|
|
|
+ }
|
|
|
+ Integer provinceId = authMapper.getProvinceId(provinceName);
|
|
|
ldmData.setProvinceId(provinceId);
|
|
|
}
|
|
|
String regId2 = ldmData.getRegId2();
|
|
|
if (StringUtils.isNotEmpty(regId2)) {
|
|
|
- Integer cityId = authMapper.getCityId(regId2);
|
|
|
+ String cityName = authMapper.getCityName(regId2);
|
|
|
+ if (StringUtils.isNotEmpty(cityName) && cityName.length() > 2) {
|
|
|
+ cityName = cityName.substring(0, cityName.length() - 1).trim();
|
|
|
+ }
|
|
|
+ Integer cityId = authMapper.getCityId(cityName);
|
|
|
ldmData.setCityId(cityId);
|
|
|
}
|
|
|
String regId3 = ldmData.getRegId3();
|
|
|
if (StringUtils.isNotEmpty(regId3)) {
|
|
|
- Integer townId = authMapper.getTownId(regId3);
|
|
|
- ldmData.setTownId(townId);
|
|
|
+ String townName = authMapper.getTownName(regId3);
|
|
|
+ if (StringUtils.isNotEmpty(townName) && townName.length() > 2) {
|
|
|
+ townName = townName.substring(0, townName.length() - 1).trim();
|
|
|
+ if (townName.startsWith("济源市")) {
|
|
|
+ townName = townName.replace("济源市", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TownPo> townList = authMapper.getTownList(townName);
|
|
|
+ townList.forEach(town->{
|
|
|
+ if (null == ldmData.getTownId()) {
|
|
|
+ if (null != ldmData.getCityId()) {
|
|
|
+ if (town.getCityId().equals(ldmData.getCityId())) {
|
|
|
+ ldmData.setTownId(town.getTownId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Integer cityId = authMapper.getCityIdByTownId(town.getTownId());
|
|
|
+ if (null != ldmData.getProvinceId() && null != cityId) {
|
|
|
+ Integer provinceId = authMapper.getProvinceIdByCityId(cityId);
|
|
|
+ if (ldmData.getProvinceId().equals(provinceId)) {
|
|
|
+ ldmData.setCityId(cityId);
|
|
|
+ ldmData.setTownId(town.getTownId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (null != ldmData.getCityId() && null == ldmData.getTownId()) {
|
|
|
+ if (236 == ldmData.getCityId()) {
|
|
|
+ // 三亚市
|
|
|
+ ldmData.setTownId(2198);
|
|
|
+ }
|
|
|
}
|
|
|
String pic1 = ldmData.getPic1();
|
|
|
String pic2 = ldmData.getPic2();
|
|
|
String pic3 = ldmData.getPic3();
|
|
|
String pic4 = ldmData.getPic4();
|
|
|
String pic5 = ldmData.getPic5();
|
|
|
- List<String> picList = new ArrayList<>();
|
|
|
- picList.add(pic1);
|
|
|
- picList.add(pic2);
|
|
|
- picList.add(pic3);
|
|
|
- picList.add(pic4);
|
|
|
- picList.add(pic5);
|
|
|
+ List<String> picList = Arrays.asList(pic1, pic2, pic3, pic4, pic5);
|
|
|
String logo = null;
|
|
|
- List<String> addPicList = new ArrayList<>();
|
|
|
for (String pic : picList) {
|
|
|
- if (StringUtils.isNotEmpty(pic)) {
|
|
|
+ if (null == logo && StringUtils.isNotEmpty(pic)) {
|
|
|
try {
|
|
|
String imagePath = "https://wangdian.skinovachina.com" + pic;
|
|
|
String fileName = imagePath.substring(imagePath.lastIndexOf("/") + 1);
|
|
|
- String imageUrl = uploadService.saveFileByUrl(imagePath, fileName);
|
|
|
- addPicList.add(imageUrl);
|
|
|
- if (null == logo) {
|
|
|
- logo = imageUrl;
|
|
|
- }
|
|
|
+ logo = uploadService.saveFileByUrl(imagePath, fileName);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -111,9 +140,7 @@ public class LdmTask {
|
|
|
authPo.setCustomFlag(0);
|
|
|
authMapper.insertAuth(authPo);
|
|
|
// 保存轮播图
|
|
|
- if (addPicList.size() > 0) {
|
|
|
- addPicList.forEach(banner -> authMapper.insertBanner(authPo.getId(), banner));
|
|
|
- }
|
|
|
+ authMapper.insertBanner(authPo.getId(), "https://img.caimei365.com/group1/M00/04/01/rB-lGGJYHJmARujYAAe1RZSC0tg297.png");
|
|
|
});
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>同步结束,ldmLatestClubId:" + ldmLatestClubId.get());
|
|
|
authMapper.updateLdmLatestClubId(ldmLatestClubId.get());
|