Browse Source

Merge pull request 'master' (#20) from master into V3

Reviewed-on: http://git.lrdaiot.cn:9000/thing/thing_api/pulls/20
qingyuan_dev_new
李帅 1 year ago
parent
commit
4cb328d7bb
  1. 2
      modules/alarm/src/main/java/com/thing/alarm/alarm/controller/AlarmDisposeLogController.java
  2. 16
      modules/alarm/src/main/java/com/thing/alarm/alarm/service/impl/AlarmDisposeLogServiceImpl.java
  3. 6
      modules/carbon-public/src/main/java/com/thing/carbon/pub/mapper/CarbonPubMaterialFactorMapper.java
  4. 2
      modules/carbon-public/src/main/java/com/thing/carbon/pub/mapper/CarbonPubProductionReportMapper.java
  5. 23
      modules/carbon-public/src/main/java/com/thing/carbon/pub/service/impl/PubCockpitServiceImpl.java
  6. 9
      modules/carbon-public/src/main/resources/mapper/CarbonPubProductionReportMapper.xml
  7. 6
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/dto/CqcCarbonReportCountInfo.java
  8. 8
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/service/impl/CqcCarbonReportServiceImpl.java
  9. 1
      modules/filter-rule/src/main/java/com/thing/filter/rule/controller/FilterLogController.java
  10. 2
      modules/filter-rule/src/main/java/com/thing/filter/rule/service/impl/FilterLogServiceImpl.java
  11. 32
      modules/thing/src/main/java/com/thing/device/analysisdata/controller/AnalysisDataController.java
  12. 2
      modules/thing/src/main/java/com/thing/device/analysisdata/service/impl/AnalysisDataServiceImpl.java
  13. 3
      modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java
  14. 4
      modules/thing/src/main/java/com/thing/thing/api/service/impl/IotThingApiServiceImpl.java
  15. 2
      modules/thing/src/main/java/com/thing/thing/relation/detail/dto/IotThingRelationDetailDTO.java
  16. 12
      modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java
  17. 5
      modules/thing/src/main/resources/mapper/device/IotThingSourceMapper.xml

2
modules/alarm/src/main/java/com/thing/alarm/alarm/controller/AlarmDisposeLogController.java

@ -77,9 +77,7 @@ public class AlarmDisposeLogController {
public Result save(@RequestBody AlarmDisposeLogDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
alarmDisposeLogService.addAlarmDisposeLog(dto);
return new Result();
}

16
modules/alarm/src/main/java/com/thing/alarm/alarm/service/impl/AlarmDisposeLogServiceImpl.java

@ -63,8 +63,10 @@ public class AlarmDisposeLogServiceImpl extends BaseServiceImpl<AlarmDisposeLogM
@Transactional(rollbackFor = SysException.class)
public void addAlarmDisposeLog(AlarmDisposeLogDTO dto) {
convertUrl(dto);
saveDto(dto);
Long ruleId = alarmRuleLogService.updateStatus(dto.getAlarmLogId(), dto.getStatus(), dto.getCreator(), dto.getCreateDate());
// saveDto(dto);
AlarmDisposeLogEntity alarmDisposeLogEntity = ConvertUtils.sourceToTarget(dto, AlarmDisposeLogEntity.class);
mapper.insert(alarmDisposeLogEntity);
Long ruleId = alarmRuleLogService.updateStatus(alarmDisposeLogEntity.getAlarmLogId(), alarmDisposeLogEntity.getStatus(), alarmDisposeLogEntity.getCreator(), alarmDisposeLogEntity.getCreateDate());
// 处理完成更新状态
if (StringUtils.equals(dto.getStatus(), AlarmStatus.PROCESSED.getStatus())) {
alarmRuleService.completed(ruleId);
@ -75,8 +77,14 @@ public class AlarmDisposeLogServiceImpl extends BaseServiceImpl<AlarmDisposeLogM
@Transactional(rollbackFor = SysException.class)
public void updateAlarmDisposeLog(AlarmDisposeLogDTO dto) {
convertUrl(dto);
updateDto(dto);
Long ruleId = alarmRuleLogService.updateStatus(dto.getAlarmLogId(), dto.getStatus(), dto.getUpdater(), dto.getUpdateDate());
AlarmDisposeLogEntity alarmDisposeLogEntity = mapper.selectOneById(dto.getId());
alarmDisposeLogEntity.setAlarmLogId(dto.getAlarmLogId());
alarmDisposeLogEntity.setDisposeResult(dto.getDisposeResult());
alarmDisposeLogEntity.setDescribe(dto.getDescribe());
alarmDisposeLogEntity.setStatus(dto.getStatus());
alarmDisposeLogEntity.setImages(dto.getImages());
mapper.update(alarmDisposeLogEntity);
Long ruleId = alarmRuleLogService.updateStatus(alarmDisposeLogEntity.getAlarmLogId(), alarmDisposeLogEntity.getStatus(), alarmDisposeLogEntity.getUpdater(), alarmDisposeLogEntity.getUpdateDate());
// 处理完成更新状态
if (StringUtils.equals(dto.getStatus(), AlarmStatus.PROCESSED.getStatus())) {
alarmRuleService.completed(ruleId);

6
modules/carbon-public/src/main/java/com/thing/carbon/pub/mapper/CarbonPubMaterialFactorMapper.java

@ -3,6 +3,7 @@ package com.thing.carbon.pub.mapper;
import com.thing.carbon.pub.entity.CarbonPubMaterialFactorEntity;
import com.thing.common.orm.mapper.PowerBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/**
* 碳排因子库
@ -12,5 +13,8 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CarbonPubMaterialFactorMapper extends PowerBaseMapper<CarbonPubMaterialFactorEntity> {
@Select("SELECT sum(hot_score) FROM carbon_pub_material_factor")
Long selectCarbonLibCount();
}

2
modules/carbon-public/src/main/java/com/thing/carbon/pub/mapper/CarbonPubProductionReportMapper.java

@ -18,4 +18,6 @@ import java.util.List;
public interface CarbonPubProductionReportMapper extends PowerBaseMapper<CarbonPubProductionReportEntity> {
List<CarbonPubProductionModelEntity> getAllModels(@Param("tenantCode") Long tenantCode);
Long selectProductsCount();
}

23
modules/carbon-public/src/main/java/com/thing/carbon/pub/service/impl/PubCockpitServiceImpl.java

@ -3,10 +3,7 @@ package com.thing.carbon.pub.service.impl;
import com.mybatisflex.core.query.QueryWrapper;
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo;
import com.thing.carbon.pub.dto.CockpitStatisticsDto;
import com.thing.carbon.pub.mapper.CarbonPubProductionModelMapper;
import com.thing.carbon.pub.mapper.CarbonPubProductionReportMapper;
import com.thing.carbon.pub.mapper.CarbonPubSupplierMapper;
import com.thing.carbon.pub.mapper.PubCockpitMapper;
import com.thing.carbon.pub.mapper.*;
import com.thing.carbon.pub.service.PubCockpitService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,6 +30,12 @@ public class PubCockpitServiceImpl implements PubCockpitService {
@Autowired
private CarbonPubProductionReportMapper carbonPubProductionReportMapper;
@Autowired
private CarbonPubMaterialFactorMapper carbonPubMaterialFactorMapper;
@Autowired
private CarbonPubProductionResultMapper carbonPubProductionResultMapper;
@Override
public List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList() {
@ -63,18 +66,20 @@ public class PubCockpitServiceImpl implements PubCockpitService {
Long processCount = carbonPubProductionModelMapper.selectCountByQuery(QueryWrapper.create());
dto.setProcessCount(processCount);
Long productsCount = carbonPubProductionReportMapper.selectCountByQuery(QueryWrapper.create().select());
//服务产品数
Long productsCount = carbonPubProductionReportMapper.selectProductsCount();
dto.setProductsCount(productsCount);
Long carbonReportCount = carbonPubProductionReportMapper.selectCountByQuery(QueryWrapper.create());
dto.setCarbonReportCount(carbonReportCount);
Long carbonLibCount = carbonPubMaterialFactorMapper.selectCarbonLibCount();
dto.setCarbonLibCount(carbonLibCount);
Long carbonCount = carbonPubProductionResultMapper.selectCountByQuery(QueryWrapper.create());
dto.setCarbonCount(carbonCount);
return null;
return dto;
}
}

9
modules/carbon-public/src/main/resources/mapper/CarbonPubProductionReportMapper.xml

@ -15,4 +15,13 @@
</if>
</where>
</select>
<select id="selectProductsCount" resultType="Long">
SELECT "count"(1) FROM (
SELECT product_id FROM carbon_pub_production_report GROUP BY product_id
) as a
</select>
</mapper>

6
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/dto/CqcCarbonReportCountInfo.java

@ -9,11 +9,11 @@ public class CqcCarbonReportCountInfo {
@Schema(description = "待提交")
private Long pendingSubmitted;
private Long pendingSubmitted = 0L;
@Schema(description = "待发证")
private Long pendingCertification;
private Long pendingCertification = 0L;
@Schema(description = "已发证")
private Long issued;
private Long issued = 0L;

8
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/service/impl/CqcCarbonReportServiceImpl.java

@ -106,10 +106,10 @@ public class CqcCarbonReportServiceImpl extends BaseServiceImpl<CqcCarbonReportM
JSONObject object = JSONObject.parseObject(reqResult);
if(ObjectUtils.isNotEmpty(object)){
Integer code = object.getInteger("code");
String data = object.getString("data");
String msg = object.getString("msg");
result.setCode(code);
Integer code = object.getInteger("status");
String data = object.getString("message");
String msg = object.getString("message");
result.setCode(code==200?0:-1);
result.setData(data);
result.setMsg(msg);
}

1
modules/filter-rule/src/main/java/com/thing/filter/rule/controller/FilterLogController.java

@ -42,6 +42,7 @@ public class FilterLogController {
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"),
@Parameter(name = "filterRuleName", description = "过滤规则名称"),
@Parameter(name = "status", description = "状态:1-未匹配,2-已匹配,3-计算成功,4-计算异常,5-已通知"),
@Parameter(name = "result", description = "过滤结果:true | false"),
})
public Result<PageData<FilterLogDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
PageData<FilterLogDTO> page = filterLogService.handlePage(params);

2
modules/filter-rule/src/main/java/com/thing/filter/rule/service/impl/FilterLogServiceImpl.java

@ -38,6 +38,7 @@ public class FilterLogServiceImpl extends BaseServiceImpl<FilterLogMapper, Filte
public QueryWrapper getWrapper(Map<String, Object> params) {
String filterRuleName = MapUtils.getString(params, "filterRuleName");
Integer status = MapUtils.getInteger(params, "status");
Boolean result = MapUtils.getBoolean(params, "result");
return QueryWrapper.create()
.select(
FILTER_RULE_ENTITY.NAME.as("filter_rule_name"),
@ -48,6 +49,7 @@ public class FilterLogServiceImpl extends BaseServiceImpl<FilterLogMapper, Filte
.eq(FilterRuleEntity::getTenantCode, UserContext.getTenantCode())
.eq(FilterRuleEntity::getName, filterRuleName, StringUtils.isNotBlank(filterRuleName))
.eq(FilterLogEntity::getStatus, status, Objects.nonNull(status))
.eq(FilterLogEntity::getResult, result, Objects.nonNull(result))
.orderBy(FilterLogEntity::getCreateDate)
.desc();
}

32
modules/thing/src/main/java/com/thing/device/analysisdata/controller/AnalysisDataController.java

@ -71,43 +71,25 @@ public class AnalysisDataController {
analysisDataRespMap.put("min",null);
analysisDataRespMap.put("average",null);
List<Map<String,Object>> list = MapUtil.get(analysisDataRespMap, "result", List.class);
List<TsKvDTO> list = MapUtil.get(analysisDataRespMap, "result", List.class);
if (CollectionUtil.isNotEmpty(list)){
DecimalFormat decimalFormat = new DecimalFormat("#.##");
// 计算最大值
OptionalDouble maxVal = list.stream()
.filter(m -> m.get("val") != null) // 过滤掉 "val" 为空的元素
.mapToDouble(m -> {
if(m.get("val") instanceof Number){
return ((Number)m.get("val")).doubleValue();
}else{
return Double.parseDouble(m.get("val").toString());
}
}).max();
.filter(m -> m.getVal() != null) // 过滤掉 "val" 为空的元素
.mapToDouble(m -> Double.parseDouble(m.getVal())).max();
String formattedMax = decimalFormat.format(maxVal.getAsDouble());
analysisDataRespMap.put("max",formattedMax);
// 计算最小值
OptionalDouble minVal = list.stream()
.filter(m -> m.get("val") != null) // 过滤掉 "val" 为空的元素
.mapToDouble(m -> {
if(m.get("val") instanceof Number){
return ((Number)m.get("val")).doubleValue();
}else{
return Double.parseDouble(m.get("val").toString());
}
}).min();
.filter(m -> m.getVal() != null) // 过滤掉 "val" 为空的元素
.mapToDouble(m -> Double.parseDouble(m.getVal())).min();
String formattedMin = decimalFormat.format(minVal.getAsDouble());
analysisDataRespMap.put("min",formattedMin);
// 计算平均值
Double averageVal = list.stream()
.filter(m -> m.get("val") != null) // 过滤掉 "val" 为空的元素
.mapToDouble(m -> {
if(m.get("val") instanceof Number){
return ((Number)m.get("val")).doubleValue();
}else{
return Double.parseDouble(m.get("val").toString());
}
}).average().orElse(0D);
.filter(m -> m.getVal() != null) // 过滤掉 "val" 为空的元素
.mapToDouble(m -> Double.parseDouble(m.getVal())).average().orElse(0D);
String formattedAverage = decimalFormat.format(averageVal);
analysisDataRespMap.put("average",formattedAverage);

2
modules/thing/src/main/java/com/thing/device/analysisdata/service/impl/AnalysisDataServiceImpl.java

@ -831,7 +831,7 @@ public class AnalysisDataServiceImpl implements AnalysisDataService {
* @return list
*/
private List<TsKvDTO> getCacheTsKvDTO(AnalysisDataReqDTO analysisDataReqDTO, List<IotThingSourcePidDTO> iotThingSourceList, List<IotThingSourcePidDTO> childList) {
List<ThingAttrDTO> thingAttrList = iotThingSourceList.parallelStream()
List<ThingAttrDTO> thingAttrList = iotThingSourceList.stream()
.filter(item -> childList.stream().noneMatch(child -> Objects.equals(child.getPid(), item.getId())))
.map(item -> new ThingAttrDTO(item.getThingTenantId(), item.getThingCode(), Lists.newArrayList(item.getThingAttrCode())))
.collect(Collectors.toList());

3
modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java

@ -480,7 +480,8 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap
return null;
}
List<IotThingSourceAttrRespDTO> iotThingSourceAttrList = ConvertUtils.sourceToTarget(iotThingSourceList, IotThingSourceAttrRespDTO.class);
return iotThingSourceAttrList.stream().filter(distinctByKey(IotThingSourceAttrRespDTO::getThingAttrCode)).sorted(Comparator.comparing(IotThingSourceAttrRespDTO::getSort)).collect(Collectors.toList());
return iotThingSourceAttrList.stream().filter(distinctByKey(IotThingSourceAttrRespDTO::getThingAttrCode)).sorted(Comparator.comparing(IotThingSourceAttrRespDTO::getSort,
Comparator.nullsLast(Comparator.naturalOrder()))).collect(Collectors.toList());
}
@Override

4
modules/thing/src/main/java/com/thing/thing/api/service/impl/IotThingApiServiceImpl.java

@ -838,9 +838,9 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I
map.put("times", JSON.parseObject(timeCondition));
apiLogDTO.setCallEntity(JSON.toJSONString(map));
apiLogDTO.setCreator(UserContext.getUserId());
apiLogDTO.setCreateDate(DateTimeUtils.getCurrentTime() / 1000);
apiLogDTO.setCreateDate(DateTimeUtils.getCurrentTime());
apiLogDTO.setUpdater(UserContext.getUserId());
apiLogDTO.setUpdateDate(DateTimeUtils.getCurrentTime() / 1000);
apiLogDTO.setUpdateDate(DateTimeUtils.getCurrentTime());
//调用IP
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
apiLogDTO.setIp(IpUtils.getIpAddr(request));

2
modules/thing/src/main/java/com/thing/thing/relation/detail/dto/IotThingRelationDetailDTO.java

@ -54,5 +54,7 @@ public class IotThingRelationDetailDTO implements Serializable {
private Long rootThingId;
@Schema(description = "标签")
private String tag;
@Schema(description = "在线离线状态,0离线 1在线 2错误 3未接入")
private String thingStatus;
}

12
modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java

@ -26,6 +26,7 @@ import com.thing.thing.cache.service.CacheInit;
import com.thing.thing.cache.service.ThingCache;
import com.thing.thing.entity.dto.IotThingEntityDTO;
import com.thing.thing.entity.service.IotThingEntityService;
import com.thing.thing.model.service.IotThingModelService;
import com.thing.thing.relation.detail.dto.IotThingRelationDetailDTO;
import com.thing.thing.relation.detail.dto.RelationDetailBatchSaveDTO;
import com.thing.thing.relation.detail.dto.ThingRelationDTO;
@ -63,6 +64,9 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR
@Resource
private IotThingEntityService thingEntitiesService;
@Resource
private IotThingModelService thingModelService;
@Autowired
private ApplicationEventPublisher eventPublisher;
@ -140,6 +144,14 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR
List<ObjectNode> relationDetaillist = cache.getTopicMap(CacheNameEnum.THING_DETAIL_RELATION);
if (CollectionUtils.isEmpty(relationDetaillist)) {
List<IotThingRelationDetailDTO> list = mapper.selectListByQueryAs(getWrapper(orderField, order, null, null), IotThingRelationDetailDTO.class);
if(CollectionUtils.isNotEmpty(list)){
list.forEach(s->{
String toCode = s.getToCode();
thingModelService.findByCode(toCode).ifPresent(thingModelEntity -> {
s.setThingStatus(thingModelEntity.getStatus());
});
});
}
relationDetaillist = JsonConverter.convertToJsonObjectListObjectNode(list);
if (CollectionUtils.isEmpty(relationDetaillist)) {
return new ArrayList<>();

5
modules/thing/src/main/resources/mapper/device/IotThingSourceMapper.xml

@ -38,7 +38,7 @@
its.thing_attr_code,
its.thing_attr_name,
its.thing_attr_code_type,
its.data_rule,
its.data_deal_config as data_rule,
its.thing_serial,
its.thing_icon,
its.thing_attr_unit,
@ -51,7 +51,8 @@
iot_thing_source its
INNER JOIN iot_thing_entity itt ON its.thing_id = itt.id
<where>
its.pid is null
-- its.pid is null
1=1
<if test="thingIdList != null">
and its.thing_id in
<foreach item="thingId" collection="thingIdList" open="(" separator="," close=")">

Loading…
Cancel
Save