Commit 058fd9fc authored by wangyangyang's avatar wangyangyang

创建计划基线

parent c441bf0d
package com.yonde.dcs.plan.core.controller;
import com.yonde.dex.basedata.entity.vo.IdVO;
import org.springframework.stereotype.Controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtPlanBaseLineVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.service.ExtPlanBaseLineService;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dcs.plan.core.controller.shadow.ExtPlanBaseLineControllerShadow;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import java.util.List;
/**
* @description: ExtPlanBaseLine-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-27 11:03:50
**/
* @description: ExtPlanBaseLine-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-27 11:03:50
**/
@Api(tags = "ExtPlanBaseLine管理服务")
@RequestMapping("/ExtPlanBaseLine")
@ResponseBody()
......@@ -28,6 +27,18 @@ import org.springframework.stereotype.Controller;
public class ExtPlanBaseLineController<V extends ExtPlanBaseLineVO, S extends ExtPlanBaseLineService<V>> extends ExtPlanBaseLineControllerShadow<V, S> {
@Autowired
ExtPlanBaseLineService extPlanBaseLineService;
@ApiOperation("创建基线")
@PostMapping(value = "/create/baseline")
public ApiResult createBaseline(@RequestBody ExtPlanBaseLineVO baseLineVO) {
ExtPlanBaseLineVO baseline = extPlanBaseLineService.createBaseline(baseLineVO);
return ApiResult.ok(baseline, "创建基线成功!");
}
}
......@@ -2,6 +2,10 @@ package com.yonde.dcs.plan.core.service;
import com.yonde.dcs.plan.common.vo.ExtPlanBaseLineVO;
import com.yonde.dcs.plan.core.service.shadow.ExtPlanBaseLineServiceShadow;
import com.yonde.dex.basedata.entity.vo.IdVO;
import java.util.List;
/**
* @description: ExtPlanBaseLine-service
* @author: dexadmin
......@@ -10,4 +14,7 @@ import com.yonde.dcs.plan.core.service.shadow.ExtPlanBaseLineServiceShadow;
**/
public interface ExtPlanBaseLineService<V extends ExtPlanBaseLineVO> extends ExtPlanBaseLineServiceShadow<V> {
ExtPlanBaseLineVO createBaseline(ExtPlanBaseLineVO baseLineVO);
}
package com.yonde.dcs.plan.core.service.impl;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.yonde.dcs.plan.common.vo.ExtPlanBaseLineLinkVO;
import com.yonde.dcs.plan.core.service.ExtPlanBaseLineLinkService;
import com.yonde.dcs.plan.core.util.SearchUtil;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.entity.vo.IdOnlyVO;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import com.yonde.dex.version.plugin.core.service.IterationService;
import org.springframework.stereotype.Service;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtPlanBaseLineVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.service.ExtPlanBaseLineService;
import com.yonde.dcs.plan.core.repository.ExtPlanBaseLineRepository;
import com.yonde.dcs.plan.entity.po.ExtPlanBaseLine;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* @description: ExtPlanBaseLine-ServiceImpl
* @author: dexadmin
* @version: V
* @date: 2024-9-27 11:03:50
**/
* @description: ExtPlanBaseLine-ServiceImpl
* @author: dexadmin
* @version: V
* @date: 2024-9-27 11:03:50
**/
@Slf4j
@Service(ExtPlanBaseLineServiceImpl.BEAN_NAME)
public class ExtPlanBaseLineServiceImpl<V extends ExtPlanBaseLineVO> implements ExtPlanBaseLineService<V>{
public class ExtPlanBaseLineServiceImpl<V extends ExtPlanBaseLineVO> implements ExtPlanBaseLineService<V> {
public static final String BEAN_NAME = "extPlanBaseLineServiceImpl";
......@@ -29,6 +41,35 @@ public class ExtPlanBaseLineServiceImpl<V extends ExtPlanBaseLineVO> implements
@Autowired
ExtPlanBaseLineRepository<ExtPlanBaseLine> extPlanBaseLineRepository;
@Autowired
ExtPlanBaseLineLinkService extPlanBaseLineLinkService;
@Override
@Transactional(rollbackFor = Exception.class)
public ExtPlanBaseLineVO createBaseline(ExtPlanBaseLineVO baseLineVO) {
Long dxContextId = baseLineVO.getDxContextId();
SearchQueryCondition queryCondition = SearchUtil.buildQuery("dxContextId", SearchItem.Operator.EQ, dxContextId);
String beanName = StrUtil.lowerFirst(baseLineVO.getPlanType()) + "ServiceImpl";
IterationService iterationService = (IterationService) ApplicationContextUtil.getBean(beanName);
DxPageImpl recursion = iterationService.findRecursion(queryCondition);
if (recursion.getTotalElements() != 0) {
List<IdVO> result = recursion.getContent();
List<ExtPlanBaseLineLinkVO> lineLinkVOS = new ArrayList<>();
result.forEach(idVO -> {
idVO.setOperator(OperatorType.ADD);
idVO.setId(null);
ReflectUtil.setFieldValue(idVO, "dxContextId", null);
ExtPlanBaseLineLinkVO lineLinkVO = new ExtPlanBaseLineLinkVO();
lineLinkVO.setOperator(OperatorType.ADD);
lineLinkVO.setTarget((IdOnlyVO) idVO);
lineLinkVOS.add(lineLinkVO);
});
baseLineVO.setExtPlanBaseLineLinks(lineLinkVOS);
}
baseLineVO.setOperator(OperatorType.ADD);
return this.saveRecursion((V) baseLineVO);
}
}
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