8 changed files with 195 additions and 4 deletions
-
41modules/carbon-public/src/main/java/com/thing/carbon/pub/controller/PubCockpitController.java
-
34modules/carbon-public/src/main/java/com/thing/carbon/pub/dto/CockpitEnterpriseInfo.java
-
13modules/carbon-public/src/main/java/com/thing/carbon/pub/mapper/PubCockpitMapper.java
-
11modules/carbon-public/src/main/java/com/thing/carbon/pub/service/PubCockpitService.java
-
42modules/carbon-public/src/main/java/com/thing/carbon/pub/service/impl/PubCockpitServiceImpl.java
-
2modules/carbon-public/src/main/resources/mapper/CarbonPubSupplierMapper.xml
-
39modules/carbon-public/src/main/resources/mapper/PubCockpitMapper.xml
-
17modules/cqc-service/src/main/java/com/thing/cqc/rpcService/JsonCryptoUtils.java
@ -0,0 +1,41 @@ |
|||
package com.thing.carbon.pub.controller; |
|||
|
|||
|
|||
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo; |
|||
import com.thing.carbon.pub.service.PubCockpitService; |
|||
import com.thing.common.core.web.response.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 企业注册 |
|||
* |
|||
* @author xc |
|||
* @since 3.0 2024-07-09 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v2/pub/cockpit") |
|||
@Tag(name="公共服务侧大屏看板") |
|||
@RequiredArgsConstructor |
|||
public class PubCockpitController { |
|||
|
|||
@Autowired |
|||
private PubCockpitService pubCockpitService; |
|||
|
|||
@GetMapping("list") |
|||
@Operation(summary="分页") |
|||
public Result<List<CockpitEnterpriseInfo>> list(){ |
|||
List<CockpitEnterpriseInfo> list = pubCockpitService.cockpitEnterpriseInfoList(); |
|||
return new Result<List<CockpitEnterpriseInfo>>().ok(list); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package com.thing.carbon.pub.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 企业列表详情 |
|||
*/ |
|||
@Data |
|||
@Schema(description = "国网侧驾驶舱企业信息") |
|||
public class CockpitEnterpriseInfo { |
|||
@Schema(description = "企业名称") |
|||
private String name; |
|||
@Schema(description = "企业编码") |
|||
private String code; |
|||
@Schema(description = "企业区域id") |
|||
private String regionId; |
|||
@Schema(description = "碳足迹结果数量") |
|||
private String recordsCount; |
|||
@Schema(description = "产品数量") |
|||
private String productCount; |
|||
@Schema(description = "经纬度原始值") |
|||
private String lngLatStr; |
|||
@Schema(description = "经度") |
|||
private String lng; |
|||
@Schema(description = "纬度") |
|||
private String lat; |
|||
@Schema(description = "产品分类") |
|||
private String productType; |
|||
@Schema(description = "平均产品碳足迹") |
|||
private BigDecimal avgCarBon; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package com.thing.carbon.pub.mapper; |
|||
|
|||
|
|||
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
@Mapper |
|||
public interface PubCockpitMapper { |
|||
List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList(); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
package com.thing.carbon.pub.service; |
|||
|
|||
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface PubCockpitService { |
|||
|
|||
|
|||
List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList(); |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.thing.carbon.pub.service.impl; |
|||
|
|||
import com.thing.carbon.pub.dto.CockpitEnterpriseInfo; |
|||
import com.thing.carbon.pub.mapper.CarbonPubSupplierMapper; |
|||
import com.thing.carbon.pub.mapper.PubCockpitMapper; |
|||
import com.thing.carbon.pub.service.PubCockpitService; |
|||
import org.apache.commons.lang3.ObjectUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.math.RoundingMode; |
|||
import java.util.List; |
|||
|
|||
|
|||
@Service |
|||
public class PubCockpitServiceImpl implements PubCockpitService { |
|||
|
|||
|
|||
@Autowired |
|||
private PubCockpitMapper pubCockpitMapper; |
|||
|
|||
@Autowired |
|||
private CarbonPubSupplierMapper carbonPubSupplierMapper; |
|||
|
|||
|
|||
@Override |
|||
public List<CockpitEnterpriseInfo> cockpitEnterpriseInfoList() { |
|||
List<CockpitEnterpriseInfo> infoList = pubCockpitMapper.cockpitEnterpriseInfoList(); |
|||
infoList.forEach(temp->{ |
|||
if(ObjectUtils.isNotEmpty(temp.getLngLatStr())){ |
|||
String[] strs = temp.getLngLatStr().split(","); |
|||
temp.setLng(strs[0]); |
|||
temp.setLat(strs[1]); |
|||
} |
|||
//补全平均产品碳足迹值 |
|||
BigDecimal avgCarbon = carbonPubSupplierMapper.avgCarbonOfAllProduct(Long.parseLong(temp.getCode()),null,null); |
|||
temp.setAvgCarBon(avgCarbon.setScale(4, RoundingMode.UP)); |
|||
}); |
|||
return infoList; |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.thing.carbon.pub.mapper.PubCockpitMapper"> |
|||
|
|||
<select id="cockpitEnterpriseInfoList" resultType="com.thing.carbon.pub.dto.CockpitEnterpriseInfo"> |
|||
SELECT |
|||
cps.NAME, |
|||
cps.code, |
|||
cps.region_id, |
|||
COALESCE ( t2.records_count, 0 ) AS records_count, |
|||
COALESCE ( t3.product_count, 0 ) AS product_count, |
|||
td.lng_lat as lngLatStr, |
|||
TEMP.product_type |
|||
FROM |
|||
carbon_pub_supplier cps |
|||
LEFT JOIN ( SELECT string_agg ( DISTINCT industry_sub, ',' ) AS product_type, tenant_code FROM iot_carbon_production_variety GROUP BY tenant_code ) TEMP ON cps.code = TEMP.tenant_code |
|||
LEFT JOIN ( |
|||
SELECT SUM |
|||
( pr_unit ) AS records_count, |
|||
tenant_code |
|||
FROM |
|||
( SELECT COUNT ( DISTINCT pr_code ) AS pr_unit, tenant_code, pr_code FROM carbon_pub_production_result GROUP BY product_id, pr_code, tenant_code ) t1 |
|||
GROUP BY |
|||
tenant_code |
|||
) t2 ON cps.code = t2.tenant_code |
|||
LEFT JOIN ( |
|||
SELECT SUM |
|||
( product_count ) AS product_count, |
|||
tenant_code |
|||
FROM |
|||
( SELECT COUNT ( DISTINCT product_id ) AS product_count, tenant_code FROM carbon_pub_production_result GROUP BY product_id, tenant_code ) t1 |
|||
GROUP BY |
|||
tenant_code |
|||
) t3 ON cps.code = t3.tenant_code |
|||
LEFT JOIN sys_tenant_detail td on cps.code = td.id |
|||
</select> |
|||
|
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue