Commit facdeac3 authored by 赵啸非's avatar 赵啸非

修改设备新增

parent 55747c41
......@@ -123,3 +123,6 @@ INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'l
INSERT INTO `mortals_xhx_param` VALUES (null, '设备来源,为其它时候上线下线通过查询', 'Device', 'deviceSource', '0', '大厅', 1, 4, 0, 'deviceSource', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '设备来源,为其它时候上线下线通过查询', 'Device', 'deviceSource', '1', '其它', 1, 4, 0, 'deviceSource', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '设备类型', 'Device', 'deviceType', '13', '无感一码通', 1, 4, 0, 'deviceType', NULL, NULL, NULL);
......@@ -34,12 +34,12 @@ export default {
},
loginFail(error) {
this.$message.error(error.message || '请登录');
// this.$router.replace({
// path: '/login',
// query: {
// redirect: this.redirect,
// }
// });
this.$router.replace({
path: '/login',
query: {
redirect: this.redirect,
}
});
},
getUrlKey (name) {
......
package com.mortals.xhx.base.system.param.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.code.YesNo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.IParam;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.param.dao.ParamDao;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.model.ParamQuery;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
......@@ -32,69 +27,43 @@ import java.util.stream.Collectors;
@Service("paramService")
public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, ParamEntity, Long>
implements ParamService {
@Override
protected String getExtKey(ParamEntity data) {
return data.getParamKey();
}
@Override
protected String getCacheName() {
return "ParamEntity.paramKey";
}
@Override
public void putCache(String key, ParamEntity data) {
cacheService.set(data.getParamKey(), data.getParamValue());
}
@Override
public void removeCache(String key) {
}
@Override
public int remove(Long[] ids, Context context) throws AppException {
// 先删缓存
for (Long id : ids) {
ParamEntity paramEntity = get(id, null);
cacheService.del(paramEntity.getParamKey());
}
removeBefore(ids, context);
int iRet = dao.delete(ids);
removeAfter(ids, context, iRet);
return iRet;
}
@Override
public String getValueByKey(String key) {
return cacheService.get(key);
List<ParamEntity> list = this.getCacheList();
Map<String, String> keyValueMap = list.parallelStream().collect(Collectors.toMap(x -> x.getParamKey(), y -> y.getParamValue(), (o, n) -> n));
return keyValueMap.getOrDefault(key, "");
}
@Override
public Map<String, String> getParamByFirstOrganize(String firstOrganize, String... excludeParamKeys) {
ParamQuery query = new ParamQuery();
query.setFirstOrganize(firstOrganize);
List<ParamEntity> list = this.getDao().getList(query);
return list.stream().filter(s -> {
return !Arrays.asList(excludeParamKeys).contains(s.getParamKey());
}).collect(Collectors.toMap(ParamEntity::getParamKey, ParamEntity::getParamValue));
List<ParamEntity> list = this.getCacheList();
return list.stream()
.filter(f -> firstOrganize.equals(f.getFirstOrganize()))
.filter(s ->
!Arrays.asList(excludeParamKeys).contains(s.getParamKey())
).collect(Collectors.toMap(ParamEntity::getParamKey, ParamEntity::getParamValue, (o, n) -> n));
}
public Map<String, String> getParamBySecondOrganize(String firstOrganize, String secondOrganize, String... excludeParamKeys) {
ParamQuery query = new ParamQuery();
query.setFirstOrganize(firstOrganize);
query.setSecondOrganize(secondOrganize);
List<ParamEntity> list = this.getDao().getList(query);
return list.stream().filter(s -> {
return !Arrays.asList(excludeParamKeys).contains(s.getParamKey());
}).collect(Collectors.toMap(ParamEntity::getParamKey, ParamEntity::getParamValue));
List<ParamEntity> list = this.getCacheList();
return list.stream()
.filter(f -> firstOrganize.equals(f.getFirstOrganize()))
.filter(f -> secondOrganize.equals(f.getSecondOrganize()))
.filter(s ->
!Arrays.asList(excludeParamKeys).contains(s.getParamKey())
).collect(Collectors.toMap(ParamEntity::getParamKey, ParamEntity::getParamValue, (o, n) -> n));
}
@Override
public boolean needRefresh() {
if (super.cacheService.isShareCache())//共享缓存,不需要实时刷新
{
if (super.cacheService.isShareCache()) {
//共享缓存如redis,不需要实时刷新
return false;
}
IParam param = this.findByKey(IParam.KEY_PARAM_REFRESH_COUNT);
......@@ -122,174 +91,81 @@ public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, Par
@Override
public IParam findByKey(String key) throws AppException {
ParamQuery params = new ParamQuery();
params.setValidStatus(YesNo.YES.getValue());
params.setParamKey(key);
List<ParamEntity> list = super.find(params, null);
if (list != null && !list.isEmpty()) {
return list.get(0);
}
return null;
return this.getCacheList().stream().filter(f -> key.equals(f.getParamKey())).findFirst().orElseGet(() -> null);
}
@Override
public List<? extends IParam> findAll() throws AppException {
ParamQuery params = new ParamQuery();
params.setValidStatus(YesNo.YES.getValue());
return super.find(params, null);
return this.getCacheList();
}
@Override
public boolean containsParamKey(String key) {
return cacheService.hget(getCacheName(), key) != null;
List<ParamEntity> list = this.getCacheList();
Map<String, String> keyValueMap = list.parallelStream().collect(Collectors.toMap(x -> x.getParamKey(), y -> y.getParamValue(), (o, n) -> n));
return keyValueMap.containsKey(key);
}
@Override
public IParam getParamByKey(String key) {
return getExtCache(key);
List<ParamEntity> list = this.getCacheList();
Map<String, IParam> keyValueMap = list.parallelStream().collect(Collectors.toMap(x -> x.getParamKey(), y -> y, (o, n) -> n));
return keyValueMap.get(key);
}
@Override
public String getParamValue(String key) {
String hget = cacheService.hget(getCacheName(), key);
if (StringUtils.isEmpty(hget))return "";
IParam param = wrapParamObject(hget);
// IParam param = getExtCache(key);
if (param != null) {
return StringUtils.trim(param.getParamValue());
}
return "";
List<ParamEntity> list = this.getCacheList();
Map<String, String> keyValueMap = list.parallelStream().collect(Collectors.toMap(x -> x.getParamKey(), y -> y.getParamValue(), (o, n) -> n));
return keyValueMap.getOrDefault(key, "");
}
private IParam wrapParamObject(String entityString) {
JSONObject jsonObject = JSON.parseObject(entityString);
ParamEntity param = new ParamEntity();
param.setCreateTime(jsonObject.getDate("createTime"));
param.setCreateUserId(jsonObject.getLong("createUserId"));
param.setDisplayType(jsonObject.getInteger("displayType"));
param.setFirstOrganize(jsonObject.getString("firstOrganize"));
param.setId(jsonObject.getLong("id"));
param.setModStatus(jsonObject.getInteger("modStatus"));
param.setName(jsonObject.getString("name"));
param.setParamKey(jsonObject.getString("paramKey"));
param.setParamValue(jsonObject.getString("paramValue"));
param.setValidStatus(jsonObject.getInteger("validStatus"));
return param;
}
@Override
public String getParamValue(String key, String defaultValue) {
if (containsParamKey(key)) {
String value = getParamValue(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
return value;
} else {
log.debug("cannot found key[" + key + "], use default value[" + defaultValue + "]");
return defaultValue;
}
}
@Override
public int getParamIntValue(String key) {
ParamEntity extCache = getExtCache(key);
IParam param = extCache;
try {
if (param == null) {
return 0;
}
String value = param.getParamValue();
if (StringUtils.isEmpty(value)) {
return 0;
} else {
return Integer.parseInt(value);
}
} catch (Exception e) {
return 0;
}
return DataUtil.converStr2Int(getParamValue(key), 0);
}
@Override
public int getParamIntValue(String key, int defaultValue) {
if (containsParamKey(key)) {
String value = getParamValue(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (Exception e) {
log.debug("cannot conver key[" + key + "]'s value[" + value + "] to int, use default value[" + defaultValue + "]");
return defaultValue;
}
} else {
log.debug("cannot found key[" + key + "], use default value[" + defaultValue + "]");
return defaultValue;
}
return DataUtil.converStr2Int(getParamValue(key), defaultValue);
}
@Override
public long getParamLongValue(String key) {
IParam param = getExtCache(key);
try {
if (param == null) {
return 0;
}
String value = param.getParamValue();
if (StringUtils.isEmpty(value)) {
return 0;
} else {
return Long.parseLong(value);
}
} catch (Exception e) {
return 0;
}
return DataUtil.converStr2Long(getParamValue(key), 0L);
}
@Override
public long getParamLongValue(String key, long defaultValue) {
if (containsParamKey(key)) {
String value = getParamValue(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
try {
return Long.parseLong(value);
} catch (Exception e) {
log.debug("cannot conver key[" + key + "]'s value[" + value + "] to long, use default value[" + defaultValue + "]");
return defaultValue;
}
} else {
log.debug("cannot found key[" + key + "], use default value[" + defaultValue + "]");
return defaultValue;
}
return DataUtil.converStr2Long(getParamValue(key), defaultValue);
}
@Override
public boolean getParamBooleanValue(String key) {
IParam param = getExtCache(key);
try {
if (param == null) {
return false;
}
String value = param.getParamValue();
String value = getParamValue(key);
if (StringUtils.isEmpty(value)) {
return false;
} else {
return Boolean.parseBoolean(value);
}
try {
return Boolean.parseBoolean(value);
} catch (Exception e) {
return false;
}
}
@Override
public boolean getParamBooleanValue(String key, boolean defaultValue) {
if (containsParamKey(key)) {
String value = getParamValue(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
......@@ -300,9 +176,6 @@ public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, Par
log.debug("cannot conver key[" + key + "]'s value[" + value + "] to boolean, use default value[" + defaultValue + "]");
return defaultValue;
}
} else {
log.debug("cannot found key[" + key + "], use default value[" + defaultValue + "]");
return defaultValue;
}
}
}
\ No newline at end of file
package com.mortals.xhx.base.system.param.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.common.code.PageDisplayType;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DataSatusEnum;
import com.mortals.xhx.common.code.ModStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......
......@@ -91,7 +91,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
* 定时清除设备日志
*/
private void doDeviceLogDel() {
//默认保存30天日志
//默认保存15天日志
int timeout = -GlobalSysInfo.getParamIntValue(ParamKey.SYS_PARAM_LOG_TIME, 15);
try {
DeviceLogQuery query = new DeviceLogQuery();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment