字典类型加上组织字段修改
This commit is contained in:
+3
-3
@@ -79,7 +79,7 @@ public class SysDictTypeController extends BaseController
|
||||
fillDictTypeOrganization(dict);
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型编码「" + dict.getDictType() + "」已存在(全局不可重复)");
|
||||
}
|
||||
dict.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
@@ -119,7 +119,7 @@ public class SysDictTypeController extends BaseController
|
||||
dict.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
}
|
||||
if (StringUtils.isEmpty(dict.getOrganizationName())
|
||||
&& dict.getOrganizationId().equals(userPo.getOrganizationId()))
|
||||
&& java.util.Objects.equals(dict.getOrganizationId(), userPo.getOrganizationId()))
|
||||
{
|
||||
dict.setOrganizationName(userPo.getOrganizationName());
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class SysDictTypeController extends BaseController
|
||||
fillDictTypeOrganization(dict);
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型编码「" + dict.getDictType() + "」已存在(全局不可重复)");
|
||||
}
|
||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
|
||||
@@ -56,7 +56,7 @@ public interface SysDictDataMapper extends BaseMapper<SysDictData>
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据
|
||||
*/
|
||||
int countDictDataByType(@Param("dictType") String dictType, @Param("organizationId") Long organizationId);
|
||||
public int countDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
@@ -97,8 +97,7 @@ public interface SysDictDataMapper extends BaseMapper<SysDictData>
|
||||
* @param newDictType 新旧字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType,
|
||||
@Param("organizationId") Long organizationId);
|
||||
public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
|
||||
|
||||
/**
|
||||
* 按字典类型批量同步字典数据的组织信息(与字典类型归属一致)
|
||||
@@ -106,6 +105,5 @@ public interface SysDictDataMapper extends BaseMapper<SysDictData>
|
||||
int updateDictDataOrganizationByDictType(@Param("dictType") String dictType,
|
||||
@Param("organizationId") Long organizationId,
|
||||
@Param("organizationName") String organizationName,
|
||||
@Param("topOrganizationId") Long topOrganizationId,
|
||||
@Param("scopeOrganizationId") Long scopeOrganizationId);
|
||||
@Param("topOrganizationId") Long topOrganizationId);
|
||||
}
|
||||
|
||||
+109
-20
@@ -4,17 +4,24 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhd.basic.infrastructure.feign.ProductServiceFeign;
|
||||
import com.mhd.basic.infrastructure.util.annotation.DataPermissions;
|
||||
import com.mhd.common.core.domain.po.OrganizationPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.domain.SysDictType;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.system.domain.vo.SysBankDictInfo;
|
||||
import com.mhd.system.domain.vo.SysDictDataVO;
|
||||
import com.mhd.system.mapper.SysDictDataMapper;
|
||||
import com.mhd.system.service.ISysDictDataService;
|
||||
import com.mhd.system.service.ISysDictTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.mhd.common.security.utils.DictUtils;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
@@ -33,6 +40,12 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
@Resource
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Resource
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@Resource
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
@@ -107,11 +120,8 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
dictDataMapper.deleteDictDataById(dictCode);
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(data.getDictType());
|
||||
Long oid = data.getOrganizationId() != null ? data.getOrganizationId() : 0L;
|
||||
dictData.setOrganizationId(oid);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
DictUtils.setDictCache(DictUtils.dictTypeOrgCacheKey(data.getDictType(), oid), dictDatas);
|
||||
DictUtils.removeDictCache(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,20 +139,28 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
data.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
data.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
data.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
applyOrganizationFromDictType(data, null);
|
||||
fillOrganizationNameFromProductForDictData(data);
|
||||
if (data.getOrganizationId() == null)
|
||||
{
|
||||
data.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isEmpty(data.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
}
|
||||
if (data.getTopOrganizationId() == null)
|
||||
{
|
||||
data.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
data.setCreateBy(loginUser.getUserPo().getUserName());
|
||||
int row = dictDataMapper.insertDictData(data);
|
||||
if (row > 0)
|
||||
{
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(data.getDictType());
|
||||
Long oid = data.getOrganizationId() != null ? data.getOrganizationId() : 0L;
|
||||
dictData.setOrganizationId(oid);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
DictUtils.setDictCache(DictUtils.dictTypeOrgCacheKey(data.getDictType(), oid), dictDatas);
|
||||
DictUtils.removeDictCache(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
@@ -185,21 +203,29 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
throw new ServiceException("修改失败:无权修改其他组织的字典数据");
|
||||
}
|
||||
}
|
||||
applyOrganizationFromDictType(data, sysDictData.getDictType());
|
||||
fillOrganizationNameFromProductForDictData(data);
|
||||
if (data.getOrganizationId() == null)
|
||||
{
|
||||
data.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isEmpty(data.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
}
|
||||
if (data.getTopOrganizationId() == null)
|
||||
{
|
||||
data.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
data.setUpdateBy(loginUser.getUserPo().getUserName());
|
||||
Long oldOid = sysDictData.getOrganizationId() != null ? sysDictData.getOrganizationId() : 0L;
|
||||
int row = dictDataMapper.updateDictData(data);
|
||||
if (row > 0)
|
||||
{
|
||||
DictUtils.removeDictCache(DictUtils.dictTypeOrgCacheKey(sysDictData.getDictType(), oldOid));
|
||||
String dictTypeForCache = StringUtils.isNotEmpty(data.getDictType()) ? data.getDictType() : sysDictData.getDictType();
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(data.getDictType());
|
||||
Long oid = data.getOrganizationId() != null ? data.getOrganizationId()
|
||||
: (sysDictData.getOrganizationId() != null ? sysDictData.getOrganizationId() : 0L);
|
||||
dictData.setOrganizationId(oid);
|
||||
dictData.setDictType(dictTypeForCache);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
DictUtils.setDictCache(DictUtils.dictTypeOrgCacheKey(data.getDictType(), oid), dictDatas);
|
||||
DictUtils.removeDictCache(data.getDictType());
|
||||
DictUtils.removeDictCache(sysDictData.getDictType());
|
||||
DictUtils.setDictCache(dictTypeForCache, dictDatas);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
@@ -399,6 +425,69 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织信息优先从所属字典类型上带出;类型上未配置的字段由调用方用登录用户等补齐。
|
||||
*
|
||||
* @param dictTypeWhenDataTypeEmpty 修改场景下请求体可能不传 dictType,此时用库中原记录的字典类型编码查询类型表
|
||||
*/
|
||||
private void applyOrganizationFromDictType(SysDictData data, String dictTypeWhenDataTypeEmpty)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String dictType = StringUtils.isNotEmpty(data.getDictType()) ? data.getDictType() : dictTypeWhenDataTypeEmpty;
|
||||
if (StringUtils.isEmpty(dictType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SysDictType dictTypeRow = dictTypeService.selectDictTypeByType(dictType);
|
||||
if (dictTypeRow == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dictTypeRow.getOrganizationId() != null)
|
||||
{
|
||||
data.setOrganizationId(dictTypeRow.getOrganizationId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dictTypeRow.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(dictTypeRow.getOrganizationName());
|
||||
}
|
||||
if (dictTypeRow.getTopOrganizationId() != null)
|
||||
{
|
||||
data.setTopOrganizationId(dictTypeRow.getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
|
||||
private void fillOrganizationNameFromProductForDictData(SysDictData data)
|
||||
{
|
||||
if (data == null || data.getOrganizationId() == null || StringUtils.isNotEmpty(data.getOrganizationName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long oid = data.getOrganizationId();
|
||||
if (oid == 0L)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
AjaxResult res = productServiceFeign.getOrganizationInfo(oid);
|
||||
if (res != null && "200".equals(String.valueOf(res.get("code"))) && res.get("data") != null)
|
||||
{
|
||||
OrganizationPo po = JSONObject.parseObject(JSONObject.toJSONString(res.get("data")), OrganizationPo.class);
|
||||
if (po != null && StringUtils.isNotEmpty(po.getOrganizationName()))
|
||||
{
|
||||
data.setOrganizationName(po.getOrganizationName());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictData> selectDictList(SysDictData sysDictData) {
|
||||
return dictDataMapper.selectDictDataList(sysDictData);
|
||||
|
||||
+88
-47
@@ -3,9 +3,14 @@ package com.mhd.system.service.impl;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhd.basic.infrastructure.feign.ProductServiceFeign;
|
||||
import com.mhd.common.core.domain.po.OrganizationPo;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.system.mapper.SysDictDataMapper;
|
||||
import com.mhd.system.mapper.SysDictTypeMapper;
|
||||
import com.mhd.system.service.ISysDictTypeService;
|
||||
@@ -35,6 +40,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Autowired
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化字典到缓存
|
||||
*/
|
||||
@@ -76,47 +84,22 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType)
|
||||
{
|
||||
Long orgId = resolveLoginOrganizationIdForDict();
|
||||
String cacheKey = DictUtils.dictTypeOrgCacheKey(dictType, orgId);
|
||||
List<SysDictData> dictDatas = DictUtils.getDictCache(cacheKey);
|
||||
if (StringUtils.isEmpty(dictDatas))
|
||||
{
|
||||
dictDatas = DictUtils.getDictCache(dictType);
|
||||
}
|
||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas))
|
||||
{
|
||||
return dictDatas;
|
||||
}
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(dictType);
|
||||
dictData.setOrganizationId(orgId);
|
||||
dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
if (StringUtils.isNotEmpty(dictDatas))
|
||||
{
|
||||
DictUtils.setDictCache(cacheKey, dictDatas);
|
||||
DictUtils.setDictCache(dictType, dictDatas);
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 字典数据按组织隔离;未登录按平台 0 */
|
||||
private Long resolveLoginOrganizationIdForDict()
|
||||
{
|
||||
try
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null
|
||||
&& loginUser.getUserPo().getOrganizationId() != null)
|
||||
{
|
||||
return loginUser.getUserPo().getOrganizationId();
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
@@ -152,13 +135,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
for (Long dictId : dictIds)
|
||||
{
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
Long typeOrgId = dictType.getOrganizationId() != null ? dictType.getOrganizationId() : 0L;
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType(), typeOrgId) > 0)
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
|
||||
{
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
dictTypeMapper.deleteDictTypeById(dictId);
|
||||
DictUtils.removeDictCache(DictUtils.dictTypeOrgCacheKey(dictType.getDictType(), typeOrgId));
|
||||
DictUtils.removeDictCache(dictType.getDictType());
|
||||
}
|
||||
}
|
||||
@@ -171,8 +152,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
{
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setStatus("0");
|
||||
Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream()
|
||||
.collect(Collectors.groupingBy(d -> DictUtils.dictTypeOrgCacheKey(d.getDictType(), d.getOrganizationId())));
|
||||
Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
for (Map.Entry<String, List<SysDictData>> entry : dictDataMap.entrySet())
|
||||
{
|
||||
DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(SysDictData::getDictSort)).collect(Collectors.toList()));
|
||||
@@ -207,12 +187,15 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public int insertDictType(SysDictType dict)
|
||||
{
|
||||
fillOrganizationNameFromProductCenter(dict);
|
||||
if (dict.getOrganizationId() != null && StringUtils.isEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName("");
|
||||
}
|
||||
int row = dictTypeMapper.insertDictType(dict);
|
||||
if (row > 0)
|
||||
{
|
||||
Long oid = dict.getOrganizationId() != null ? dict.getOrganizationId() : 0L;
|
||||
DictUtils.removeDictCache(DictUtils.dictTypeOrgCacheKey(dict.getDictType(), oid));
|
||||
DictUtils.removeDictCache(dict.getDictType());
|
||||
DictUtils.setDictCache(dict.getDictType(), null);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
@@ -228,27 +211,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
public int updateDictType(SysDictType dict)
|
||||
{
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
|
||||
Long oldTypeOrgId = oldDict.getOrganizationId() != null ? oldDict.getOrganizationId() : 0L;
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType(), oldTypeOrgId);
|
||||
mergeDictTypeOrganizationNameForUpdate(dict, oldDict);
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
int row = dictTypeMapper.updateDictType(dict);
|
||||
if (row > 0)
|
||||
{
|
||||
if (dictDataMapper.countDictDataByType(dict.getDictType(), oldTypeOrgId) > 0)
|
||||
if (dictDataMapper.countDictDataByType(dict.getDictType()) > 0)
|
||||
{
|
||||
dictDataMapper.updateDictDataOrganizationByDictType(dict.getDictType(),
|
||||
dict.getOrganizationId(), dict.getOrganizationName(), dict.getTopOrganizationId(),
|
||||
oldTypeOrgId);
|
||||
dict.getOrganizationId(), dict.getOrganizationName(), dict.getTopOrganizationId());
|
||||
}
|
||||
DictUtils.removeDictCache(DictUtils.dictTypeOrgCacheKey(oldDict.getDictType(), oldTypeOrgId));
|
||||
DictUtils.removeDictCache(DictUtils.dictTypeOrgCacheKey(dict.getDictType(), dict.getOrganizationId()));
|
||||
DictUtils.removeDictCache(oldDict.getDictType());
|
||||
DictUtils.removeDictCache(dict.getDictType());
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setDictType(dict.getDictType());
|
||||
Long newOrgId = dict.getOrganizationId() != null ? dict.getOrganizationId() : 0L;
|
||||
dictData.setOrganizationId(newOrgId);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictData);
|
||||
DictUtils.setDictCache(DictUtils.dictTypeOrgCacheKey(dict.getDictType(), newOrgId), dictDatas);
|
||||
DictUtils.setDictCache(dict.getDictType(), dictDatas);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
@@ -270,4 +246,69 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型时,请求体常不带 organizationName;若与库中或当前登录用户组织一致则补全,避免 UPDATE 把名称写成 null。
|
||||
*/
|
||||
private void mergeDictTypeOrganizationNameForUpdate(SysDictType dict, SysDictType oldDict)
|
||||
{
|
||||
if (dict == null || oldDict == null || StringUtils.isNotEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dict.getOrganizationId() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(dict.getOrganizationId(), oldDict.getOrganizationId())
|
||||
&& StringUtils.isNotEmpty(oldDict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(oldDict.getOrganizationName());
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null
|
||||
&& Objects.equals(dict.getOrganizationId(), loginUser.getUserPo().getOrganizationId())
|
||||
&& StringUtils.isNotEmpty(loginUser.getUserPo().getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
}
|
||||
fillOrganizationNameFromProductCenter(dict);
|
||||
if (dict.getOrganizationId() != null && StringUtils.isEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 已存在 organizationId 但名称为空时,从产品中心按组织 id 补全名称(与 BasicAgreement 等模块一致)。
|
||||
*/
|
||||
private void fillOrganizationNameFromProductCenter(SysDictType dict)
|
||||
{
|
||||
if (dict == null || dict.getOrganizationId() == null || StringUtils.isNotEmpty(dict.getOrganizationName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long oid = dict.getOrganizationId();
|
||||
if (oid == 0L)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
AjaxResult res = productServiceFeign.getOrganizationInfo(oid);
|
||||
if (res != null && "200".equals(String.valueOf(res.get("code"))) && res.get("data") != null)
|
||||
{
|
||||
OrganizationPo po = JSONObject.parseObject(JSONObject.toJSONString(res.get("data")), OrganizationPo.class);
|
||||
if (po != null && StringUtils.isNotEmpty(po.getOrganizationName()))
|
||||
{
|
||||
dict.setOrganizationName(po.getOrganizationName());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
// 远程不可用时保持后续逻辑(如置空字符串以便 UPDATE 写入列)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,9 +58,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="topOrganizationId != null">
|
||||
and (top_organization_id = #{topOrganizationId} OR is_default = 'Y')
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
and (IFNULL(organization_id, 0) = #{organizationId} OR is_default = 'Y')
|
||||
</if>
|
||||
</where>
|
||||
order by dict_sort asc
|
||||
</select>
|
||||
@@ -76,9 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="countDictDataByType" resultType="Integer">
|
||||
select count(1) from sys_dict_data
|
||||
where dict_type = #{dictType}
|
||||
and IFNULL(organization_id, 0) = IFNULL(#{organizationId}, 0)
|
||||
select count(1) from sys_dict_data where dict_type=#{dictType}
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictDataById" parameterType="Long">
|
||||
@@ -113,10 +108,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where dict_code = #{dictCode}
|
||||
</update>
|
||||
|
||||
<update id="updateDictDataType">
|
||||
update sys_dict_data set dict_type = #{newDictType}
|
||||
where dict_type = #{oldDictType}
|
||||
and IFNULL(organization_id, 0) = IFNULL(#{organizationId}, 0)
|
||||
<update id="updateDictDataType" parameterType="String">
|
||||
update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
|
||||
</update>
|
||||
|
||||
<update id="updateDictDataOrganizationByDictType">
|
||||
@@ -126,7 +119,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
top_organization_id = #{topOrganizationId},
|
||||
update_time = sysdate()
|
||||
where dict_type = #{dictType}
|
||||
and IFNULL(organization_id, 0) = IFNULL(#{scopeOrganizationId}, 0)
|
||||
</update>
|
||||
|
||||
<insert id="insertDictData" parameterType="SysDictData">
|
||||
|
||||
@@ -64,14 +64,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType}
|
||||
order by (IFNULL(organization_id, 0) = 0) desc, dict_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkDictTypeUnique" parameterType="SysDictType" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType}
|
||||
and IFNULL(organization_id, 0) = IFNULL(#{organizationId}, 0)
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
@@ -109,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="organizationId != null">organization_id,</if>
|
||||
<if test="organizationName != null and organizationName != ''">organization_name,</if>
|
||||
<if test="organizationId != null">organization_name,</if>
|
||||
<if test="topOrganizationId != null">top_organization_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
@@ -119,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="organizationId != null">#{organizationId},</if>
|
||||
<if test="organizationName != null and organizationName != ''">#{organizationName},</if>
|
||||
<if test="organizationId != null">#{organizationName},</if>
|
||||
<if test="topOrganizationId != null">#{topOrganizationId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
|
||||
Reference in New Issue
Block a user