Browse Source

APP功能修复,在线离线定时任务

2024年8月20日16:45:03
thing_master
lishuai 1 year ago
parent
commit
fe474d3324
  1. 2
      modules/alarm/src/main/java/com/thing/alarm/alarm/service/impl/AlarmConfigServiceImpl.java
  2. 39
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java
  3. 4
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/entity/EqWxPlanEntity.java
  4. 10
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqWxPlanServiceImpl.java
  5. 30
      modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java
  6. 3
      modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java
  7. 4
      modules/equipment/src/main/java/com/thing/eq/equsergroup/controller/EqUserGroupController.java
  8. 5
      modules/equipment/src/main/java/com/thing/eq/equsergroup/dto/EqUserGroupDTO.java
  9. 44
      modules/equipment/src/main/java/com/thing/eq/equsergroup/entity/EqUserGroupEntity.java
  10. 2
      modules/equipment/src/main/java/com/thing/eq/equsergroup/service/EqUserGroupService.java
  11. 26
      modules/equipment/src/main/java/com/thing/eq/equsergroup/service/impl/EqUserGroupServiceImpl.java
  12. 35
      modules/quartz/src/main/java/com/thing/quartz/timetask/task/ThingStatusTask.java
  13. 2
      modules/report-analysis/src/main/java/com/thing/carbon/xiaochengxu/service/impl/AppletServiceImpl.java
  14. 4
      modules/thing/src/main/java/com/thing/thing/cache/service/CacheInit.java
  15. 3
      modules/thing/src/main/java/com/thing/thing/context/service/ThingManageContextService.java
  16. 4
      modules/thing/src/main/java/com/thing/thing/context/service/impl/ThingManageContextServiceImpl.java
  17. 2
      modules/thing/src/main/java/com/thing/thing/dictRelation/service/impl/IotThingDictRelationServiceImpl.java
  18. 10
      modules/thing/src/main/java/com/thing/thing/entity/controller/IotThingEntityController.java
  19. 4
      modules/thing/src/main/java/com/thing/thing/entity/service/IotThingEntityService.java
  20. 13
      modules/thing/src/main/java/com/thing/thing/entity/service/impl/IotThingEntityServiceImpl.java

2
modules/alarm/src/main/java/com/thing/alarm/alarm/service/impl/AlarmConfigServiceImpl.java

@ -62,7 +62,7 @@ public class AlarmConfigServiceImpl extends BaseServiceImpl<AlarmConfigMapper, A
params.put("name",code);
params.remove("type");
Optional<List<ObjectNode>> optionalList = thingManageContextService.findViewAllEntity(null, null, code, type, UserContext.getRealTenantCode(),
null, null, null, null, TemplateMark.NO.getValue());
null, null, null, null, TemplateMark.NO.getValue(),null);
if(optionalList.isPresent()){
wrapper.in( AlarmConfigEntity::getThingId, optionalList.get().stream().map(
s-> s.get(CacheNameEnum.EntityField.THING_ENTITY_ID.getField()).asLong()

39
modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.thing.common.core.annotation.LogOperation;
import com.thing.common.core.constants.Constant;
import com.thing.common.core.exception.SysException;
import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.utils.excel.ExcelUtils;
import com.thing.common.core.validator.AssertUtils;
import com.thing.common.core.validator.ValidatorUtils;
@ -124,21 +125,23 @@ public class EqWxPlanController {
List<EqWxInfoRes> resultList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(pageData)) {
for (EqWxPlanDTO data : pageData) {
EqWxInfoRes eqWxInfoRes = new EqWxInfoRes();
BeanUtils.copyProperties(data, eqWxInfoRes);
EqWxInfoRes eqWxInfoRes = ConvertUtils.sourceToTarget(data, EqWxInfoRes.class);
//调整
String userId = data.getWxUser();
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(new Long(s));
} List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
for (String s : planUserName) {
name+=s+",";
if(StringUtils.isNotBlank(userId)){
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(Long.parseLong(s));
}
List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
for (String s : planUserName) {
name+=s+",";
}
name = name.substring(0, name.length() - 1);
eqWxInfoRes.setWxUseText(name);
}
name = name.substring(0, name.length() - 1);
eqWxInfoRes.setWxUseText(name);
// 查询设备信息
ThingDTO thingDTO = new ThingDTO();
if (storeThingsMap.containsKey(data.getThingId())) {
@ -153,7 +156,10 @@ public class EqWxPlanController {
if (storeEqBxMap.containsKey(data.getEqBxId())) {
eqWxInfoRes.setBxInfo(storeEqBxMap.get(data.getEqBxId()));
} else {
EqBxEntity eqBxEntity = eqBxService.getById(data.getEqBxId());
EqBxEntity eqBxEntity = null;
if(!Objects.isNull(data.getEqBxId())){
eqBxEntity = eqBxService.getById(data.getEqBxId());
}
if (!Objects.isNull(eqBxEntity)) {
BxInfoDTO bxInfoDTO = new BxInfoDTO();
BeanUtils.copyProperties(eqBxEntity, bxInfoDTO);
@ -163,13 +169,10 @@ public class EqWxPlanController {
storeEqBxMap.put(data.getEqBxId(), null);
}
}
resultList.add(eqWxInfoRes);
}
}
PageData<EqWxInfoRes> page = new PageData<>(resultList, CollectionUtil.isEmpty(resultList) ? 0 : pageList.getTotal());
return new Result<PageData<EqWxInfoRes>>().ok(page);
}
@ -195,7 +198,7 @@ public class EqWxPlanController {
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(new Long(s));
longs.add(Long.parseLong(s));
} List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
for (String s : planUserName) {
@ -355,7 +358,7 @@ public class EqWxPlanController {
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(new Long(s));
longs.add(Long.parseLong(s));
} List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
for (String s : planUserName) {

4
modules/equipment/src/main/java/com/thing/eq/eqbxwx/entity/EqWxPlanEntity.java

@ -2,7 +2,9 @@ package com.thing.eq.eqbxwx.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -26,7 +28,7 @@ public class EqWxPlanEntity implements Serializable {
/**
* id
*/
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id;
/**
* 维修班组

10
modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqWxPlanServiceImpl.java

@ -23,6 +23,7 @@ import com.thing.eq.eqpartrecord.service.EqPartRecordService;
import com.thing.eq.utils.SerialNumberUnit;
import com.thing.sys.biz.entity.SysDictDataEntity;
import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -258,8 +259,13 @@ public class EqWxPlanServiceImpl extends BaseServiceImpl<EqWxPlanMapper, EqWxPla
}
lastNo = SerialNumberUnit.generateNumber("WX", eqWxPlanEntity.getWxNo());
dto.setWxNo(lastNo);
saveDto(dto);
BeanUtils.copyProperties(dto, eqWxPlanEntity);
eqWxPlanEntity.setTenantCode(UserContext.getRealTenantCode());
eqWxPlanEntity.setCreateDate(new Date());
eqWxPlanEntity.setUpdateDate(new Date());
eqWxPlanEntity.setCreator(SecurityUser.getUserId());
save(eqWxPlanEntity);
if (CollectionUtil.isEmpty(replacementDTOS)) {
continue;
}
@ -294,7 +300,6 @@ public class EqWxPlanServiceImpl extends BaseServiceImpl<EqWxPlanMapper, EqWxPla
eqWxReplacementService.saveDto(ConvertUtils.sourceToTarget(replacementDTOS, EqWxReplacementEntity.class));
}
// 重新赋值备件的各个使用总数
if ("2".equals(dto.getWxStatus()) && CollectionUtil.isNotEmpty(replacementDTOS)) {
List<ReplaceMentUseDTO> replaceMentUseDTOList = new ArrayList<>();
@ -307,7 +312,6 @@ public class EqWxPlanServiceImpl extends BaseServiceImpl<EqWxPlanMapper, EqWxPla
replaceMentUseDTOList.add(replaceMentUseDTO);
}
updateStock(replaceMentUseDTOList);
}
}

30
modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java

@ -1,11 +1,11 @@
package com.thing.eq.eqby.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import com.thing.common.orm.entity.BaseDateEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.io.Serial;
/**
* 部件使用记录
@ -16,34 +16,16 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper=false)
@Table("eq_by_plan_part")
public class EqByPlanPartEntity {
public class EqByPlanPartEntity extends BaseDateEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id
private Long id;
/**
* 更换数量
*/
private String useCount;
/**
* 创建人
*/
private Long creator;
/**
* 创建时间
*/
private Date createDate;
/**
* 更新人
*/
private Long updater;
/**
* 更新时间
*/
private Date updateDate;
/**
* 设备保养计划id
*/

3
modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java

@ -30,6 +30,7 @@ import com.thing.sys.biz.service.SysDictDataService;
import com.thing.sys.biz.service.SysDictTypeService;
import com.thing.sys.biz.service.SysUserService;
import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -142,7 +143,7 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla
dto.setByStatus("0");
dto.setPlanStatus("0");
dto.setIsRemind("0");
dto.setTenantCode(SecurityUser.getTenantCode());
dto.setTenantCode(UserContext.getRealTenantCode());
// 第一个单号用lastNo
if (Objects.isNull(eqByPlanEntity)) {
eqByPlanEntity = new EqByPlanEntity();

4
modules/equipment/src/main/java/com/thing/eq/equsergroup/controller/EqUserGroupController.java

@ -104,9 +104,7 @@ public class EqUserGroupController {
throw new SysException("用户组名称不可重复");
}
}
eqUserGroupService.saveDto(dto);
eqUserGroupService.save(dto);
return new Result();
}

5
modules/equipment/src/main/java/com/thing/eq/equsergroup/dto/EqUserGroupDTO.java

@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户组
@ -26,11 +25,11 @@ public class EqUserGroupDTO implements Serializable {
@Schema(description = "创建人")
private Long creator;
@Schema(description = "创建时间")
private Date createDate;
private Long createDate;
@Schema(description = "更新人")
private Long updater;
@Schema(description = "更新时间")
private Date updateDate;
private Long updateDate;
@Schema(description = "部门id")
private Long deptId;
@Schema(description = "租户code")

44
modules/equipment/src/main/java/com/thing/eq/equsergroup/entity/EqUserGroupEntity.java

@ -3,9 +3,12 @@ package com.thing.eq.equsergroup.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import com.thing.common.orm.entity.BaseDateEntity;
import com.thing.common.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.Date;
/**
@ -17,14 +20,12 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper=false)
@Table("eq_user_group")
public class EqUserGroupEntity {
public class EqUserGroupEntity extends BaseDateEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id
private Long id;
/**
* usrid,多个隔开
*/
@ -33,34 +34,19 @@ public class EqUserGroupEntity {
* 用户组名
*/
private String name;
/**
* 创建人
*/
private Long creator;
/**
* 创建时间
*/
private Date createDate;
/**
* 更新人
*/
private Long updater;
/**
* 更新时间
*/
private Date updateDate;
/**
* 部门id
*/
* 部门id
*/
private Long deptId;
/**
* 租户code
*/
* 租户code
*/
private Long tenantCode;
}

2
modules/equipment/src/main/java/com/thing/eq/equsergroup/service/EqUserGroupService.java

@ -19,6 +19,8 @@ import java.util.Map;
*/
public interface EqUserGroupService extends IBaseService<EqUserGroupEntity> {
void save(EqUserGroupDTO dto);
EqUserGroupDTO getById(Long id);
List<EqUserGroupDTO> getList(Map<String, Object> params);

26
modules/equipment/src/main/java/com/thing/eq/equsergroup/service/impl/EqUserGroupServiceImpl.java

@ -1,7 +1,9 @@
package com.thing.eq.equsergroup.service.impl;
import cn.hutool.core.map.MapUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.eq.equsergroup.dto.EqUserGroupDTO;
@ -38,15 +40,15 @@ public class EqUserGroupServiceImpl extends BaseServiceImpl<EqUserGroupMapper, E
@Override
public PageData<EqUserGroupDTO> page(Map<String, Object> params) {
Page<EqUserGroupEntity> page = getPage(params);
params.put("tenantCode", TenantContext.getTenantCode(SecurityUser.getUser()));
List<EqUserGroupDTO> eqUserGroupDTOs = mapper.getListData(params);
for (EqUserGroupDTO eqUserGroupDTO : eqUserGroupDTOs) {
Integer page = MapUtil.getInt(params, "page", 1);
Integer limit = MapUtil.getInt(params, "limit", 10);
Page<EqUserGroupDTO> pageList = mapper.paginateAs(page, limit, getWrapper(params),EqUserGroupDTO.class);
for (EqUserGroupDTO eqUserGroupDTO : pageList.getRecords()) {
String userId = eqUserGroupDTO.getUserId();
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(new Long(s));
longs.add(Long.parseLong(s));
}
List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
@ -56,7 +58,15 @@ public class EqUserGroupServiceImpl extends BaseServiceImpl<EqUserGroupMapper, E
name = name.substring(0, name.length() - 1);
eqUserGroupDTO.setUserIdStr(name);
}
return new PageData<>(eqUserGroupDTOs, eqUserGroupDTOs.size());
return new PageData<>(pageList.getRecords(), pageList.getTotalRow());
}
@Override
public void save(EqUserGroupDTO dto) {
EqUserGroupEntity eqUserGroupEntity = ConvertUtils.sourceToTarget(dto, EqUserGroupEntity.class);
eqUserGroupEntity.setTenantCode(TenantContext.getTenantCode(SecurityUser.getUser()));
eqUserGroupEntity.setDeptId(TenantContext.getCompanyId(SecurityUser.getUser()));
mapper.insert(eqUserGroupEntity);
}
@Override
@ -67,7 +77,7 @@ public class EqUserGroupServiceImpl extends BaseServiceImpl<EqUserGroupMapper, E
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(new Long(s));
longs.add(Long.parseLong(s));
}
List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
@ -88,7 +98,7 @@ public class EqUserGroupServiceImpl extends BaseServiceImpl<EqUserGroupMapper, E
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(new Long(s));
longs.add(Long.parseLong(s));
}
List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";

35
modules/quartz/src/main/java/com/thing/quartz/timetask/task/ThingStatusTask.java

@ -12,6 +12,7 @@ import com.thing.thing.context.service.ThingManageContextService;
import com.thing.thing.model.dto.IotThingModelDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@ -49,7 +50,7 @@ public class ThingStatusTask implements ITask {
@Override
public void run(String params) {
log.info("设备在线离线 statusTask start");
//所有物
//所有物模型
Optional<List<ObjectNode>> optionalList = thingManageContextService.findModelByGateway(GateWayStatus.NO_GATE_WAY.getValue());
if(optionalList.isEmpty()) {
return;
@ -60,29 +61,41 @@ public class ThingStatusTask implements ITask {
//处理
List<IotThingModelDTO> statusList = optionalList.get().stream()
.map(item -> {
IotThingModelDTO iotThingModelDTO = JacksonUtil.convertValue(item, IotThingModelDTO.class);
// IotThingModelDTO iotThingModelDTO = JacksonUtil.convertValue(item, IotThingModelDTO.class);
//找到最大时间的属性
Optional<TsKvDTO> optionalMax = lastTsKvList.stream()
.filter(tsKvDTO -> StringUtils.equals(tsKvDTO.getThingCode(),item.get(CacheNameEnum.ModelField.THING_MODEL_CODE.getField()).asText()))
.max(Comparator.comparing(TsKvDTO::getTs));
if(optionalMax.isEmpty()){
iotThingModelDTO.setStatus(ThingStatus.OFFLINE.getCode());
// item.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(),ThingStatus.OFFLINE.getCode());
item.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(),ThingStatus.OFFLINE.getCode());
}else{
TsKvDTO tsKvDTO = optionalMax.get();
//根据当前时间和获取的最新时间 若大于45min 则离线 否则为在线
boolean isOffline = System.currentTimeMillis() - tsKvDTO.getTs() > TIME_INTERVAL;
iotThingModelDTO.setStatus(isOffline ? ThingStatus.OFFLINE.getCode() : ThingStatus.ONLINE.getCode());
iotThingModelDTO.setStatusTs(new Date(tsKvDTO.getTs()).getTime());
// item.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(),isOffline ? ThingStatus.OFFLINE.getCode() : ThingStatus.ONLINE.getCode());
// item.put(CacheNameEnum.ModelField.THING_MODEL_STATUS_TS.getField(),new Date(tsKvDTO.getTs()).getTime());
item.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(),isOffline ? ThingStatus.OFFLINE.getCode() : ThingStatus.ONLINE.getCode());
item.put(CacheNameEnum.ModelField.THING_MODEL_STATUS_TS.getField(),new Date(tsKvDTO.getTs()).getTime());
//更新实体设备状态
List<ObjectNode> entityNodes = cache.findKeyMap(CacheNameEnum.THING_ENTITY, item.get(CacheNameEnum.ModelField.THING_MODEL_CODE.getField()).asText());
if(CollectionUtils.isNotEmpty(entityNodes)){
for (ObjectNode entityNode : entityNodes) {
entityNode.put(CacheNameEnum.EntityField.THING_ENTITY_STATUS.getField()
,isOffline ? ThingStatus.OFFLINE.getCode() : ThingStatus.ONLINE.getCode());
cache.updateKeyMap(CacheNameEnum.THING_ENTITY
,entityNode.get(CacheNameEnum.EntityField.THING_ENTITY_TENANT_CODE.getField()).asText()
+ ":" + entityNode.get(CacheNameEnum.EntityField.THING_ENTITY_CODE.getField()).asText()
+ ":" + entityNode.get(CacheNameEnum.EntityField.THING_ENTITY_ID.getField()).asText(),entityNode);
}
}
}
return iotThingModelDTO;
//更新物模型
cache.updateKeyMap(CacheNameEnum.THING_MODEL
, item.get(CacheNameEnum.ModelField.THING_MODEL_CODE.getField()).asText()
+ ":" + item.get(CacheNameEnum.ModelField.THING_MODEL_ID.getField()).asText(),item);
return JacksonUtil.convertValue(item, IotThingModelDTO.class);
}).collect(Collectors.toList());
//修改状态
thingManageContextService.saveModelBatch(statusList);
cache.clearTopic(CacheNameEnum.THING_MODEL);
cache.clearTopic(CacheNameEnum.THING_ENTITY);
log.info("设备在线离线 statusTask end");
}

2
modules/report-analysis/src/main/java/com/thing/carbon/xiaochengxu/service/impl/AppletServiceImpl.java

@ -54,7 +54,7 @@ public class AppletServiceImpl implements AppletService {
thingParams.put("tenantCode", tenantCode);
thingParams.put("companyId", companyId);
thingParams.put("enableStatus", "1");
Optional<List<ObjectNode>> optionalList = thingManageContextService.findViewAllEntity(null, null, null, null, tenantCode, null, null, null, "1", TemplateMark.NO.getValue());
Optional<List<ObjectNode>> optionalList = thingManageContextService.findViewAllEntity(null, null, null, null, tenantCode, null, null, null, "1", TemplateMark.NO.getValue(),null);
long online = optionalList.orElseGet(Collections::emptyList).stream().filter(item -> ThingStatus.ONLINE.getCode().equals(item.get(CacheNameEnum.EntityField.THING_ENTITY_STATUS.getField()).asText())).count();
long offline = optionalList.orElseGet(Collections::emptyList).stream().filter(item -> ThingStatus.OFFLINE.getCode().equals(item.get(CacheNameEnum.EntityField.THING_ENTITY_STATUS.getField()).asText())).count();
result.setOnlineCount((int) online);

4
modules/thing/src/main/java/com/thing/thing/cache/service/CacheInit.java

@ -52,7 +52,7 @@ public class CacheInit {
//物模型的初始化
cacheModel();
//定时打印缓存
notificationsConsumerExecutor.scheduleAtFixedRate(thingCache::printStats, 0, 5, TimeUnit.MINUTES);
notificationsConsumerExecutor.scheduleAtFixedRate(thingCache::printStats, 0, 3, TimeUnit.SECONDS);
log.info("thing 【物模型:物实体:物指标】 cache init end");
}
@ -65,7 +65,7 @@ public class CacheInit {
private void cacheEntity() {
entityService.findList(CacheNameEnum.EntityField.THING_ENTITY_CREATE_DATE.getField(), Constant.DESC, null,null, null,
null, null, null, null, null);
null, null, null, null, null,null);
cacheDictRelation();
cacheRelation();
cacheRelationDetail();

3
modules/thing/src/main/java/com/thing/thing/context/service/ThingManageContextService.java

@ -57,7 +57,8 @@ public interface ThingManageContextService {
Optional<List<IotThingEntityDTO>> findEntityAllByCodeAndTenantCode(Collection<String> codes,Long tenantCode,boolean isEntity);
Optional<List<ObjectNode>> findViewAllEntity(String orderField,String order,
String name,String type,Long tenantCode,Long deptId,String realType,String tags,String enableStatus,String templateMark);
String name,String type,Long tenantCode,Long deptId,String realType,String tags
,String enableStatus,String templateMark,String status);
Optional<IotThingViewDTO> findViewEntityById(Long id);

4
modules/thing/src/main/java/com/thing/thing/context/service/impl/ThingManageContextServiceImpl.java

@ -100,8 +100,8 @@ public class ThingManageContextServiceImpl implements ThingManageContextService
@Override
public Optional<List<ObjectNode>> findViewAllEntity(String orderField,String order,
String name,String type,Long tenantCode,Long deptId,String realType,String tags,String enableStatus,String templateMark) {
return Optional.ofNullable(entityService.findList(orderField,order,name,type,tenantCode,deptId,realType,tags,enableStatus,templateMark));
String name,String type,Long tenantCode,Long deptId,String realType,String tags,String enableStatus,String templateMark,String status) {
return Optional.ofNullable(entityService.findList(orderField,order,name,type,tenantCode,deptId,realType,tags,enableStatus,templateMark,status));
}
@Override

2
modules/thing/src/main/java/com/thing/thing/dictRelation/service/impl/IotThingDictRelationServiceImpl.java

@ -169,7 +169,7 @@ public class IotThingDictRelationServiceImpl extends BaseServiceImpl<IotThingDic
CacheInit.dictRelationMap(dictRelationList,cache);
}
if(StringUtils.isBlank(entityIds)){
List<ObjectNode> entityServiceList = thingEntityService.findList(null, null, null, null, tenantCode, null, null, null, null, templateMark);
List<ObjectNode> entityServiceList = thingEntityService.findList(null, null, null, null, tenantCode, null, null, null, null, templateMark,null);
entityIds = entityServiceList.stream().map(jsonObject -> jsonObject.get(CacheNameEnum.EntityField.THING_ENTITY_ID.getField()).asText()).collect(Collectors.joining(","));
}
if(StringUtils.isBlank(orderField)){

10
modules/thing/src/main/java/com/thing/thing/entity/controller/IotThingEntityController.java

@ -63,9 +63,10 @@ public class IotThingEntityController {
@Parameter(name = "realType", description = "真实/虚拟物") @RequestParam(required = false) String realType,
@Parameter(name = "tags", description = "真实/虚拟物") @RequestParam(required = false) String tags,
@Parameter(name = "enableStatus", description = "停用开启")@RequestParam(required = false) String enableStatus,
@Parameter(name = "templateMark", description = "是否是物实体/模板")@RequestParam(required = false) String templateMark)
@Parameter(name = "templateMark", description = "是否是物实体/模板")@RequestParam(required = false) String templateMark,
@Parameter(name = "status", description = "在线离线状态,0离线 1在线 2错误 3未接入") @RequestParam(required = false) String status)
{
PageData<ObjectNode> pageList = service.pageList(page,limit,orderField,order, name,type,deptId,realType,tags,enableStatus,templateMark);
PageData<ObjectNode> pageList = service.pageList(page,limit,orderField,order, name,type,deptId,realType,tags,enableStatus,templateMark,status);
return new Result<PageData<ObjectNode>>().ok(pageList);
}
@ -80,9 +81,10 @@ public class IotThingEntityController {
@Parameter(name = "realType", description = "真实/虚拟物") @RequestParam(required = false) String realType,
@Parameter(name = "tags", description = "真实/虚拟物") @RequestParam(required = false) String tags,
@Parameter(name = "enableStatus", description = "停用开启")@RequestParam(required = false) String enableStatus,
@Parameter(name = "enableStatus", description = "是否是物实体/模板")@RequestParam(required = false) String templateMark)
@Parameter(name = "enableStatus", description = "是否是物实体/模板")@RequestParam(required = false) String templateMark,
@Parameter(name = "status", description = "在线离线状态,0离线 1在线 2错误 3未接入") @RequestParam(required = false) String status)
{
List<ObjectNode> list = service.findList(orderField,order,name,type, UserContext.getRealTenantCode(),deptId,realType,tags,enableStatus,templateMark);
List<ObjectNode> list = service.findList(orderField,order,name,type, UserContext.getRealTenantCode(),deptId,realType,tags,enableStatus,templateMark,status);
return new Result<List<ObjectNode>>().ok(list);
}

4
modules/thing/src/main/java/com/thing/thing/entity/service/IotThingEntityService.java

@ -29,10 +29,10 @@ import java.util.Optional;
public interface IotThingEntityService extends IBaseService<IotThingEntity> {
PageData<ObjectNode> pageList(Integer page,Integer limit,String orderField,String order,
String code,String type,Long deptId,String realType,String tags,String enableStatus,String templateMark);
String code,String type,Long deptId,String realType,String tags,String enableStatus,String templateMark,String status);
List<ObjectNode> findList(String orderField,String order,
String name,String type,Long tenantCode,Long deptId,String realType,String tags,String enableStatus,String templateMark);
String name,String type,Long tenantCode,Long deptId,String realType,String tags,String enableStatus,String templateMark,String status);
List<IotThingViewDTO> findAll(Map<String, Object> params);

13
modules/thing/src/main/java/com/thing/thing/entity/service/impl/IotThingEntityServiceImpl.java

@ -240,8 +240,8 @@ public class IotThingEntityServiceImpl extends BaseServiceImpl<IotThingEntityMap
String realType,
String tags,
String enableStatus,
String templateMark) {
List<ObjectNode> list = findList(orderField, order, name, type, UserContext.getRealTenantCode(),deptId, realType, tags,enableStatus, templateMark);
String templateMark,String status) {
List<ObjectNode> list = findList(orderField, order, name, type, UserContext.getRealTenantCode(),deptId, realType, tags,enableStatus, templateMark, status);
if (CollectionUtils.isEmpty(list)) {
return PageData.empty();
}
@ -259,7 +259,7 @@ public class IotThingEntityServiceImpl extends BaseServiceImpl<IotThingEntityMap
String realType,
String tags,
String enableStatus,
String templateMark) {
String templateMark,String status) {
List<ObjectNode> thingList = cache.getTopicMap(CacheNameEnum.THING_ENTITY);
if(CollectionUtils.isEmpty(thingList)){
List<IotThingViewDTO> iotThingViewDTOS = mapper.selectListByQueryAs(getWrapper(orderField,order, null, null,null,null,
@ -277,7 +277,7 @@ public class IotThingEntityServiceImpl extends BaseServiceImpl<IotThingEntityMap
}
//封装参数
List<Pair<String, String>> pairs = buildParam(type,tenantCode,
deptId,realType,tags,enableStatus,templateMark);
deptId,realType,tags,enableStatus,templateMark,status);
String finalOrderField = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, orderField);
Comparator<ObjectNode> comparator = CompareUtils.getComparator(order, finalOrderField);
return thingList.stream().filter(jsonObject -> JacksonUtil.filter(jsonObject, pairs))
@ -932,7 +932,7 @@ public class IotThingEntityServiceImpl extends BaseServiceImpl<IotThingEntityMap
String realType,
String tags,
String enableStatus,
String templateMark)
String templateMark,String status)
{
List<Pair<String, String>> filterList = new ArrayList<>();
/* if (StringUtils.isNotBlank(code)) {
@ -962,6 +962,9 @@ public class IotThingEntityServiceImpl extends BaseServiceImpl<IotThingEntityMap
if (StringUtils.isNotBlank(templateMark)) {
filterList.add(Pair.of(CacheNameEnum.EntityField.THING_ENTITY_TEMPLATE_MARK.getField(), templateMark));
}
if (StringUtils.isNotBlank(status)) {
filterList.add(Pair.of(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status));
}
return filterList;
}

Loading…
Cancel
Save