|
|
|
@ -1,19 +1,35 @@
|
|
|
|
|
package cn.iocoder.yudao.module.bpm.service.quotationsheetbidding;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetUpdateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingCreateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingExportReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingUpdateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.service.quotationsheet.QuotationSheetService;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.enums.QuotationSheetBiddingEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.tenant.TenantApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.tenant.dto.TenantDTO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
@ -22,6 +38,7 @@ import cn.iocoder.yudao.module.bpm.convert.quotationsheetbidding.QuotationSheetB
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.dal.mysql.quotationsheetbidding.QuotationSheetBiddingMapper;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
|
|
|
|
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -33,6 +50,8 @@ import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
|
|
|
|
|
@Validated
|
|
|
|
|
public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<QuotationSheetBiddingMapper, QuotationSheetBiddingDO> implements QuotationSheetBiddingService {
|
|
|
|
|
|
|
|
|
|
//报价单中标流程
|
|
|
|
|
public static final String BIDDING_KEY = "quotation_sheet_bidding";
|
|
|
|
|
@Resource
|
|
|
|
|
private QuotationSheetBiddingMapper quotationSheetBiddingMapper;
|
|
|
|
|
|
|
|
|
@ -42,6 +61,22 @@ public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<Quotati
|
|
|
|
|
@Resource
|
|
|
|
|
private TenantApi tenantApi;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private BpmProcessInstanceService processInstanceService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
@Lazy
|
|
|
|
|
private QuotationSheetService quotationSheetService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private BpmProcessInstanceApi processInstanceApi;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DeptApi deptApi;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long createQuotationSheetBidding(QuotationSheetBiddingCreateReqVO createReqVO) {
|
|
|
|
|
// 插入
|
|
|
|
@ -115,4 +150,75 @@ public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<Quotati
|
|
|
|
|
return quotationSheetBiddingMapper.selectList(exportReqVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void processInstanceCallBack(long id, Integer result) {
|
|
|
|
|
QuotationSheetDO quotationShe = quotationSheetService.getById(id);
|
|
|
|
|
ProcessInstance proces = processInstanceService.getProcessInstance(quotationShe.getProcessId());
|
|
|
|
|
List<Long> biddingList = null;
|
|
|
|
|
try {
|
|
|
|
|
//获取中标报价数据
|
|
|
|
|
biddingList = (List<Long>) proces.getProcessVariables().get("bidding");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
biddingList = new ArrayList<>();
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BpmProcessInstanceResultEnum.APPROVE.getResult().equals(result)) {
|
|
|
|
|
//通过
|
|
|
|
|
if (biddingList!=null){
|
|
|
|
|
biddingList.forEach(biddingId->{
|
|
|
|
|
QuotationSheetBiddingDO quotationSheetBiddingDO = getById(biddingId);
|
|
|
|
|
//中标赋值
|
|
|
|
|
quotationSheetBiddingDO.setIsWin(1);
|
|
|
|
|
this.updateById(quotationSheetBiddingDO);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quotationShe.setBiddingStatus(QuotationSheetBiddingEnum.CONFIRM.getValue());
|
|
|
|
|
quotationSheetService.updateById(quotationShe);
|
|
|
|
|
} else if (BpmProcessInstanceResultEnum.REJECT.getResult().equals(result)) {
|
|
|
|
|
//驳回
|
|
|
|
|
quotationShe.setBiddingStatus(QuotationSheetBiddingEnum.ABANDON.getValue());
|
|
|
|
|
quotationSheetService.updateById(quotationShe);
|
|
|
|
|
}else if (BpmProcessInstanceResultEnum.CANCEL.getResult().equals(result)) {
|
|
|
|
|
//驳回
|
|
|
|
|
quotationShe.setBiddingStatus(QuotationSheetBiddingEnum.NO_CONFIRM.getValue());
|
|
|
|
|
quotationSheetService.updateById(quotationShe);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String approvalBidding(QuotationSheetUpdateReqVO pageVO) {
|
|
|
|
|
QuotationSheetDO questionDO = quotationSheetService.getById(pageVO.getId());
|
|
|
|
|
//发起实例
|
|
|
|
|
if (questionDO.getBiddingStatus().equals(QuotationSheetBiddingEnum.PRIMED_FOR_ACTION.getValue())) {
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
variables.put("bidding", pageVO.getApprovalBiddingIdList());
|
|
|
|
|
LoginUser loginUser = getLoginUser();
|
|
|
|
|
String processInstanceId = processInstanceApi.createProcessInstance(questionDO.getApplicant(),
|
|
|
|
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(BIDDING_KEY)
|
|
|
|
|
.setVariables(variables).setBusinessKey(String.valueOf(questionDO.getId())));
|
|
|
|
|
quotationSheetService.updateById(new QuotationSheetDO().setId(questionDO.getId()).setProcessId(processInstanceId).setUserId(loginUser.getId()));
|
|
|
|
|
return processInstanceId;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setNickNameField(List<QuotationSheetDO> list) {
|
|
|
|
|
List<Long> userIds = list.stream().map(QuotationSheetDO::getUserId).distinct().collect(Collectors.toList());
|
|
|
|
|
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(AdminUserRespDTO::getId, user -> user.getNickname()));
|
|
|
|
|
for (QuotationSheetDO quotationSheetDO : list) {
|
|
|
|
|
quotationSheetDO.setNickname(userMap.get(quotationSheetDO.getApplicant()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setDeptNameField(List<QuotationSheetDO> toList) {
|
|
|
|
|
List<Long> deptIds = toList.stream().map(QuotationSheetDO::getDeptId).distinct().collect(Collectors.toList());
|
|
|
|
|
Map<Long, String> deptMap = deptApi.getDeptList(deptIds).stream().collect(Collectors.toMap(DeptRespDTO::getId, dept -> dept.getName()));
|
|
|
|
|
for (QuotationSheetDO quotationSheetDO : toList) {
|
|
|
|
|
quotationSheetDO.setDeptName(deptMap.get(quotationSheetDO.getDeptId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|