|
|
|
|
@@ -7,8 +7,12 @@ import cn.hutool.core.date.TimeInterval;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.njcn.common.pojo.constant.BizParamConstant;
|
|
|
|
|
import com.njcn.common.pojo.constant.ServerInfo;
|
|
|
|
|
import com.njcn.common.pojo.response.HttpResult;
|
|
|
|
|
import com.njcn.common.utils.LogUtil;
|
|
|
|
|
import com.njcn.device.biz.commApi.DeptLineGeneralClient;
|
|
|
|
|
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO;
|
|
|
|
|
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
|
|
|
|
import com.njcn.device.pq.api.DeptLineFeignClient;
|
|
|
|
|
import com.njcn.device.pq.api.LineFeignClient;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.Overlimit;
|
|
|
|
|
@@ -23,6 +27,8 @@ import com.njcn.prepare.harmonic.service.mysql.line.PollutionService;
|
|
|
|
|
import com.njcn.system.api.DicDataFeignClient;
|
|
|
|
|
import com.njcn.system.enums.DicDataTypeEnum;
|
|
|
|
|
import com.njcn.system.pojo.po.DictData;
|
|
|
|
|
import com.njcn.user.api.DeptFeignClient;
|
|
|
|
|
import com.njcn.user.pojo.po.Dept;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.influxdb.dto.QueryResult;
|
|
|
|
|
@@ -77,9 +83,14 @@ public class PollutionServiceImpl implements PollutionService {
|
|
|
|
|
|
|
|
|
|
private final RMpPollutionDMapper rMpPollutionDMapper;
|
|
|
|
|
|
|
|
|
|
private final DeptLineGeneralClient deptLineGeneralClient;
|
|
|
|
|
|
|
|
|
|
private final DeptFeignClient deptFeignClient;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Async("asyncExecutor")
|
|
|
|
|
public void processPollutionData(LineParam lineParam) {
|
|
|
|
|
|
|
|
|
|
TimeInterval timer = new TimeInterval();
|
|
|
|
|
List<PollutionDTO> pollutionList;
|
|
|
|
|
LocalDateTime local = LocalDateTimeUtil.now();
|
|
|
|
|
@@ -135,12 +146,12 @@ public class PollutionServiceImpl implements PollutionService {
|
|
|
|
|
localEnd = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOute) + "T23:59:59");
|
|
|
|
|
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_QUARTER).equals(lineParam.getType())){
|
|
|
|
|
Date dateOutb = DateUtil.beginOfQuarter(dateOut);
|
|
|
|
|
Date dateOute = DateUtil.endOfQuarter(dateOut);
|
|
|
|
|
Date dateOute = dateOut;
|
|
|
|
|
local = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOutb) + "T00:00:00");
|
|
|
|
|
localEnd = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOute) + "T23:59:59");
|
|
|
|
|
}else if (Integer.valueOf(BizParamConstant.STAT_BIZ_YEAR).equals(lineParam.getType())){
|
|
|
|
|
Date dateOutb = DateUtil.beginOfYear(dateOut);
|
|
|
|
|
Date dateOute = DateUtil.endOfYear(dateOut);
|
|
|
|
|
Date dateOute = dateOut;
|
|
|
|
|
local = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOutb) + "T00:00:00");
|
|
|
|
|
localEnd = LocalDateTimeUtil.parse(DateUtil.formatDate(dateOute) + "T23:59:59");
|
|
|
|
|
}
|
|
|
|
|
@@ -158,11 +169,18 @@ public class PollutionServiceImpl implements PollutionService {
|
|
|
|
|
*/
|
|
|
|
|
private void insertPolluctionMySql(List<RMpPollutionDPO> pollutionDayList, List<DictData> dictData, LocalDateTime local, Integer type){
|
|
|
|
|
HttpResult<Map<String, List<String>>> substationOut = lineFeignClient.getLineBySubstationRelation(1);
|
|
|
|
|
HttpResult<Map<String, List<String>>> unitOut = deptLineFeignClient.getLineByDeptRelation(1);
|
|
|
|
|
//HttpResult<Map<String, List<String>>> unitOut = deptLineFeignClient.getLineByDeptRelation(1);
|
|
|
|
|
|
|
|
|
|
Dept dept = deptFeignClient.getRootDept().getData();
|
|
|
|
|
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
|
|
|
|
deptGetLineParam.setDeptId(dept.getId());
|
|
|
|
|
deptGetLineParam.setServerName(ServerInfo.HARMONIC);
|
|
|
|
|
List<DeptGetChildrenDTO> deptGetChildrenDTOList = deptLineGeneralClient.deptGetLineList(deptGetLineParam).getData();
|
|
|
|
|
|
|
|
|
|
Map<String, List<String>> substationMap = substationOut.getData();
|
|
|
|
|
Map<String, List<String>> unitMap = unitOut.getData();
|
|
|
|
|
|
|
|
|
|
insertSubstation(dictData,substationMap,pollutionDayList,local,type);
|
|
|
|
|
insertUnit(dictData,unitMap,pollutionDayList,local,type);
|
|
|
|
|
insertUnit(dictData,deptGetChildrenDTOList,pollutionDayList,local,type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*MySql入表 r_mp_pollution_d*/
|
|
|
|
|
@@ -212,11 +230,11 @@ public class PollutionServiceImpl implements PollutionService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*MySql入表 r_stat_pollution_org*/
|
|
|
|
|
private void insertUnit(List<DictData> dictDataList,Map<String, List<String>> unitMap,List<RMpPollutionDPO> pollutionDayList,LocalDateTime local, Integer type){
|
|
|
|
|
for (String key : unitMap.keySet()){
|
|
|
|
|
private void insertUnit(List<DictData> dictDataList,List<DeptGetChildrenDTO> deptGetChildrenDTOList,List<RMpPollutionDPO> pollutionDayList,LocalDateTime local, Integer type){
|
|
|
|
|
for (DeptGetChildrenDTO deptGetChildrenDTO : deptGetChildrenDTOList){
|
|
|
|
|
List<RMpPollutionDPO> processList = new ArrayList<>();
|
|
|
|
|
List<String> unitList = unitMap.get(key);
|
|
|
|
|
for(String lineid : unitList){
|
|
|
|
|
|
|
|
|
|
for(String lineid : deptGetChildrenDTO.getLineIds()){
|
|
|
|
|
for (RMpPollutionDPO pollution : pollutionDayList){
|
|
|
|
|
if (lineid.equals(pollution.getLineId())){
|
|
|
|
|
processList.add(pollution);
|
|
|
|
|
@@ -224,7 +242,7 @@ public class PollutionServiceImpl implements PollutionService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> inMap = new HashMap<>();
|
|
|
|
|
inMap.put("orgId",key);
|
|
|
|
|
inMap.put("orgId",deptGetChildrenDTO.getDeptId());
|
|
|
|
|
inMap.put("dataDate",local);
|
|
|
|
|
for (DictData dictData : dictDataList){
|
|
|
|
|
processData(dictData, processList, inMap);
|
|
|
|
|
|