Browse Source

Merge remote-tracking branch 'origin/master'

thing_master
siyang 1 year ago
parent
commit
0c64ce6bd0
  1. 9
      modules/carbon-public/src/main/java/com/thing/carbon/pub/controller/PubCockpitController.java
  2. 16
      modules/carbon-public/src/main/java/com/thing/carbon/pub/dto/CockpitStatisticsDto.java
  3. 3
      modules/carbon-public/src/main/java/com/thing/carbon/pub/service/PubCockpitService.java
  4. 38
      modules/carbon-public/src/main/java/com/thing/carbon/pub/service/impl/PubCockpitServiceImpl.java
  5. 9
      modules/thing/src/main/java/com/thing/thing/api/entity/IotThingApiLogEntity.java
  6. 2
      modules/thing/src/main/java/com/thing/thing/api/service/IotThingApiLogService.java
  7. 5
      modules/thing/src/main/java/com/thing/thing/api/service/impl/IotThingApiServiceImpl.java

9
modules/carbon-public/src/main/java/com/thing/carbon/pub/controller/PubCockpitController.java

@ -2,6 +2,7 @@ package com.thing.carbon.pub.controller;
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo; import com.thing.carbon.pub.dto.CockpitEnterpriseInfo;
import com.thing.carbon.pub.dto.CockpitStatisticsDto;
import com.thing.carbon.pub.service.PubCockpitService; import com.thing.carbon.pub.service.PubCockpitService;
import com.thing.common.core.web.response.Result; import com.thing.common.core.web.response.Result;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -36,13 +37,11 @@ public class PubCockpitController {
return new Result<List<CockpitEnterpriseInfo>>().ok(list); return new Result<List<CockpitEnterpriseInfo>>().ok(list);
} }
@GetMapping("statistics") @GetMapping("statistics")
@Operation(summary="中间六个统计") @Operation(summary="中间六个统计")
public Result<List<CockpitEnterpriseInfo>> statistics(){
List<CockpitEnterpriseInfo> list = pubCockpitService.cockpitEnterpriseInfoList();
return new Result<List<CockpitEnterpriseInfo>>().ok(list);
public Result<CockpitStatisticsDto> statistics(){
CockpitStatisticsDto statisticsDto = pubCockpitService.statistics();
return new Result<CockpitStatisticsDto>().ok(statisticsDto);
} }

16
modules/carbon-public/src/main/java/com/thing/carbon/pub/dto/CockpitStatisticsDto.java

@ -11,10 +11,18 @@ import lombok.Data;
@Schema(description = "国网侧驾驶舱中间六个统计信息") @Schema(description = "国网侧驾驶舱中间六个统计信息")
public class CockpitStatisticsDto { public class CockpitStatisticsDto {
@Schema(description = "服务企业数")
private Long enterprisesCount;
@Schema(description = "服务产品数")
private Long productsCount;
@Schema(description = "工艺模型数")
private Long processCount;
@Schema(description = "碳足迹结果")
private Long carbonReportCount;
@Schema(description = "排放因子库调用次数")
private Long carbonLibCount;
@Schema(description = "累计产品碳足迹背景数据")
private Long carbonCount;
} }

3
modules/carbon-public/src/main/java/com/thing/carbon/pub/service/PubCockpitService.java

@ -1,6 +1,7 @@
package com.thing.carbon.pub.service; package com.thing.carbon.pub.service;
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo; import com.thing.carbon.pub.dto.CockpitEnterpriseInfo;
import com.thing.carbon.pub.dto.CockpitStatisticsDto;
import java.util.List; import java.util.List;
@ -8,4 +9,6 @@ public interface PubCockpitService {
List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList(); List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList();
CockpitStatisticsDto statistics();
} }

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

@ -1,6 +1,10 @@
package com.thing.carbon.pub.service.impl; 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.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.CarbonPubSupplierMapper;
import com.thing.carbon.pub.mapper.PubCockpitMapper; import com.thing.carbon.pub.mapper.PubCockpitMapper;
import com.thing.carbon.pub.service.PubCockpitService; import com.thing.carbon.pub.service.PubCockpitService;
@ -23,6 +27,12 @@ public class PubCockpitServiceImpl implements PubCockpitService {
@Autowired @Autowired
private CarbonPubSupplierMapper carbonPubSupplierMapper; private CarbonPubSupplierMapper carbonPubSupplierMapper;
@Autowired
private CarbonPubProductionModelMapper carbonPubProductionModelMapper;
@Autowired
private CarbonPubProductionReportMapper carbonPubProductionReportMapper;
@Override @Override
public List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList() { public List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList() {
@ -39,4 +49,32 @@ public class PubCockpitServiceImpl implements PubCockpitService {
}); });
return infoList; return infoList;
} }
@Override
public CockpitStatisticsDto statistics() {
CockpitStatisticsDto dto = new CockpitStatisticsDto();
Long enterprisesCount = carbonPubSupplierMapper.selectCountByQuery(QueryWrapper.create());
dto.setEnterprisesCount(enterprisesCount);
Long processCount = carbonPubProductionModelMapper.selectCountByQuery(QueryWrapper.create());
dto.setProcessCount(processCount);
Long productsCount = carbonPubProductionReportMapper.selectCountByQuery(QueryWrapper.create().select());
dto.setProductsCount(productsCount);
Long carbonReportCount = carbonPubProductionReportMapper.selectCountByQuery(QueryWrapper.create());
dto.setCarbonReportCount(carbonReportCount);
return null;
}
} }

9
modules/thing/src/main/java/com/thing/thing/api/entity/IotThingApiLogEntity.java

@ -1,15 +1,12 @@
package com.thing.thing.api.entity; package com.thing.thing.api.entity;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.thing.common.core.validator.group.UpdateGroup;
import com.thing.common.orm.entity.BaseDateEntity; import com.thing.common.orm.entity.BaseDateEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serial; import java.io.Serial;
/** /**
@ -27,9 +24,9 @@ public class IotThingApiLogEntity extends BaseDateEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "主键")
@NotNull(message = "API日志id不能为空",groups = UpdateGroup.class)
private Long id;
// @Schema(description = "主键")
// @NotNull(message = "API日志id不能为空",groups = UpdateGroup.class)
// private Long id;
/** /**
* 调用API的主键 * 调用API的主键

2
modules/thing/src/main/java/com/thing/thing/api/service/IotThingApiLogService.java

@ -3,8 +3,6 @@ package com.thing.thing.api.service;
import com.thing.common.orm.service.IBaseService; import com.thing.common.orm.service.IBaseService;
import com.thing.thing.api.entity.IotThingApiLogEntity; import com.thing.thing.api.entity.IotThingApiLogEntity;
;
/** /**
* 超级api * 超级api
* *

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

@ -29,6 +29,7 @@ import com.thing.sys.security.context.UserContext;
import com.thing.thing.api.controller.IotThingApiController; import com.thing.thing.api.controller.IotThingApiController;
import com.thing.thing.api.dto.*; import com.thing.thing.api.dto.*;
import com.thing.thing.api.entity.IotThingApiEntity; import com.thing.thing.api.entity.IotThingApiEntity;
import com.thing.thing.api.entity.IotThingApiLogEntity;
import com.thing.thing.api.excel.IotThingApiExcel; import com.thing.thing.api.excel.IotThingApiExcel;
import com.thing.thing.api.mapper.IotThingApiMapper; import com.thing.thing.api.mapper.IotThingApiMapper;
import com.thing.thing.api.service.IotThingApiLogService; import com.thing.thing.api.service.IotThingApiLogService;
@ -823,7 +824,7 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I
private void apiLog(IotThingApiEntity apiEntity, String caller) { private void apiLog(IotThingApiEntity apiEntity, String caller) {
try { try {
IotThingApiLogDTO apiLogDTO = new IotThingApiLogDTO();
IotThingApiLogEntity apiLogDTO = new IotThingApiLogEntity();
apiLogDTO.setApiId(apiEntity.getId()); apiLogDTO.setApiId(apiEntity.getId());
apiLogDTO.setCaller(caller); apiLogDTO.setCaller(caller);
apiLogDTO.setApiName(apiEntity.getName()); apiLogDTO.setApiName(apiEntity.getName());
@ -842,7 +843,7 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I
//调用IP //调用IP
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
apiLogDTO.setIp(IpUtils.getIpAddr(request)); apiLogDTO.setIp(IpUtils.getIpAddr(request));
apiLogService.saveDto(apiLogDTO);
apiLogService.saveOrUpdate(apiLogDTO);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
} }

Loading…
Cancel
Save