修改收藏英文翻译

This commit is contained in:
梁琦涛
2024-08-08 17:22:57 +08:00
parent e05ba6fd48
commit 0497f2353b
7 changed files with 92 additions and 14 deletions
@@ -18,6 +18,11 @@ public class CacheConstant {
*/
public static final String SYS_DICT_CACHE = "sys:cache:dict";
/**
* 字典信息缓存(含禁用的字典项)(英文)
*/
public static final String SYS_DICT_CACHE_EN = "sys:cache:dictEn";
/**
* 字典信息缓存 status为有效的
*/
@@ -235,4 +235,12 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
List<DictModel> queryAllTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
Integer checkUsed(@Param("dictCode") String dictCode);
/**
* 获取英文
* @param code
* @param key
* @return
*/
String queryDictTextByKeyEn(@Param("code") String code,@Param("key") String key);
}
@@ -207,4 +207,9 @@
<select id="checkUsed" resultType="java.lang.Integer">
select count(*) from laws_tag where dict_field = #{dictCode}
</select>
<select id="queryDictTextByKeyEn" resultType="java.lang.String">
select s.en_name from sys_dict_item s
where s.dict_id = (select id from sys_dict where dict_code = #{code} and del_flag = 0)
and s.item_value = #{key} and del_flag = 0
</select>
</mapper>
@@ -52,6 +52,8 @@ public interface ISysDictService extends IService<SysDict> {
public String queryDictTextByKey(String code, String key);
public String queryDictTextByKeyEn(String code, String key);
/**
* 可通过多个字典code查询翻译文本
* @param dictCodeList 多个字典code
@@ -122,6 +122,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
return sysDictMapper.queryDictTextByKey(code, key);
}
@Override
@Cacheable(value = CacheConstant.SYS_DICT_CACHE_EN,key = "#code+':'+#key", unless = "#result == null ")
public String queryDictTextByKeyEn(String code, String key) {
return sysDictMapper.queryDictTextByKeyEn(code, key);
}
@Override
public Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys) {
List<DictModelMany> list = sysDictMapper.queryManyDictByKeys(dictCodeList, keys);
@@ -1856,6 +1856,42 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
}
}
// private void addES(LawsHomeNormalSearchVO obj, String idTemp, StringBuilder fileTextAll){
// Map<String, Object> map = new HashMap<>();
// map.put("id", obj.getId());
// map.put("title", obj.getTitle());
// map.put(CONTENT, fileTextAll);
// map.put(RESOURCE_TYPE, obj.getResourceType());
// map.put("standard_type_order", obj.getStandardTypeOrder());
// map.put("standard_state_order", obj.getStandardStateOrder());
// map.put(STANDARD_CLASS, "," + obj.getStandardClass() + ",");
// map.put(DYNAMIC_TYPE, "," + obj.getDynamicType() + ",");
// map.put(APPLICABLE_VEHICLE, "," + obj.getApplicableVehicle() + ",");
// map.put(STANDARD_PROPERTY, "," + obj.getStandardProperty() + ",");
// map.put(STANDARD_STATE, "," + obj.getStandardState() + ",");
// map.put(STANDARD_CATEGORY_CODE,"," + obj.getCategoryCode() + ",");
// map.put(ENTERPRISE_STANDARD_STATE,"," + obj.getEnterpriseStandardState() + ",");
// map.put("applicable_market","," + obj.getApplicableMarket() + ",");
// map.put("release_date",obj.getReleaseDate());
// // 没有时间 强行加入最早时间
// try {
// map.put(IMPLEMENTATION_DATE,Objects.isNull(obj.getImplementationDate()) ? new SimpleDateFormat(YYYY_MM_DD).parse("1900-01-01") : obj.getImplementationDate());
// map.put("create_time_c",Objects.isNull(obj.getCreateTime()) ? new SimpleDateFormat(YYYY_MM_DD).parse("1900-01-01") : obj.getCreateTime());
// }catch (Exception e){
// log.error("文档库添加es失败",e);
// }
// map.put("es_create_time",new Date());
//// map.put(RELEASE_STATUS,obj.getReleaseStatus());
//// map.put("push_range_flag",obj.getReleaseStatus());
// //添加es
// JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(map, SerializerFeature.WriteMapNullValue));
// try {
// jeroElasticsearchTemplate.saveOrUpdate(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), idTemp, jsonObject);
// log.info("==============更新es成功================");
// } catch (Exception e) {
// log.error("文档库添加es失败",e);
// }
// }
private void addES(LawsHomeNormalSearchVO obj, String idTemp, StringBuilder fileTextAll){
Map<String, Object> map = new HashMap<>();
map.put("id", obj.getId());
@@ -1864,14 +1900,14 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
map.put(RESOURCE_TYPE, obj.getResourceType());
map.put("standard_type_order", obj.getStandardTypeOrder());
map.put("standard_state_order", obj.getStandardStateOrder());
map.put(STANDARD_CLASS, "," + obj.getStandardClass() + ",");
map.put(DYNAMIC_TYPE, "," + obj.getDynamicType() + ",");
map.put(APPLICABLE_VEHICLE, "," + obj.getApplicableVehicle() + ",");
map.put(STANDARD_PROPERTY, "," + obj.getStandardProperty() + ",");
map.put(STANDARD_STATE, "," + obj.getStandardState() + ",");
map.put(STANDARD_CATEGORY_CODE,"," + obj.getCategoryCode() + ",");
map.put(ENTERPRISE_STANDARD_STATE,"," + obj.getEnterpriseStandardState() + ",");
map.put("applicable_market","," + obj.getApplicableMarket() + ",");
map.put(STANDARD_CLASS, "," + (StringUtils.isBlank(obj.getStandardClass()) ? "" : obj.getStandardClass()) + ",");
map.put(DYNAMIC_TYPE, "," + (StringUtils.isBlank(obj.getDynamicType()) ? "" : obj.getDynamicType()) + ",");
map.put(APPLICABLE_VEHICLE, "," + (StringUtils.isBlank(obj.getApplicableVehicle()) ? "" : obj.getApplicableVehicle()) + ",");
map.put(STANDARD_PROPERTY, "," + (StringUtils.isBlank(obj.getStandardProperty()) ? "" : obj.getStandardProperty()) + ",");
map.put(STANDARD_STATE, "," + (StringUtils.isBlank(obj.getStandardState()) ? "" : obj.getStandardState()) + ",");
map.put(STANDARD_CATEGORY_CODE,"," + (StringUtils.isBlank(obj.getCategoryCode()) ? "" : obj.getCategoryCode()) + ",");
map.put(ENTERPRISE_STANDARD_STATE,"," + (StringUtils.isBlank(obj.getEnterpriseStandardState()) ? "" : obj.getEnterpriseStandardState()) + ",");
map.put("applicable_market","," + (StringUtils.isBlank(obj.getApplicableMarket()) ? "" : obj.getApplicableMarket()) + ",");
map.put("release_date",obj.getReleaseDate());
// 没有时间 强行加入最早时间
try {
@@ -12,13 +12,17 @@ import com.jero.modules.personal.entity.LawsStandardCollection;
import com.jero.modules.personal.mapper.LawsStandardCollectionMapper;
import com.jero.modules.personal.service.ILawsStandardCollectionService;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jero.common.exception.JeroBootException;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.query.QueryGenerator;
@@ -61,6 +65,8 @@ public class LawsStandardCollectionServiceImpl extends ServiceImpl<LawsStandardC
return page(page, queryWrapper);
}
public void standardAssignment(List<LawsStandardCollection> list){
Locale locale = LocaleContextHolder.getLocale();
Locale localeZh = Locale.CHINESE;
for (LawsStandardCollection collection : list) {
String standardId = collection.getStandardId();
String source = collection.getSource();
@@ -69,11 +75,16 @@ public class LawsStandardCollectionServiceImpl extends ServiceImpl<LawsStandardC
LawsDomesticStandard standard = lawsDomesticStandardService.queryById(standardId);
if (standard != null){
// TODO
// collection.setNewModelImplementationDate(standard.getNewModelImplementationDate());
// collection.setOnTheProductionDate(standard.getOnTheProductionDate());
// collection.setNewModelImplementationDate(standard.getNewAuthImplDate());
// collection.setOnTheProductionDate(standard.getNewProductImplDate());
collection.setReleaseDate(standard.getReleaseDate());
String standard_state = sysDictService.queryDictTextByKey("standard_state", standard.getStandardState());
collection.setStandardState(standard_state);
if (Objects.equals(locale,localeZh)){
String standard_state = sysDictService.queryDictTextByKey("standard_state", standard.getStandardState());
collection.setStandardState(standard_state);
}else{
String standard_state = sysDictService.queryDictTextByKeyEn("standard_state", standard.getStandardState());
collection.setStandardState(standard_state);
}
}
}
if (CommonConstant.STANDARD_SOURCE_3.equals(source)){
@@ -81,8 +92,13 @@ public class LawsStandardCollectionServiceImpl extends ServiceImpl<LawsStandardC
LawsEnterpriseStandard standard = ILawsEnterpriseStandardService.getById(standardId);
if (standard != null){
collection.setReleaseDate(standard.getReleaseDate());
String standard_state = sysDictService.queryDictTextByKey("enterprise_standard_state", standard.getStandardState());
collection.setStandardState(standard_state);
if (Objects.equals(locale,localeZh)){
String standard_state = sysDictService.queryDictTextByKey("enterprise_standard_state", standard.getStandardState());
collection.setStandardState(standard_state);
}else{
String standard_state = sysDictService.queryDictTextByKeyEn("enterprise_standard_state", standard.getStandardState());
collection.setStandardState(standard_state);
}
}
}
}