Commit 798c67ca authored by tianyiming's avatar tianyiming

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents f406891c 6718fa39
package com.yeejoin.amos.boot.biz.common;
public class Test {
public static void main(String[] args) {
System.out.println("dddddddddddddd");
}
}
......@@ -17,7 +17,12 @@ public class IndexDto {
private String address;// 指标地址
private String createdTime;// '上报时间',
private String equipmentSpecificName;//
private String equipmentNumber;
private String value;
private int count;
private String equipmentsIdx;
private String equipmentIndexName; // 指标名称【风机状态名称】
private String longitude; // 经度
private String latitude; // 纬度
private String frontModule;
}
......@@ -112,7 +112,7 @@
station_basic.station_type stationType,
station_basic.station_flag stationFlag,
station_basic.area_code areaCode,
station_basic.jumpPath,
station_basic.jump_path,
station_basic.risk_level riskLevel,
station_basic.belong_area belongArea,
station_coordinate.longitude,
......@@ -154,7 +154,7 @@
<select id="getStationListByRegionCode" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto">
select
station_name as name,
station_code as code,
sequence_nbr as code,
station_type as parentCode,
sequence_nbr as id,
'1' as isOnclick
......
......@@ -175,7 +175,7 @@ public class StationBasicController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "场站地图数据", notes = "场站地图数据")
@GetMapping(value = "/listforMap")
public ResponseModel<List<StationInfoDto>> getStationList(@RequestParam(value = "areaCode", required = false) String areaCode,@RequestParam(value = "type", required = false) String type) {
public ResponseModel<List<StationInfoDto>> getStationList(@RequestParam(value = "areaCode", required = false) String areaCode,@RequestParam(value = "type", required = false,defaultValue = "qj") String type) {
return ResponseHelper.buildResponse(stationBasicServiceImpl.getStationList(areaCode,type));
}
}
......@@ -2,10 +2,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.PersonAccountDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -20,6 +21,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -34,43 +36,27 @@ import java.util.List;
public class DeviceController extends BaseController {
@Autowired
InfluxDButils influxDButils;
MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取告警数据")
@ApiOperation(value = "获取每个风机实时告警数据")
@GetMapping("/nationwide")
public ResponseModel<Page<IndexDto>> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "gateway") String gateway,@RequestParam(value = "equipmentNumber") String equipmentNumber) {
Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current);
page.setSize(size);
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM ");
querysql.append("indicators_").append(gateway);
querysql.append(" WHERE isAlarm='1' and value!='0.0' and gatewayId=");
querysql.append(gateway);
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM ");
querysqlcount.append("indicators_").append(gateway);
querysqlcount.append(" WHERE isAlarm='1' and value!='0.0' and gatewayId=");
querysqlcount.append(gateway);
if(StringUtils.isNotEmpty(querysqlcount)){
querysqlcount.append(" and equipmentNumber =").append(equipmentNumber);
querysql.append(" and equipmentNumber =").append(equipmentNumber);
}
querysql.append(" ORDER BY time desc LIMIT ").append(page.getSize()).append(" OFFSET ").append((page.getCurrent() - 1)*page.getSize());
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql.toString(),IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcount.toString(),IndexDto.class);
page.setRecords(list);
if(list1!=null&&list1.size()>0){
page.setTotal(list1.get(0).getCount());
}
return ResponseHelper.buildResponse(page);
public ResponseModel<ResultsData> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
ResultsData resultsData=monitorFanIndicatorImpl.getNationWideInfo( current, size, stationBasicId, equipmentNumber);
return ResponseHelper.buildResponse(resultsData);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取历史告警数据")
@GetMapping("/historyNationwide")
public ResponseModel<ResultsData> getLSNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
ResultsData resultsData=monitorFanIndicatorImpl.getLsNationWideInfo( current, size, stationBasicId, equipmentNumber);
return ResponseHelper.buildResponse(resultsData);
}
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
......@@ -20,6 +21,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
@RestController
@Api(tags = "大屏相关API")
......@@ -36,12 +38,13 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据设备编号、网关ID、前段展示模块查询表数据")
@GetMapping("/getFanIdxInfoByPage")
public ResponseModel<IPage<MonitorFanIndicator>> getFanIdxInfoByPage(@RequestParam(value = "equipmentNumber", required = false) String equipmentNumber,
@RequestParam(value = "gateway", required = false) String gateway,
@RequestParam(value = "frontModule", required = false) String frontModule,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanIdxInfoByPage(equipmentNumber, gateway, frontModule, current, size));
public ResponseModel<IPage<IndexDto>> getFanIdxInfoByPage(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "frontModule", required = false) String frontModule,
@RequestParam(value = "systemType", required = false) String systemType,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanIdxInfoByPage(equipNum, stationId, frontModule, current, size, systemType));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -54,7 +57,27 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机状态列表")
@GetMapping("/getFanStatusList")
public ResponseModel<List<IndexDto>> getFanStatusList(@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanStatusList(stationId));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机状态统计")
@GetMapping("/getFanStatusStatistics")
public ResponseModel<Map<String, Long>> getFanStatusStatistics(@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanStatusStatistics(stationId));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机基础信息")
@GetMapping("/getFanBasicInfoByEquipNum")
public ResponseModel<IndexDto> getFanBasicInfoByEquipNum(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanBasicInfoByEquipNum(equipNum, stationId));
}
}
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMapRegionService;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitoringServiceImpl;
......@@ -48,9 +49,9 @@ public class MonitoringMapController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取社会贡献")
@GetMapping("/getTotalSocialContribution")
public void getTotalSocialContribution() {
// return ResponseHelper.buildResponse(monitoringServiceImpl.getTotalSocialContribution());
@ApiOperation(value = "获取区域电量指标完成情况")
@GetMapping("/getCompletionOfPowerIndicatorsByProvinceName")
public ResponseModel<ResultsData> getCompletionOfPowerIndicatorsByProvinceName(@RequestParam(required = true) int current, @RequestParam(required = true) int size, @RequestParam(required = true) String provinceName) {
return ResponseHelper.buildResponse(monitoringServiceImpl.getCompletionOfPowerIndicatorsByProvinceName(current,size,provinceName));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2023/7/6
*/
@Data
public class ColModel {
private String fid;
private String dataIndex;
private String name;
private String title;
private String type;
private String key;
public ColModel(String fid, String dataIndex, String name, String title, String type, String key) {
this.fid = fid;
this.dataIndex = dataIndex;
this.name = name;
this.title = title;
this.type = type;
this.key = key;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
@Data
public class CompletionOfPowerIndicatorsDto {
//场站名称
private String stationName;
//装机容量
private String installCapactity;
//风速或者辐照度
private String windSpeedOrIrradiance;
// 有功功率
private String activePower;
//日发电量
private String dailyPower;
//月发电量
private String monthlyPower;
//年发电量
private String annualPower;
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/7/6
*/
@Data
public class DataGridMock {
private int current;
private int total;
private boolean pagination;
private int totalPage;
private List dataList;
public DataGridMock(int current, int total, boolean pagination, int totalPage, List dataList) {
this.current = current;
this.total = total;
this.pagination = pagination;
this.totalPage = totalPage;
this.dataList = dataList;
}
}
......@@ -2,7 +2,25 @@ package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
/**
* 指标dto-用于接收influxdb里边查询的到的数据
*/
@Data
public class IndicatorsDto {
private String address;
private String createdTime;
private String dataType;
private String equipmentIndex;
private String equipmentIndexName;
private String equipmentNumber;
private String equipmentSpecificName;
private String equipmentsIdx;
private String frontModule;
private String gatewayId;
private String isAlarm;
private String systemType;
private String traceId;
private String unit;
private String value;
private String valueLabel;
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/7/6
*/
@Data
public class ResultsData {
private DataGridMock dataGridMock;
private List<ColModel> colModel;
public ResultsData(DataGridMock dataGridMock, List<ColModel> colModel) {
this.dataGridMock = dataGridMock;
this.colModel = colModel;
}
}
package com.yeejoin.amos.boot.module.jxiop.api.service;
package com.yeejoin.amos.boot.module.jxiop.biz.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -16,4 +15,6 @@ public interface IMonitorFanIndicator {
//批量修改指标值
void UpdateMonitorFanIndicator(List<IndexDto> list);
ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CommonServiceImpl {
@Autowired
InfluxDButils influxDButils;
/**
* @deprecated 获取指标值总和
* @param gatewayId 网关id 用于拼接sql语句
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和
*/
public Double getTotalByIndicatior(String gatewayId,String indicator){
String sql = "SELECT * FROM indicators_"+gatewayId+" where equipmentIndexName='"+indicator+"'";
Double totalvalue = 0.0;
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql,IndicatorsDto.class);
List<Double> doubleList = indicatorsDtoList.stream().map(indicatorsDto -> Double.parseDouble(indicatorsDto.getValue())).collect(Collectors.toList());
totalvalue = doubleList.stream().mapToDouble(Double::doubleValue).sum();
return totalvalue;
}
/**
* @deprecated 获取指标值平均值
* @param gatewayId 网关id 用于拼接sql语句
* @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和
*/
public Double getAvgvalueByIndicatior(String gatewayId,String indicator){
String sql = "SELECT * FROM indicators_"+gatewayId+" where equipmentIndexName='"+indicator+"'";
Double avageValue = 0.0;
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql,IndicatorsDto.class);
List<Double> doubleList = indicatorsDtoList.stream().map(indicatorsDto -> Double.parseDouble(indicatorsDto.getValue())).collect(Collectors.toList());
avageValue = doubleList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
return avageValue;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@Async
@Service
public class MonitoringServiceIMQTTmpl {
Logger logger = LoggerFactory.getLogger(MonitoringServiceIMQTTmpl.class);
/**
* 场站mapper
*/
@Autowired
StationBasicMapper stationBasicMapper;
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
RegionMapper regionMapper;
@Autowired
EmqKeeper emqKeeper;
@Scheduled(cron = "0 0/1 * * * *")
public void getTotalSocialContribution() {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
logger.error("--------------------------社会贡献定时执行----------------------------------------------");
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
//定义社会贡献列表
AtomicReference<Double> totalSocialContribution = new AtomicReference<>(0.0);
//获取所有网关id不为空的数据
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
totalSocialContribution.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量"));
});
//二氧化碳贡献数
SocialContributionDto co2 = new SocialContributionDto();
//标准煤贡献度
SocialContributionDto coal = new SocialContributionDto();
//碳粉尘计算公式
SocialContributionDto toner = new SocialContributionDto();
//二氧化硫贡献度
SocialContributionDto so2 = new SocialContributionDto();
/** 社会贡献原始计算公式,后边的数据已经经过处理
//二氧化碳计算公式 *10000*832/10000/1000/1000
//标准煤计算公式 *10000*304.9/10000/1000/1000
//碳粉尘计算公式 *10000*0.032/1000/1000
//二氧化硫计算公式 =A2*10000*0.16/1000/1000
*/
co2.setUnit("二氧化碳减排量(万t)");
co2.setTitle(totalSocialContribution.get() * 0.000832);
socialContributionDtoList.add(co2);
coal.setUnit("节约标准煤(万t)");
coal.setTitle(totalSocialContribution.get() * 0.0003049);
socialContributionDtoList.add(coal);
toner.setUnit("碳粉尘减排量(万t)");
toner.setTitle(totalSocialContribution.get() * 0.00032);
socialContributionDtoList.add(toner);
so2.setUnit("二氧化硫减排量(万t)");
so2.setTitle(totalSocialContribution.get() * 0.0016);
socialContributionDtoList.add(so2);
socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100);
socialContributionDtoPage.setCurrent(1);
try {
emqKeeper.getMqttClient().publish("socialcontribution_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true);
logger.info("-----------------发送社会贡献消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage));
} catch (Exception exception) {
logger.error("-----------------发送社会贡献消息=================== 失败!");
}
}
@Scheduled(cron = "0/30 * * * * *")
public void getCompletionOfPowerIndicatorsByProvinceName() {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
logger.error("--------------------------区域实时数据消息开始发送----------------------------------------------");
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
Region region = this.regionMapper.selectOne(new QueryWrapper<Region>().eq("level", 1).eq("region_name", "江苏省"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("belong_area", region.getRegionCode()));
//日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
//年发电量完成比例
Double completionRatio = 23.11;
//年利用小时数
AtomicReference<Double> useHours = new AtomicReference<>(0.01);
stationBasicList.forEach(stationBasic -> {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量"));
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量"));
useHours.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日工作时间"));
});
SocialContributionDto dailyPowerdto = new SocialContributionDto();
dailyPowerdto.setTitle(dailyPower.get());
dailyPowerdto.setUnit("万kWh");
SocialContributionDto monthlyPowerdto = new SocialContributionDto();
monthlyPowerdto.setTitle(monthlyPower.get());
monthlyPowerdto.setUnit("万kWh");
SocialContributionDto annualPowerdto = new SocialContributionDto();
annualPowerdto.setTitle(annualPower.get());
annualPowerdto.setUnit("万kWh");
SocialContributionDto completionRatioDto = new SocialContributionDto();
completionRatioDto.setTitle(completionRatio);
completionRatioDto.setUnit("%");
SocialContributionDto useHoursDto = new SocialContributionDto();
useHoursDto.setTitle(useHours.get());
useHoursDto.setUnit("h");
socialContributionDtoList.add(dailyPowerdto);
socialContributionDtoList.add(monthlyPowerdto);
socialContributionDtoList.add(annualPowerdto);
socialContributionDtoList.add(completionRatioDto);
socialContributionDtoList.add(useHoursDto);
socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100);
socialContributionDtoPage.setCurrent(1);
try {
emqKeeper.getMqttClient().publish("completionofpowerindicator_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true);
logger.info("-----------------发送区域实时生产数据消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage));
} catch (Exception exception) {
logger.error("-----------------发送区域实时生产数据消息=================== 失败!");
}
}
}
......@@ -66,8 +66,8 @@ privilege.fegin.name=AMOS-API-PRIVILEGE
feign.client.config.default.connect-timeout=20000
feign.client.config.default.read-timeout=20000
#场站实时数据
station.task.cron=0/10 * * * * ?
station.task.cron=* * */10 * * ?
#是否切片
station.isok=true
station.isok=false
#风机更新数据切片量
station.section=10
\ No newline at end of file
station.section=1000
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum ImageSizeEnums {
/**
* 导出监管码、96333码尺寸
*/
// 监管码-大
JG_BIG("JG_BIG", "bigBg.png", 350, 350, 60, 720, 190, 0, 0, 780, 680),
// 监管码-中
JG_MID("JG_MID", "centreBg.png", 230, 230, 40, 480, 170, 0, 0, 520, 525),
// 监管码-小
JG_MIN("JG_MIN", "smallBg.png", 170, 170, 30, 360, 110, 0, 0, 380, 355),
// 96333电梯码
DT("DT", "dt.png", 170, 170, 30, 30, 110, 0, 0, 330, 355);
String code;
String bgPath;
Integer with;
Integer height;
Integer size;
Integer imagesX;
Integer imagesY;
Integer text1X;
Integer text1Y;
Integer text2X;
Integer text2Y;
public static ImageSizeEnums getEnumByCode(String code) {
for (ImageSizeEnums value : ImageSizeEnums.values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
}
......@@ -84,6 +84,7 @@ public interface IdxFeignService {
FeignClientResult<String> submit(@RequestParam(value = "pageId") long pageId,
@RequestParam(value = "taskId",required = false) String taskId,
@RequestParam(value = "planInstanceId", required = false) String planInstanceId,
@RequestParam(value = "bizField", required = false) String bizField,
@RequestParam(value = "topic", required = false) String topic,
@RequestParam(value = "tableName", required = false) String tableName,
@RequestBody Map<String, Object> kv) throws Exception;
......
......@@ -351,6 +351,7 @@
<if test="dto.ORG_BRANCH_NAME != '' and dto.ORG_BRANCH_NAME != null">and ORG_BRANCH_NAME = #{dto.ORG_BRANCH_NAME}</if>
<if test="dto.USE_PLACE != '' and dto.USE_PLACE != null">and USE_PLACE = #{dto.USE_PLACE}</if>
<if test="dto.STATUS != '' and dto.STATUS != null">and STATUS = #{dto.STATUS}</if>
<if test="dto.EQU_CATEGORY != '' and dto.EQU_CATEGORY != null">and EQU_CATEGORY = #{dto.EQU_CATEGORY}</if>
<if test="dto.USE_UNIT_CREDIT_CODE != '' and dto.USE_UNIT_CREDIT_CODE != null">and USE_UNIT_CREDIT_CODE like concat('%', #{dto.USE_UNIT_CREDIT_CODE},'%')</if>
<if test="dto.ORG_BRANCH_CODE != '' and dto.ORG_BRANCH_CODE != null">and ORG_BRANCH_CODE like concat('%', #{dto.ORG_BRANCH_CODE},'%')</if>
<if test='dto.ids != null'> and SEQUENCE_NBR in
......
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -13,13 +14,16 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.enums.ImageSizeEnums;
import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.tzs.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentCategoryServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.utils.ImageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
......@@ -30,10 +34,12 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* 装备分类
......@@ -55,6 +61,13 @@ public class EquipmentCategoryController extends BaseController {
EquipmentCategoryMapper equipmentCategoryMapper;
@Value("${regulatory_code_prefix}")
String REGULATORY_CODE_PREFIX ;
/**
* 监管码背景图路径
*/
private static final String BASE_PATH = "amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/resources/temp/";
/**
* 新增装备分类
......@@ -374,6 +387,64 @@ public class EquipmentCategoryController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/exportImage")
@ApiOperation(httpMethod = "GET", value = "设备监管码下载", notes = "设备监管码下载")
public void exportImage(HttpServletResponse response, @RequestParam("code") String code, @RequestParam("type") String type) throws IOException {
FileInputStream bgImgFile = null;
ImageSizeEnums imageSizeEnums = ImageSizeEnums.getEnumByCode(type);
try {
bgImgFile = new FileInputStream(BASE_PATH + imageSizeEnums.getBgPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File QrCodeFile = new File(BASE_PATH + code + ".png");
ImageUtils.creatQRCode(QrCodeFile, bgImgFile, imageSizeEnums.getWith(), imageSizeEnums.getHeight(), REGULATORY_CODE_PREFIX+code, "", code, imageSizeEnums.getSize(), imageSizeEnums.getImagesX(), imageSizeEnums.getImagesY(), imageSizeEnums.getText1X(), imageSizeEnums.getText1Y(), imageSizeEnums.getText2X(), imageSizeEnums.getText2Y());
ImageUtils.downloadResource(code + ".png", BASE_PATH + code + ".png", response);
QrCodeFile.delete();
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/exportImageZip")
@ApiOperation(httpMethod = "GET", value = "设备信息导出", notes = "设备信息导出")
public void exportImageZip(HttpServletResponse response, EquipExportDto dto, @RequestParam("type") String type) throws IOException {
File delete = new File(BASE_PATH + "images");
if (!delete.exists()) {
delete.mkdir();
}
ImageSizeEnums imageSizeEnums = ImageSizeEnums.getEnumByCode(type);
//创建list 存放图片
List<File> fileList = new ArrayList<>();
List<EquipExportVo> equipExportData = equipmentCategoryServiceImpl.getEquipExportData(dto);
List<EquipExportVo> unique = equipExportData.stream().collect(
Collectors. collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getSupervisoryCode() + ";" + o.getCode96333()))), ArrayList::new)
);
for (EquipExportVo equipExportDatum : unique) {
FileInputStream bgImgFile = new FileInputStream(BASE_PATH + imageSizeEnums.getBgPath());
if ("DT".equals(type) && !ObjectUtils.isEmpty(equipExportDatum.getCode96333())) {
File QrCodeFile = new File(BASE_PATH + "images/" + equipExportDatum.getCode96333() + ".png");
ImageUtils.creatQRCode(QrCodeFile, bgImgFile, imageSizeEnums.getWith(), imageSizeEnums.getHeight(), REGULATORY_CODE_PREFIX+equipExportDatum.getCode96333(), "", equipExportDatum.getCode96333(), imageSizeEnums.getSize(), imageSizeEnums.getImagesX(), imageSizeEnums.getImagesY(), imageSizeEnums.getText1X(), imageSizeEnums.getText1Y(), imageSizeEnums.getText2X(), imageSizeEnums.getText2Y());
fileList.add(new File(BASE_PATH + "images/" + equipExportDatum.getCode96333() + ".png"));
} else if (!ObjectUtils.isEmpty(equipExportDatum.getSupervisoryCode())) {
File QrCodeFile = new File(BASE_PATH + "images/" + equipExportDatum.getSupervisoryCode() + ".png");
ImageUtils.creatQRCode(QrCodeFile, bgImgFile, imageSizeEnums.getWith(), imageSizeEnums.getHeight(), REGULATORY_CODE_PREFIX+equipExportDatum.getSupervisoryCode(), "", equipExportDatum.getSupervisoryCode(), imageSizeEnums.getSize(), imageSizeEnums.getImagesX(), imageSizeEnums.getImagesY(), imageSizeEnums.getText1X(), imageSizeEnums.getText1Y(), imageSizeEnums.getText2X(), imageSizeEnums.getText2Y());
fileList.add(new File(BASE_PATH + "images/" + equipExportDatum.getSupervisoryCode() + ".png"));
}
bgImgFile.close();
}
File zipFile = new File(BASE_PATH + "images/imageZip.zip");
zipFile.createTempFile("imageZip", ".zip");
// 调用压缩方法
ImageUtils.zipFiles(fileList, zipFile);
ImageUtils.downloadResourceZip("imageZip.zip", BASE_PATH + "images/imageZip.zip", response);
zipFile.delete();
ImageUtils.deleteAllFilesOfDir(delete);
if (delete.exists()) {
ImageUtils.deleteAllFilesOfDir(delete);
}
}
}
......@@ -780,18 +780,19 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
String userIdsTask = String.join(",", task);
// 添加被检查企业下的人员id
objectMap.put("CHECKED_COMPANY_USERS", userIds);
objectMap.put("CHECKED_COMPANY_USER_ids", userIdsTask);
// 表单信息提交
FeignClientResult<String> submit = idxFeignService.submit(pageId, taskId, planInstanceId, topic, tableName, objectMap);
if ("200".equals(String.valueOf(submit.getStatus()))) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("title", "企业整改");
jsonObject.put("userIds", userIdsTask);
logger.info("idx执行任务更新参数,{}", JSONObject.toJSONString(jsonObject));
//FeignClientResult<JSONObject> jsonObjectFeignClientResult = idxFeignService.updateAmosTask(taskId, jsonObject);
updateAmosTask(taskId, jsonObject);
//logger.info("idx执行任务更新任务返回参数,{}", JSONObject.toJSONString(jsonObjectFeignClientResult));
}
FeignClientResult<String> submit = idxFeignService.submit(pageId, taskId, planInstanceId,"CHECKED_COMPANY_USER_ids", topic, tableName, objectMap);
// if ("200".equals(String.valueOf(submit.getStatus()))) {
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("title", "企业整改");
// jsonObject.put("userIds", userIdsTask);
// logger.info("idx执行任务更新参数,{}", JSONObject.toJSONString(jsonObject));
// //FeignClientResult<JSONObject> jsonObjectFeignClientResult = idxFeignService.updateAmosTask(taskId, jsonObject);
// updateAmosTask(taskId, jsonObject);
// //logger.info("idx执行任务更新任务返回参数,{}", JSONObject.toJSONString(jsonObjectFeignClientResult));
//
// }
return "ok";
}
......
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