package com.product.admin.service;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Set;
|
|
import com.google.common.collect.Sets;
|
import com.product.admin.service.idel.IDictService;
|
import com.product.common.lang.StringUtils;
|
import com.product.core.config.CoreConst;
|
import com.product.core.transfer.Transactional;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import com.product.core.dao.BaseDao;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.core.service.support.QueryFilterService;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.module.sys.entity.SystemUser;
|
import com.product.util.BaseUtil;
|
import com.product.admin.config.CmnConst;
|
import com.product.admin.config.SystemCode;
|
|
/**
|
* Copyright LX-BASE
|
*
|
* @Title: DictService
|
* @Project: LX-BASE-SERVER
|
* @Date: 2020年5月30日 上午11:56:57
|
* @Author: 郑盟
|
* @Description:普通参照配置
|
*/
|
@Component
|
public class DictService extends AbstractBaseService implements IDictService {
|
/**
|
* 数据查询 ,spring 注入
|
*/
|
@Autowired
|
public BaseDao baseDao;
|
@Autowired
|
|
public QueryFilterService queryFilterService;
|
|
private final String SYSTEM_CACHE_KEY = "system-cache:dict";
|
|
|
public void initCache(FieldSetEntity fse) {
|
if (fse == null || StringUtils.isEmpty(fse.getString(CmnConst.UUID))) {
|
//更新所有
|
DataTableEntity dt = baseDao.listTable(CmnConst.PRODUCT_SYS_DICT, "is_used=1");
|
}
|
}
|
|
|
public void initCache() {
|
|
}
|
|
public FieldSetEntity findDict(FieldSetEntity fse) throws BaseException {
|
|
return baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DICT, fse.getString("uuid"), false), null);
|
}
|
|
/**
|
* 手机端专用
|
*
|
* @return
|
* @throws BaseException
|
*/
|
public FieldSetEntity findDictForMobile(FieldSetEntity fse, String language_code) throws BaseException {
|
|
return baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DICT, fse.getString("uuid"), false),
|
language_code);
|
}
|
|
public DataTableEntity listDict(FieldSetEntity fse) throws BaseException {
|
// 郑盟 12-18 12:02
|
String queryFilter = "";
|
String filter = fse.getString("filter");
|
if (!StringUtils.isEmpty(filter)) {
|
queryFilter += " and (" + filter + ")";
|
}
|
DataTableEntity dt = null;
|
if (!BaseUtil.dataTableIsEmpty(fse.getSubDataTable("systemSeniorQueryString"))) {
|
queryFilter = " and " + queryFilterService.getQueryFilter(fse);
|
}
|
StringBuilder sql = new StringBuilder();
|
SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
|
String manager_type = null;
|
|
if (currentUser != null && currentUser.getCurrentManager() != null) {
|
manager_type = currentUser.getCurrentManager().getString("manager_type");
|
}
|
if (StringUtils.isEmpty(manager_type)) {
|
return null;
|
} else if ("1".equals(manager_type) || "4".equals(manager_type)) {
|
sql.append(" select * FROM product_sys_dict where (client_uuid is null or client_uuid='') ");
|
sql.append(queryFilter);
|
sql.append(" order by dict_name ");
|
dt = baseDao.listTable(sql.toString(), new Object[]{}, fse.getInteger("pagesize"), fse.getInteger("cpage"));
|
|
} else {
|
String client_uuid = SpringMVCContextHolder.getCurrentUser().getClient_uuid();
|
// 郑盟 12-18 12:02
|
if (!StringUtils.isEmpty(client_uuid)) {
|
sql.append("SELECT a.dict_value_img,a.dict_value_color,a.dict_id,a.uuid,a.dict_name,a.dict_label,a.is_used,a.sequence,a.dict_value FROM (SELECT * FROM (select dict_value_img,dict_value_color,dict_id,uuid,dict_name,dict_label,is_used,sequence,dict_value FROM product_sys_dict WHERE (client_uuid is null or client_uuid='') ");
|
sql.append(queryFilter);
|
sql.append(" and is_used=1 and CONCAT(dict_name,dict_value ) not in(");
|
sql.append(" select CONCAT(dict_name,dict_value ) FROM product_sys_dict WHERE client_uuid='");
|
sql.append(client_uuid);
|
sql.append("') union all ");
|
sql.append(" select dict_value_img,dict_value_color,dict_id,uuid,dict_name,dict_label,is_used,sequence,dict_value FROM product_sys_dict b WHERE is_used=1 ");
|
sql.append(queryFilter);
|
sql.append(" and client_uuid='");
|
sql.append(client_uuid);
|
sql.append("') a) a ");
|
dt = baseDao.listTable(sql.toString(), new Object[]{}, fse.getInteger("pagesize"), fse.getInteger("cpage"));
|
dt.getMeta().addAliasTable(CmnConst.PRODUCT_SYS_DICT, "a");
|
} else {
|
return null;
|
}
|
}
|
DataTableEntity dataTableEntity = baseDao.listInternationDataTable(dt, null);
|
baseDao.loadPromptData(dataTableEntity);
|
return dataTableEntity;
|
}
|
|
public DataTableEntity listDictForMobile(Integer cpage, Integer pagesize, String language_code)
|
throws BaseException {
|
StringBuilder sql = new StringBuilder();
|
SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
|
String manager_type = null;
|
if (currentUser != null && currentUser.getCurrentManager() != null) {
|
manager_type = currentUser.getCurrentManager().getString("manager_type");
|
}
|
// 郑盟 2020年12月17日 下午15:55
|
if (StringUtils.isEmpty(manager_type)) {
|
return null;
|
} else if ("1".equals(manager_type) || "4".equals(manager_type)) {
|
sql.append("select * FROM product_sys_dict where client_uuid is null or client_uuid='' order by dict_name");
|
} else {
|
String client_uuid = SpringMVCContextHolder.getCurrentUser().getClient_uuid();
|
// 郑盟 2020年12月17日 下午15:55
|
if (!StringUtils.isEmpty(client_uuid)) {
|
sql.append(" select * FROM product_sys_dict WHERE (client_uuid is null or client_uuid='') and CONCAT(dict_name,dict_value ) not in(");
|
sql.append(" select CONCAT(dict_name,dict_value ) FROM product_sys_dict WHERE client_uuid='");
|
sql.append(client_uuid);
|
sql.append("') union all");
|
sql.append(" select * FROM product_sys_dict WHERE client_uuid='");
|
sql.append(client_uuid + "'");
|
} else {
|
return null;
|
}
|
}
|
DataTableEntity dataTableEntity = baseDao
|
.listInternationDataTable(baseDao.listTable(sql.toString(), new Object[]{}, pagesize, cpage), language_code);
|
|
baseDao.loadPromptData(dataTableEntity);
|
return dataTableEntity;
|
}
|
|
public DataTableEntity listDictByname(FieldSetEntity fse, String manager_type) throws BaseException {
|
String dictName = fse.getString("dict_name");
|
// 郑盟 2020年12月17日 下午15:55
|
if (StringUtils.isEmpty(dictName)) {
|
return null;
|
}
|
StringBuilder sql = new StringBuilder();
|
SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
|
String client_uuid = null;
|
if (currentUser != null && currentUser.getClient_uuid() != null) {
|
client_uuid = currentUser.getClient_uuid();
|
}
|
List<Object> params = new ArrayList<>();
|
params.add(dictName);
|
//updatetime 2021年1月15日16:07:48 xupengcheng 增加客户端类型过滤,修改参数传递方式 改为占位符
|
if (("1".equals(manager_type) || "4".equals(manager_type)) && (currentUser != null && currentUser.getCurrentManager() != null)) {
|
sql.append("select dict_id,uuid,dict_name,dict_label,is_used,sequence,dict_value FROM product_sys_dict where dict_name=? and concat(',',client_type,',') like concat('%,',?,',%') and is_used=1 and (client_uuid is null or client_uuid='') order by sequence");
|
params.add(fse.getString(CoreConst.SYSTEM_CLIENT_TYPE_));
|
} else {
|
//SELECT包两层 给最外层a 别名表名完成国际化 郑盟 2020/12/21
|
sql.append("SELECT a.dict_value_img,a.dict_value_color,a.dict_id,a.uuid,a.dict_name,a.dict_label,a.is_used,a.sequence,a.dict_value FROM (SELECT * FROM (select dict_value_img,dict_value_color,dict_id,uuid,dict_name,dict_label,is_used,sequence,dict_value FROM product_sys_dict WHERE (client_uuid is null or client_uuid='') and dict_name=? and is_used=1 and CONCAT(dict_name,dict_value ) not in(");
|
sql.append("select CONCAT(dict_name,dict_value ) FROM product_sys_dict WHERE client_uuid= ? ");
|
sql.append(" ) union all");
|
sql.append(" select dict_value_img,dict_value_color,dict_id,uuid,dict_name,dict_label,is_used,sequence,dict_value FROM product_sys_dict b WHERE dict_name=? ");
|
sql.append(" and is_used=1 and client_uuid= ? ");
|
sql.append(" and concat(',',client_type,',') like concat('%,',?,',%')");
|
sql.append(" ) a) a");
|
params.add(client_uuid);
|
params.add(dictName);
|
params.add(client_uuid);
|
params.add(fse.getString(CoreConst.SYSTEM_CLIENT_TYPE_));
|
}
|
DataTableEntity listTable = baseDao.listTable(sql.toString(), params.toArray());
|
listTable.getMeta().addAliasTable(CmnConst.PRODUCT_SYS_DICT, "a");
|
return baseDao.listInternationDataTable(listTable, null);
|
}
|
|
|
public String addDict(FieldSetEntity fse, String client_uuid) throws BaseException {
|
String filter = "";
|
// 郑盟 2020年12月17日 下午15:55
|
if (!StringUtils.isEmpty(client_uuid)) {
|
filter = " and client_uuid= '" + client_uuid + "'";
|
fse.setValue(CmnConst.CLIENT_UUID, client_uuid);
|
}
|
if (!dictRepeat(fse, filter)) {
|
throw new BaseException(SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getText(), this.getClass(), "public String addDict(FieldSetEntity fse, String client_uuid) throws BaseException");
|
}
|
fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
|
return baseDao.add(fse);
|
}
|
|
/**
|
* 批量删除数据字典
|
* 如该字典包含个性化 或通用字典 则对应无权限操作
|
*
|
* @param dict_name
|
* @throws BaseException
|
* @auth cheng
|
* @date 2021年11月29日15:01:43
|
*/
|
public void deleteMultipleDict(String dict_name) throws BaseException {
|
String client_uuid = getClientUuid();
|
StringBuilder sql = new StringBuilder();
|
sql.append(" SELECT count(dict_name) count FROM product_sys_dict ");
|
sql.append(" where ");
|
//当前客户uuid不为空说明是该客户进行操作 判断该字典所有数据是否所属该客户
|
if (!StringUtils.isEmpty(client_uuid)) {
|
//个性化操作
|
sql.append(" (client_uuid is null or client_uuid ='') ");
|
} else {
|
//当前客户uuid为空说明是超级管理员操作 判断该字典所有数据是否为通用数据
|
sql.append(" length(client_uuid)>0 ");
|
}
|
sql.append(" AND (dict_name=?)");
|
FieldSetEntity f = baseDao.getFieldSetEntityBySQL(sql.toString(), new Object[]{dict_name}, false);
|
//不判断查询结果是否为空 如有报错则说明逻辑错误
|
if (f.getInteger("count") > 0) {
|
throw new BaseException(SystemCode.MULTIPLE_DELETE_NOT_PERMISSION.getValue(), SystemCode.MULTIPLE_DELETE_NOT_PERMISSION.getText());
|
} else {
|
baseDao.delete(CmnConst.PRODUCT_SYS_DICT, "dict_name=?", new Object[]{dict_name});
|
}
|
}
|
|
public DataTableEntity getDictTree() {
|
String clientUuid = getClientUuid();
|
if (!StringUtils.isEmpty(clientUuid)) {
|
return baseDao.listTable("select dict_name FROM product_sys_dict where client_uuid is null or client_uuid in ('',?) GROUP BY dict_name", new Object[]{clientUuid});
|
}
|
return baseDao.listTable("select dict_name FROM product_sys_dict GROUP BY dict_name ", new Object[]{});
|
}
|
|
public boolean updateDictIsUsed(FieldSetEntity fse) {
|
String clientUuid = getClientUuid();
|
|
FieldSetEntity f = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DICT, fse.getUUID(), false);
|
if (f != null) {
|
boolean noPermission = false;
|
if (StringUtils.isEmpty(clientUuid) && StringUtils.isEmpty(f.getString(CmnConst.CLIENT_UUID))) {
|
|
} else if (!StringUtils.isEmpty(clientUuid) && !clientUuid.equals(f.getString(CmnConst.CLIENT_UUID))) {
|
noPermission = true;
|
} else if (!StringUtils.isEmpty(f.getString(CmnConst.CLIENT_UUID)) && !f.getString(CmnConst.CLIENT_UUID).equals(clientUuid)) {
|
noPermission = true;
|
}
|
if (noPermission) {
|
|
throw new BaseException(SystemCode.OPER_DICT_NOT_PERMISSION.getValue(), SystemCode.OPER_DICT_NOT_PERMISSION.getText());
|
}
|
}
|
if (!StringUtils.isEmpty(fse.getUUID())) {
|
StringBuilder sql = new StringBuilder();
|
sql.append(" UPDATE product_sys_dict ");
|
sql.append(" SET is_used = ( SELECT is_used FROM ( ");
|
sql.append("SELECT CASE WHEN is_used = 1 THEN 0 ELSE 1 END AS is_used FROM product_sys_dict WHERE uuid = ? ");
|
sql.append(" ) a ) ");
|
sql.append(" WHERE ");
|
sql.append(" uuid = ? ");
|
baseDao.executeUpdate(sql.toString(), new Object[]{fse.getUUID(), fse.getUUID()});
|
return true;
|
}
|
return false;
|
}
|
|
|
public String getClientUuid() {
|
|
SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
|
String manager_type = null;
|
if (currentUser != null && currentUser.getCurrentManager() != null) {
|
manager_type = currentUser.getCurrentManager().getString(CmnConst.MANAGER_TYPE);
|
} else {
|
throw new BaseException(SystemCode.SYSTEM_NOTOBTAINEDROLE_FAIL.getValue(),
|
SystemCode.SYSTEM_NOTOBTAINEDROLE_FAIL.getText());
|
}
|
String client_uuid = "1".equals(manager_type) || "4".equals(manager_type) ? ""
|
: SpringMVCContextHolder.getCurrentUser().getClientUuid();
|
return client_uuid;
|
}
|
|
public FieldSetEntity findMultipleDict(FieldSetEntity fse) throws BaseException {
|
String client_uuid = getClientUuid();
|
String dict_name = fse.getString("dict_name");
|
StringBuilder sql = new StringBuilder();
|
sql.append(" SELECT ");
|
sql.append(" * ");
|
sql.append(" FROM ");
|
sql.append(" product_sys_dict ");
|
sql.append(" WHERE ");
|
sql.append(" ( client_uuid IS NULL OR client_uuid = '' ) ");
|
sql.append(" AND dict_name = ? ");
|
Object[] objects = new Object[]{dict_name};
|
if (!StringUtils.isEmpty(client_uuid)) {
|
sql.append(" AND CONCAT( dict_name, dict_value ) NOT IN ( SELECT CONCAT( dict_name, dict_value ) FROM product_sys_dict WHERE client_uuid = ? ) UNION ALL ");
|
sql.append(" SELECT ");
|
sql.append(" * ");
|
sql.append(" FROM ");
|
sql.append(" product_sys_dict b ");
|
sql.append(" WHERE ");
|
sql.append(" dict_name = ? ");
|
sql.append(" AND client_uuid = ? ");
|
objects = new Object[]{dict_name, client_uuid, dict_name, client_uuid};
|
}
|
sql.append(" ORDER BY created_utc_datetime ");
|
DataTableEntity dt = baseDao.listTable(sql.toString(), objects);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName(CmnConst.PRODUCT_SYS_DICT);
|
fs.setValue(CmnConst.DICT_NAME, dict_name);
|
if (!BaseUtil.dataTableIsEmpty(dt)) {
|
dt.getMeta().setTableName(new Object[]{CmnConst.PRODUCT_SYS_DICT});
|
fs.addSubDataTable(dt);
|
}
|
return fs;
|
}
|
|
/**
|
* 批量保存数据字典
|
*
|
* @param fse
|
* @throws BaseException
|
* @date 2021年11月26日17:07:53
|
* @aUth cheng
|
*/
|
@Transactional
|
public boolean saveDict(FieldSetEntity fse) throws BaseException {
|
SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
|
String manager_type = null;
|
if (currentUser != null && currentUser.getCurrentManager() != null) {
|
manager_type = currentUser.getCurrentManager().getString(CmnConst.MANAGER_TYPE);
|
} else {
|
throw new BaseException(SystemCode.SYSTEM_NOTOBTAINEDROLE_FAIL.getValue(),
|
SystemCode.SYSTEM_NOTOBTAINEDROLE_FAIL.getText());
|
}
|
String client_uuid = "1".equals(manager_type) || "4".equals(manager_type) ? ""
|
: SpringMVCContextHolder.getCurrentUser().getClientUuid();
|
String dict_name = fse.getString(CmnConst.DICT_NAME);
|
DataTableEntity historyData = baseDao.listTable(CmnConst.PRODUCT_SYS_DICT, "dict_name=?", new Object[]{dict_name});
|
|
DataTableEntity subDataTable = fse.getSubDataTable(CmnConst.PRODUCT_SYS_DICT);
|
if (!BaseUtil.dataTableIsEmpty(subDataTable)) {
|
Set<String> keySet = Sets.newHashSet();
|
for (int i = 0; i < subDataTable.getRows(); i++) {
|
//新提交的数据
|
FieldSetEntity fs = subDataTable.getFieldSetEntity(i);
|
fs.setValue(CmnConst.DICT_NAME, dict_name);
|
// 默认客户端类型为 web
|
fs.setValue("client_type", "Web");
|
String key = dict_name + fs.getString(CmnConst.DICT_VALUE);
|
//判断数据字典值是否重复
|
if (keySet.contains(key)) {
|
throw new BaseException(SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getText());
|
} else {
|
keySet.add(key);
|
}
|
String uuid = fs.getString("uuid");
|
if (StringUtils.isEmpty(uuid)) {
|
//新增的数据
|
//客户uuid不为空时 该字典是客户个性化的
|
if (!StringUtils.isEmpty(client_uuid)) {
|
fs.setValue(CmnConst.CLIENT_UUID, client_uuid);
|
}
|
//添加创建时间、创建人
|
BaseUtil.createCreatorAndCreationTime(fs);
|
} else {
|
if (BaseUtil.dataTableIsEmpty(historyData)) {
|
historyData = subDataTable;
|
}
|
//旧数据
|
List<FieldSetEntity> fieldSetEntity = historyData.getFieldSetEntity(uuid);
|
FieldSetEntity historyFs = fieldSetEntity.get(0);
|
//判断是否个性化 前提
|
if (!StringUtils.isEmpty(client_uuid) && StringUtils.isEmpty(fs.getString(CmnConst.CLIENT_UUID))) {
|
//判断是否修改过通用数据
|
if (isUpdateDict(fs, historyFs)) {
|
//修改过 将uuid去掉 变为该客户个性化字典
|
fs.setValue(CmnConst.CLIENT_UUID, client_uuid);
|
fs.setValue(CmnConst.UUID, null);
|
//去掉更新时间、更新人
|
fs.setValue(CmnConst.UPDATED_BY, null);
|
fs.setValue(CmnConst.UPDATED_UTC_DATETIME, null);
|
//添加创建时间、创建人
|
BaseUtil.createCreatorAndCreationTime(fs);
|
}
|
}
|
}
|
}
|
|
return baseDao.update(subDataTable);
|
}
|
return false;
|
|
}
|
|
/**
|
* 判断历史数据字典和现有数据字典是否变化
|
*
|
* @param fse
|
* @param historyFse
|
* @return
|
*/
|
public boolean isUpdateDict(FieldSetEntity fse, FieldSetEntity historyFse) {
|
//需要对比的字段集合
|
String[] fieldNames = {CmnConst.DICT_LABEL, CmnConst.DICT_VALUE, CmnConst.DICT_VALUE_COLOR, CmnConst.DICT_VALUE_IMG};
|
for (String fieldName : fieldNames) {
|
String value = fse.getString(fieldName);
|
String historyValue = historyFse.getString(fieldName);
|
if (StringUtils.isEmpty(value) && StringUtils.isEmpty(historyValue)) {
|
continue;
|
} else if (StringUtils.isEmpty(value) && !StringUtils.isEmpty(historyValue)) {
|
return true;
|
} else if (!StringUtils.isEmpty(value) && StringUtils.isEmpty(historyValue)) {
|
return true;
|
} else if (!value.equals(historyValue)) {
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public String addDict(FieldSetEntity fse, String client_uuid, String language_code) throws BaseException {
|
String filter = "";
|
// 郑盟 2020年12月17日 下午15:55
|
if (!StringUtils.isEmpty(client_uuid)) {
|
filter = " and client_uuid= '" + client_uuid + "'";
|
fse.setValue(CmnConst.CLIENT_UUID, client_uuid);
|
}
|
if (!dictRepeat(fse, filter)) {
|
throw new BaseException(SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getText(), this.getClass(), "public String addDict(FieldSetEntity fse, String client_uuid, String language_code) throws BaseException");
|
}
|
fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
|
return baseDao.add(fse);
|
}
|
|
/**
|
* 验证数据字典是否重复
|
*
|
* @throws BaseException
|
*/
|
public boolean dictRepeat(FieldSetEntity fse, String filter) throws BaseException {
|
String uuidFilter = "";
|
String likeclient = "";
|
// 郑盟 2020年12月17日 下午15:55
|
if (!StringUtils.isEmpty(fse.getString("uuid"))) {
|
uuidFilter = "and uuid!='" + fse.getString("uuid") + "'";
|
}
|
// 郑盟 2020年12月17日 下午15:55
|
if (StringUtils.isEmpty(filter)) {
|
String client_uuid = fse.getString(CmnConst.CLIENT_UUID);
|
if (!StringUtils.isEmpty(client_uuid)) {
|
likeclient = "and (client_uuid = '" + client_uuid + "')";
|
}
|
}
|
DataTableEntity dd = baseDao.listTable(CmnConst.PRODUCT_SYS_DICT,
|
"dict_name=? and dict_value=? " + likeclient + " " + uuidFilter + " " + filter + "",
|
new Object[]{fse.getString("dict_name"), fse.getString("dict_value")});
|
|
if (dd != null && dd.getRows() > 0) {
|
return false;
|
}
|
return true;
|
}
|
|
public boolean updateDict(FieldSetEntity fse, String language_code) throws BaseException {
|
String uuid = fse.getString("uuid");
|
FieldSetEntity fs = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DICT, uuid, false);
|
String client_uuid = fs.getString(CmnConst.CLIENT_UUID);
|
String org_level = SpringMVCContextHolder.getCurrentUser().getClient_uuid();
|
if (StringUtils.isEmpty(org_level)) {
|
return false;
|
}
|
if (StringUtils.isEmpty(client_uuid)) {
|
fse.remove("uuid");
|
String addDict = addDict(fse, org_level);
|
return addDict != null && !"".equals(addDict);
|
} else if (client_uuid.equals(org_level)) {
|
String filter = " and client_uuid='" + client_uuid + "'";
|
if (!dictRepeat(fse, filter)) {
|
throw new BaseException(SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getText(), this.getClass(), "public boolean updateDict(FieldSetEntity fse, String language_code) throws BaseException");
|
}
|
fse.setValue(CmnConst.CLIENT_UUID, client_uuid);
|
fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
|
return baseDao.update(fse);
|
} else {
|
throw new BaseException(SystemCode.SYSTEM_DICTLEVELS_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTLEVELS_UPDATE_FAIL.getText(), this.getClass(), "public boolean updateDict(FieldSetEntity fse, String language_code) throws BaseException");
|
}
|
}
|
|
public boolean updateDict(FieldSetEntity fse) throws BaseException {
|
String uuid = fse.getString("uuid");
|
FieldSetEntity fs = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DICT, uuid, false);
|
String client_uuid = fs.getString(CmnConst.CLIENT_UUID);
|
String org_level = SpringMVCContextHolder.getCurrentUser().getClient_uuid();
|
if (StringUtils.isEmpty(org_level)) {
|
return false;
|
}
|
// 郑盟 2020年12月17日 下午15:55
|
if (StringUtils.isEmpty(client_uuid)) {
|
fse.remove("uuid");
|
String addDict = addDict(fse, org_level);
|
return addDict != null && !"".equals(addDict);
|
} else if (client_uuid.equals(org_level)) {
|
String filter = " and client_uuid='" + client_uuid + "'";
|
if (!dictRepeat(fse, filter)) {
|
throw new BaseException(SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTREPEAT_ADD_FAIL.getText(), this.getClass(), "public boolean updateDict(FieldSetEntity fse) throws BaseException");
|
}
|
fse.setValue(CmnConst.CLIENT_UUID, client_uuid);
|
fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
|
return baseDao.update(fse);
|
} else {
|
throw new BaseException(SystemCode.SYSTEM_DICTLEVELS_UPDATE_FAIL.getValue(),
|
SystemCode.SYSTEM_DICTLEVELS_UPDATE_FAIL.getText(), this.getClass(), "public boolean updateDict(FieldSetEntity fse) throws BaseException");
|
}
|
|
}
|
|
}
|