代码调整
This commit is contained in:
@@ -5,6 +5,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
@@ -22,6 +24,7 @@ import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -36,6 +39,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -43,7 +51,7 @@ import java.time.LocalDateTime;
|
||||
* @date 2023年11月01日 10:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "监测点算法执行链")
|
||||
@Api(tags = "算法执行中心")
|
||||
@RestController
|
||||
@RequestMapping("/executor")
|
||||
@RequiredArgsConstructor
|
||||
@@ -54,39 +62,6 @@ public class ExecutionCenter extends BaseController {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("监测点算法执行链")
|
||||
@PostMapping("/measurementPointExecutor")
|
||||
public void measurementPointExecutor(@RequestBody BaseParam baseParam) {
|
||||
//手动判断参数是否合法,
|
||||
CalculatedParam calculatedParam = judgeExecuteParam(baseParam);
|
||||
// 测点索引
|
||||
if (CollectionUtils.isEmpty(calculatedParam.getIdList())) {
|
||||
calculatedParam.setIdList(commTerminalGeneralClient.getRunMonitorIds().getData());
|
||||
}
|
||||
LiteflowResponse liteflowResponse;
|
||||
if (baseParam.isRepair()) {
|
||||
//补招时,起始日期、截止日期必填
|
||||
DateTime startDate = DateUtil.parse(baseParam.getBeginTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
}
|
||||
calculatedParam.setDataDate(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
|
||||
liteflowResponse = flowExecutor.execute2Resp("measurement_point", calculatedParam);
|
||||
log.info("执行结果:{}", liteflowResponse.isSuccess());
|
||||
}
|
||||
} else {
|
||||
//非补招
|
||||
liteflowResponse = flowExecutor.execute2Resp("measurement_point", calculatedParam);
|
||||
log.info("执行结果:{}", liteflowResponse.isSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* 1、校验非全链执行时,tagNames节点标签集合必须为非空,否则提示---无可执行节点
|
||||
@@ -111,5 +86,68 @@ public class ExecutionCenter extends BaseController {
|
||||
return calculatedParam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @author hongawen
|
||||
* @date 2023/11/7 14:44
|
||||
*/
|
||||
private void dealResponse(CalculatedParam calculatedParam, LiteflowResponse liteflowResponse,String methodDescribe) {
|
||||
if(liteflowResponse.isSuccess()){
|
||||
log.info("日期{},{}执行{}成功",calculatedParam.getDataDate(),methodDescribe,calculatedParam.isFullChain()?"全链":"指定节点:".concat(String.join(StrPool.COMMA,calculatedParam.getTagNames())));
|
||||
}else{
|
||||
Map<String, List<CmpStep>> executeSteps = liteflowResponse.getExecuteSteps();
|
||||
CmpStep failStep = null;
|
||||
for (String key : executeSteps.keySet()) {
|
||||
List<CmpStep> cmpSteps = executeSteps.get(key);
|
||||
cmpSteps=cmpSteps.stream().filter(cmpStep -> !cmpStep.isSuccess()).collect(Collectors.toList());
|
||||
if(CollectionUtil.isNotEmpty(cmpSteps)){
|
||||
failStep = cmpSteps.get(0);
|
||||
}
|
||||
}
|
||||
log.error("日期{},{}执行{}失败,在执行{}失败,失败原因:{}"
|
||||
,calculatedParam.getDataDate()
|
||||
,methodDescribe
|
||||
,calculatedParam.isFullChain()?"全链":"指定节点:".concat(String.join(StrPool.COMMA,calculatedParam.getTagNames()))
|
||||
,failStep.getNodeId().concat(Objects.isNull(failStep.getTag()) ? "" :StrPool.DASHED.concat(failStep.getTag()))
|
||||
,failStep.getException().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("监测点算法执行链")
|
||||
@PostMapping("/measurementPointExecutor")
|
||||
public void measurementPointExecutor(@RequestBody BaseParam baseParam) {
|
||||
String methodDescribe = getMethodDescribe("measurementPointExecutor");
|
||||
//手动判断参数是否合法,
|
||||
CalculatedParam calculatedParam = judgeExecuteParam(baseParam);
|
||||
// 测点索引
|
||||
if (CollectionUtils.isEmpty(calculatedParam.getIdList())) {
|
||||
calculatedParam.setIdList(commTerminalGeneralClient.getRunMonitorIds().getData());
|
||||
}
|
||||
LiteflowResponse liteflowResponse;
|
||||
if (baseParam.isRepair()) {
|
||||
//补招时,起始日期、截止日期必填
|
||||
DateTime startDate = DateUtil.parse(baseParam.getBeginTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
}
|
||||
calculatedParam.setDataDate(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
|
||||
liteflowResponse = flowExecutor.execute2Resp("measurement_point", calculatedParam);
|
||||
dealResponse(calculatedParam,liteflowResponse,methodDescribe);
|
||||
}
|
||||
} else {
|
||||
//非补招
|
||||
liteflowResponse = flowExecutor.execute2Resp("measurement_point", calculatedParam);
|
||||
dealResponse(calculatedParam,liteflowResponse,methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,9 +34,12 @@ public class MeasurementExecutor extends BaseExecutor {
|
||||
* @author hongawen
|
||||
* @date 2023年11月01日 11:08
|
||||
*/
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rMpMonitorEvaluate", nodeType = NodeTypeEnum.COMMON)
|
||||
public boolean processRMpMonitorEvaluateAccess(NodeComponent bindCmp) {
|
||||
return isAccess(bindCmp);
|
||||
}
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rMpMonitorEvaluate", nodeType = NodeTypeEnum.COMMON)
|
||||
public void processRMpMonitorEvaluate(NodeComponent bindCmp) {
|
||||
isAccess(bindCmp);
|
||||
public void processRMpMonitorEvaluateProcess(NodeComponent bindCmp) {
|
||||
rMpMonitorEvaluateDService.handleDay(bindCmp.getRequestData());
|
||||
}
|
||||
|
||||
@@ -47,16 +50,18 @@ public class MeasurementExecutor extends BaseExecutor {
|
||||
* @author hongawen
|
||||
* @date 2023年11月01日 11:08
|
||||
*/
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rMpEventDetail", nodeType = NodeTypeEnum.COMMON)
|
||||
public boolean processRMpEventDetailAccess(NodeComponent bindCmp) {
|
||||
return isAccess(bindCmp);
|
||||
}
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rMpEventDetail", nodeType = NodeTypeEnum.COMMON)
|
||||
public void processRMpEventDetail(NodeComponent bindCmp) {
|
||||
public void processRMpEventDetailProcess(NodeComponent bindCmp) {
|
||||
String tag = bindCmp.getTag();
|
||||
CalculatedParam calculatedParam = bindCmp.getRequestData();
|
||||
if (tag.equalsIgnoreCase("r_mp_event_detail_d")) {
|
||||
isAccess(bindCmp);
|
||||
//日表
|
||||
rMpEventDetailService.handleDay(calculatedParam);
|
||||
} else if (tag.equalsIgnoreCase("r_mp_event_detail_m")) {
|
||||
isAccess(bindCmp);
|
||||
//数据补招不执行非日表算法
|
||||
if (!calculatedParam.isRepair()) {
|
||||
//月表
|
||||
@@ -66,6 +71,4 @@ public class MeasurementExecutor extends BaseExecutor {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.njcn.prepare.harmonic.pojo.mysql.RMpEventDetailPO;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailDService;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailMService;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -106,7 +106,6 @@ public class RMpMonitorEvaluateDServiceImpl extends MppServiceImpl<RMpMonitorEva
|
||||
*/
|
||||
@Override
|
||||
public void handleDay(CalculatedParam calculatedParam) {
|
||||
// System.out.println(1/0);
|
||||
//1、取出规则
|
||||
List<PmsAbnormalRules> pmsAbnormalRules = pmsAbnormalRulesMapper.selectList(null);
|
||||
String beginDay =LocalDateTimeUtil.format(LocalDateTimeUtil.beginOfDay(LocalDateTimeUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)),DatePattern.NORM_DATETIME_PATTERN);
|
||||
|
||||
Reference in New Issue
Block a user