代码调整
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.njcn.prepare;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.util.StrUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.prepare.bo.BaseParam;
|
||||
import com.njcn.prepare.bo.CalculatedParam;
|
||||
import com.njcn.prepare.harmonic.enums.PrepareResponseEnum;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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 io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年11月01日 10:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "监测点算法执行链")
|
||||
@RestController
|
||||
@RequestMapping("/executor")
|
||||
@RequiredArgsConstructor
|
||||
public class ExecutionCenter extends BaseController {
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
@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节点标签集合必须为非空,否则提示---无可执行节点
|
||||
* 2、补招标识为true时,起始日期&截止日期不可为空
|
||||
* 3、算法需要的索引集合
|
||||
* @author hongawen
|
||||
* @date 2023/11/3 11:36
|
||||
* @param baseParam 执行的基础参数
|
||||
*/
|
||||
private CalculatedParam judgeExecuteParam(BaseParam baseParam) {
|
||||
CalculatedParam calculatedParam = new CalculatedParam();
|
||||
|
||||
if (!baseParam.isFullChain() && CollectionUtil.isEmpty(baseParam.getTagNames())) {
|
||||
throw new BusinessException(PrepareResponseEnum.NO_EXECUTOR_NODE);
|
||||
}
|
||||
|
||||
if (baseParam.isRepair() && StrUtil.isAllNotEmpty(baseParam.getBeginTime(), baseParam.getEndTime())) {
|
||||
throw new BusinessException(PrepareResponseEnum.NO_REPAIR_DATE);
|
||||
}
|
||||
|
||||
BeanUtil.copyProperties(baseParam, calculatedParam);
|
||||
return calculatedParam;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user