mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-08 14:44:57 +08:00
[fix] 优化预算管理功能
This commit is contained in:
parent
98f295be74
commit
67dcab5a0f
@ -1,11 +1,15 @@
|
|||||||
package cn.iocoder.yudao.module.pms.service.budget;
|
package cn.iocoder.yudao.module.pms.service.budget;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.cms.api.contract.ContractApi;
|
import cn.iocoder.yudao.module.cms.api.contract.ContractApi;
|
||||||
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractDTO;
|
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractDTO;
|
||||||
import cn.iocoder.yudao.module.cms.api.outscontract.OutsContractApi;
|
import cn.iocoder.yudao.module.cms.api.outscontract.OutsContractApi;
|
||||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDetailDO;
|
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDetailDO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
||||||
import cn.iocoder.yudao.module.pms.dal.dataobject.projecttracking.ProjectTrackingDO;
|
import cn.iocoder.yudao.module.pms.dal.dataobject.projecttracking.ProjectTrackingDO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.mysql.budgethistory.BudgetHistoryMapper;
|
||||||
import cn.iocoder.yudao.module.pms.service.projecttracking.ProjectTrackingService;
|
import cn.iocoder.yudao.module.pms.service.projecttracking.ProjectTrackingService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -36,6 +40,17 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_E
|
|||||||
@Validated
|
@Validated
|
||||||
public class BudgetServiceImpl implements BudgetService {
|
public class BudgetServiceImpl implements BudgetService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预算管理流程定义
|
||||||
|
*/
|
||||||
|
public static final String PROCESS_KEY = "budget_init";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本
|
||||||
|
*/
|
||||||
|
public static String VERSION = "1";
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BudgetMapper budgetMapper;
|
private BudgetMapper budgetMapper;
|
||||||
|
|
||||||
@ -51,6 +66,13 @@ public class BudgetServiceImpl implements BudgetService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectTrackingService projectTrackingService;
|
private ProjectTrackingService projectTrackingService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmProcessInstanceApi processInstanceApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BudgetHistoryMapper budgetHistoryMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createBudget(Long loginUserId, BudgetSaveReqVO createReqVO) {
|
public Long createBudget(Long loginUserId, BudgetSaveReqVO createReqVO) {
|
||||||
|
|
||||||
@ -76,6 +98,30 @@ public class BudgetServiceImpl implements BudgetService {
|
|||||||
budget.setCreator(userName);
|
budget.setCreator(userName);
|
||||||
budget.setUpdater(userName);
|
budget.setUpdater(userName);
|
||||||
budgetMapper.insert(budget);
|
budgetMapper.insert(budget);
|
||||||
|
|
||||||
|
Long budgetId = budget.getId();
|
||||||
|
BudgetHistoryDO budgetHistory = BeanUtils.toBean(budget, BudgetHistoryDO.class);
|
||||||
|
// 启动流程,写入历史预算 todo
|
||||||
|
if (createReqVO.getId() == null) {
|
||||||
|
String processInstanceId = processInstanceApi.createProcessInstance(loginUserId,
|
||||||
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
|
.setBusinessKey(String.valueOf(budgetId)));
|
||||||
|
|
||||||
|
// 写入工作流编号
|
||||||
|
// budgetHistory.setProcessInstanceId(processInstanceId);
|
||||||
|
// budgetHistory.setBudgetId(budgetId);
|
||||||
|
budgetHistoryMapper.updateById(budgetHistory.setBudgetId(budgetId).setProcessInstanceId(processInstanceId));
|
||||||
|
|
||||||
|
Long count = budgetHistoryMapper.selectCount("project_id", projectId);
|
||||||
|
if (count < 1) {
|
||||||
|
budgetHistory.setVersion(VERSION);
|
||||||
|
} else {
|
||||||
|
budgetHistory.setVersion(String.valueOf(count + 1));
|
||||||
|
}
|
||||||
|
budgetHistory.setProcessStatus("0");
|
||||||
|
budgetHistoryMapper.insert(budgetHistory);
|
||||||
|
}
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return budget.getId();
|
return budget.getId();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user