河北两级贯通接口调整
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.njcn.harmonic.controller.upload;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 调度算法执行结果记录表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-06-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rUploadDataLog")
|
||||
public class RUploadDataLogController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.harmonic.mapper.upload;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.harmonic.pojo.po.upload.RUploadDataLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 调度算法执行结果记录表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-06-06
|
||||
*/
|
||||
public interface RUploadDataLogMapper extends MppBaseMapper<RUploadDataLog> {
|
||||
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class RMpPartHarmonicDetailDServiceImpl extends ServiceImpl<RMpPartHarmon
|
||||
@Override
|
||||
public Page<RMpPartHarmonicDetailDTO> getRMpPartHarmonicDetail(RMpPartHarmonicDetailQueryParam param) {
|
||||
|
||||
String start = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(param.getEndTime(), DatePattern.NORM_DATE_PATTERN),-15),DatePattern.NORM_DATE_PATTERN);
|
||||
//String start = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(param.getEndTime(), DatePattern.NORM_DATE_PATTERN),-15),DatePattern.NORM_DATE_PATTERN);
|
||||
|
||||
List<String> lineIdLists = deptLineFeignClient.getLineNodeByDeptId(param.getOrgNo()).getData();
|
||||
if (CollectionUtils.isEmpty(lineIdLists)){
|
||||
@@ -70,7 +70,7 @@ public class RMpPartHarmonicDetailDServiceImpl extends ServiceImpl<RMpPartHarmon
|
||||
List<RStatLimitRateDPO> rStatLimitRateDPOs = irStatLimitRateDService.lambdaQuery()
|
||||
.in(RStatLimitRateDPO::getLineId,lineIdLists)
|
||||
.eq(RStatLimitRateDPO::getPhasicType,"T")
|
||||
.between(RStatLimitRateDPO::getTime, start+" 00:00:00", param.getEndTime()+" 23:59:59").list();
|
||||
.between(RStatLimitRateDPO::getTime, param.getStartTime()+" 00:00:00", param.getEndTime()+" 23:59:59").list();
|
||||
List<RMpPartHarmonicDetailDTO> rMpPartHarmonicDetailDTOS = new ArrayList<>();
|
||||
LocalDate date = LocalDate.parse(param.getStartTime());
|
||||
YearMonth yearMonth = YearMonth.from(date);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.harmonic.service.upload;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.harmonic.pojo.po.upload.RUploadDataLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 调度算法执行结果记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-06-06
|
||||
*/
|
||||
public interface IRUploadDataLogService extends IMppService<RUploadDataLog> {
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -30,6 +31,7 @@ import com.njcn.harmonic.pojo.po.upload.*;
|
||||
import com.njcn.harmonic.pojo.vo.upload.DimBusBarVO;
|
||||
import com.njcn.harmonic.pojo.vo.upload.UploadEvaluationDataVo;
|
||||
import com.njcn.harmonic.service.upload.IEvaluationDataService;
|
||||
import com.njcn.harmonic.service.upload.IRUploadDataLogService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
@@ -47,7 +49,10 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -84,6 +89,8 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
|
||||
private final PmsMidLedgerClient pmsMidLedgerClient;
|
||||
|
||||
private final IRUploadDataLogService irUploadDataLogService;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -121,6 +128,7 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
|
||||
@Override
|
||||
public String uploadEvaluationData(UploadParam param) {
|
||||
LocalDate localDate = LocalDate.parse(param.getTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||
List<RUploadEvaluationDataD> list;
|
||||
//指定数据上送,不管之前有没有上送,都重新上送一次
|
||||
//(预防之前上送过,修改数据后需要再次上送)
|
||||
@@ -141,6 +149,8 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
//以尺寸100分片
|
||||
List<List<RUploadEvaluationDataD>> partition = ListUtils.partition(list, 100);
|
||||
//分片上传
|
||||
StrBuilder resultLog = new StrBuilder();
|
||||
AtomicBoolean resultFlag = new AtomicBoolean(true);
|
||||
for (int i = 0; i < partition.size(); i++) {
|
||||
//处理数据
|
||||
List<RUploadEvaluationDataD> collect = partition.get(i).stream().peek(item -> {
|
||||
@@ -181,11 +191,29 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.EVALUATION);
|
||||
//获取返回结果
|
||||
List<String> l = dtoList.stream().map(PqEvaluationCreateDTO::getId).collect(Collectors.toList());
|
||||
returnInformation(i, l, send);
|
||||
|
||||
returnInformation(i, l, send,resultLog,resultFlag,localDate);
|
||||
}
|
||||
|
||||
if(resultFlag.get()){
|
||||
assUploadLog(localDate,resultLog,resultFlag);
|
||||
}
|
||||
|
||||
|
||||
return "上送成功:成功数据" + list.size() + "条";
|
||||
}
|
||||
|
||||
private void assUploadLog(LocalDate statisticDate,StrBuilder msg,AtomicBoolean resultFlag){
|
||||
RUploadDataLog rUploadDataLog = new RUploadDataLog();
|
||||
rUploadDataLog.setStatisticDate(statisticDate);
|
||||
rUploadDataLog.setBigType(0);
|
||||
rUploadDataLog.setSmallType(0);
|
||||
rUploadDataLog.setCreateTime(LocalDateTime.now());
|
||||
rUploadDataLog.setResult(resultFlag.get()?1:0);
|
||||
rUploadDataLog.setResultMsg(msg.toString());
|
||||
irUploadDataLogService.saveOrUpdateByMultiId(rUploadDataLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DimBusBarVO> getBaseEvaOnlineBusDetail(DimBusBarParam param) {
|
||||
List<String> temBusIds = new ArrayList<>();
|
||||
@@ -607,7 +635,9 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
* @param send 上送结果
|
||||
* @return
|
||||
*/
|
||||
private void returnInformation(Integer step, List<String> ids, Map<String, String> send) {
|
||||
private void returnInformation(Integer step, List<String> ids, Map<String, String> send,StrBuilder resultLog,AtomicBoolean resultFlag,LocalDate localDate) {
|
||||
int start = step * 100;
|
||||
int end = (step + 1) * 100;
|
||||
if (send.containsKey("succeed")) {
|
||||
String succeed = send.get("succeed");
|
||||
if (succeed.contains("\\\"")) {
|
||||
@@ -615,21 +645,30 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
}
|
||||
Map mapData = JSON.parseObject(succeed, Map.class);
|
||||
String status = mapData.get("status").toString();
|
||||
|
||||
if ("000000".equals(status)) {
|
||||
//修改数据上送状态
|
||||
updateState(ids);
|
||||
String result = mapData.get("result").toString();
|
||||
Map mapCount = JSON.parseObject(result, Map.class);
|
||||
String count = mapCount.get("count").toString();
|
||||
resultLog.append(" 上送" + start + "条至" + end + "条数据成功,返回成功条数: "+count+"; ");
|
||||
} else {
|
||||
resultFlag.set(false);
|
||||
String errors = mapData.get("errors").toString();
|
||||
int start = step * 100;
|
||||
int end = (step + 1) * 100;
|
||||
throw new BusinessException("上送" + start + "条至" + end + "条数据,上送失败:" + status + "_" + errors);
|
||||
String errorMsg = " 上送" + start + "条至" + end + "条数据,上送失败:" + status + "_" + errors+" ;";
|
||||
resultLog.append(errorMsg);
|
||||
assUploadLog(localDate,resultLog,resultFlag);
|
||||
throw new BusinessException(errorMsg);
|
||||
}
|
||||
} else {
|
||||
resultFlag.set(false);
|
||||
resultLog.append(" 上送" + start + "条至" + end + "条数据网络异常;");
|
||||
assUploadLog(localDate,resultLog,resultFlag);
|
||||
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.harmonic.service.upload.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.harmonic.mapper.upload.RUploadDataLogMapper;
|
||||
import com.njcn.harmonic.pojo.po.upload.RUploadDataLog;
|
||||
import com.njcn.harmonic.service.upload.IRUploadDataLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 调度算法执行结果记录表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-06-06
|
||||
*/
|
||||
@Service
|
||||
public class RUploadDataLogServiceImpl extends MppServiceImpl<RUploadDataLogMapper, RUploadDataLog> implements IRUploadDataLogService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user