Merge branch 'dev' of http://47.94.165.164:13000/geg-gas/geg-gas-pcitc into dev
This commit is contained in:
@ -0,0 +1,17 @@
|
|||||||
|
package com.xjrsoft.module.mdm.client;
|
||||||
|
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import com.xjrsoft.common.constant.GlobalConstant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: ksy
|
||||||
|
* @since: 2025/11/5
|
||||||
|
*/
|
||||||
|
@FeignClient(value = GlobalConstant.CLIENT_PCITC_MDM_NAME, path = GlobalConstant.CLIENT_API_PRE + GlobalConstant.MDM_MODULE_PREFIX + "/countryRegion")
|
||||||
|
public interface ICountryRegionClient {
|
||||||
|
|
||||||
|
@GetMapping("/refreshCache")
|
||||||
|
void refreshCache();
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package com.xjrsoft.module.mdm.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.xjrsoft.common.constant.GlobalConstant;
|
||||||
|
import com.xjrsoft.common.utils.RedisUtil;
|
||||||
|
import com.xjrsoft.common.utils.TenantUtil;
|
||||||
|
import com.xjrsoft.module.mdm.entity.LngBRegion;
|
||||||
|
import com.xjrsoft.module.mdm.service.ICountryRegionService;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: yjw
|
||||||
|
* @since: 2025/3/5
|
||||||
|
*/
|
||||||
|
//@Api(hidden = true)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(GlobalConstant.CLIENT_API_PRE + GlobalConstant.MDM_MODULE_PREFIX + "/countryRegion")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class CountryRegionClientImpl implements ICountryRegionClient {
|
||||||
|
|
||||||
|
private final ICountryRegionService countryRegionService;
|
||||||
|
private final RedisUtil redisUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/refreshCache")
|
||||||
|
public void refreshCache() {
|
||||||
|
try {
|
||||||
|
TenantUtil.ignore(true);
|
||||||
|
log.info("MDM: 加载所有国家地区表缓存开始");
|
||||||
|
List<LngBRegion> list = countryRegionService.list();
|
||||||
|
redisUtil.set(GlobalConstant.REGION_CACHE_KEY, list);
|
||||||
|
redisUtil.set(GlobalConstant.REGION_NAME_CACHE_KEY, list.stream().collect(Collectors.toMap(LngBRegion::getCode,LngBRegion::getFullPath)));
|
||||||
|
log.info("MDM: 加载所有国家地区表缓存结束");
|
||||||
|
}finally {
|
||||||
|
TenantUtil.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.xjrsoft.module.mdm.service.impl;
|
package com.xjrsoft.module.mdm.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -14,6 +15,7 @@ import com.pictc.enums.BusinessCode;
|
|||||||
import com.pictc.enums.ExceptionCommonCode;
|
import com.pictc.enums.ExceptionCommonCode;
|
||||||
import com.pictc.utils.DataLogTools;
|
import com.pictc.utils.DataLogTools;
|
||||||
import com.xjrsoft.common.exception.BusinessException;
|
import com.xjrsoft.common.exception.BusinessException;
|
||||||
|
import com.xjrsoft.common.utils.CacheUtil;
|
||||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||||
import com.xjrsoft.module.mdm.dto.UpdateLngBRegionDto;
|
import com.xjrsoft.module.mdm.dto.UpdateLngBRegionDto;
|
||||||
@ -54,6 +56,7 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
|||||||
this.checkParams(dto);
|
this.checkParams(dto);
|
||||||
UpdateLngBRegionDto res = DataLogTools.insert(dto);
|
UpdateLngBRegionDto res = DataLogTools.insert(dto);
|
||||||
this.addOrUpdateAfter(res.getId());
|
this.addOrUpdateAfter(res.getId());
|
||||||
|
refreshCahe();
|
||||||
return res.getId();
|
return res.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +70,7 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
|||||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
refreshCahe();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +85,7 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
|||||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
refreshCahe();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +107,7 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
|||||||
this.checkParams(dto);
|
this.checkParams(dto);
|
||||||
UpdateLngBRegionDto res = DataLogTools.update(dto);
|
UpdateLngBRegionDto res = DataLogTools.update(dto);
|
||||||
this.addOrUpdateAfter(res.getId());
|
this.addOrUpdateAfter(res.getId());
|
||||||
|
refreshCahe();
|
||||||
return res.getId();
|
return res.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,5 +132,13 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
|
|||||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refreshCahe(){
|
||||||
|
//异步更新用户表、用户部门表、用户角色表、用户岗位表数据
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
CacheUtil.refreshRegionList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user