-中标回调成功

new
Agoni 1 year ago
parent 5a0c2b0fc9
commit 1fb7bce6e9

@ -1,10 +1,14 @@
package cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet; package cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.*; import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.*;
import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService; import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService;
import cn.iocoder.yudao.module.bpm.service.quotationsheetbidding.QuotationSheetBiddingService;
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
import cn.iocoder.yudao.module.bs.enums.QuotationSheetEnum; import cn.iocoder.yudao.module.bs.enums.QuotationSheetEnum;
@ -48,6 +52,9 @@ public class QuotationSheetController {
@Resource @Resource
private ExpenseApplyTripService expenseApplyTripService; private ExpenseApplyTripService expenseApplyTripService;
@Resource
private QuotationSheetBiddingService quotationSheetBiddingService;
@Resource @Resource
@Lazy // 解决循环依赖 @Lazy // 解决循环依赖
private BpmTaskService taskService; private BpmTaskService taskService;
@ -96,6 +103,27 @@ public class QuotationSheetController {
return success(sheetRespVO); return success(sheetRespVO);
} }
@GetMapping("/getBidding")
@Operation(summary = "获得中标报价单详情")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('bs:quotation-sheet:query')")
public CommonResult<QuotationSheetRespVO> getBidding(@RequestParam("id") Long id) {
QuotationSheetDO quotationSheet = quotationSheetService.getQuotationSheet(id);
if (quotationSheet.getStatus().equals(QuotationSheetEnum.NOSUBMIT.getValue())) {
LambdaQueryWrapperX<ExpenseApplyTripDO> queryWrapper = new LambdaQueryWrapperX<>();
queryWrapper.eq(ExpenseApplyTripDO::getApplyId, quotationSheet.getId());
List<ExpenseApplyTripDO> list = expenseApplyTripService.list(queryWrapper);
quotationSheet.setExpenseApplyTrips(list);
}
quotationSheetBiddingService.setNickNameField(CollUtil.toList(quotationSheet));
quotationSheetBiddingService.setDeptNameField(CollUtil.toList(quotationSheet));
taskService.handleApprovalAuthority2(CollUtil.toList(quotationSheet));
QuotationSheetRespVO sheetRespVO =QuotationSheetConvert.INSTANCE.convert(quotationSheet);
return success(sheetRespVO);
}
@GetMapping("/list") @GetMapping("/list")
@Operation(summary = "获得报价单列表") @Operation(summary = "获得报价单列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@ -105,6 +133,8 @@ public class QuotationSheetController {
return success(QuotationSheetConvert.INSTANCE.convertList(list)); return success(QuotationSheetConvert.INSTANCE.convertList(list));
} }
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得报价单分页") @Operation(summary = "获得报价单分页")
@PreAuthorize("@ss.hasPermission('bs:quotation-sheet:query')") @PreAuthorize("@ss.hasPermission('bs:quotation-sheet:query')")
@ -114,7 +144,6 @@ public class QuotationSheetController {
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
quotationSheetService.setNickNameField(list); quotationSheetService.setNickNameField(list);
taskService.handleApprovalAuthority(list); taskService.handleApprovalAuthority(list);
} }
return success(QuotationSheetConvert.INSTANCE.convertPage(pageResult)); return success(QuotationSheetConvert.INSTANCE.convertPage(pageResult));
} }
@ -137,6 +166,11 @@ public class QuotationSheetController {
@PreAuthorize("@ss.hasPermission('bs:quotation-sheet:query')") @PreAuthorize("@ss.hasPermission('bs:quotation-sheet:query')")
public CommonResult<PageResult<QuotationSheetRespVO>> pageBidding(@Valid QuotationSheetPageReqVO pageVO) { public CommonResult<PageResult<QuotationSheetRespVO>> pageBidding(@Valid QuotationSheetPageReqVO pageVO) {
PageResult<QuotationSheetDO> pageResult = quotationSheetService.getQuotationSheetPageBidding(pageVO); PageResult<QuotationSheetDO> pageResult = quotationSheetService.getQuotationSheetPageBidding(pageVO);
List<QuotationSheetDO> list = pageResult.getList();
if (CollUtil.isNotEmpty(list)) {
quotationSheetService.setNickNameField(list);
taskService.handleApprovalAuthority(list);
}
return success(QuotationSheetConvert.INSTANCE.convertPage(pageResult)); return success(QuotationSheetConvert.INSTANCE.convertPage(pageResult));
} }
@ -145,7 +179,7 @@ public class QuotationSheetController {
@Operation(summary = "中标审批发起接口") @Operation(summary = "中标审批发起接口")
// @PreAuthorize("@ss.hasPermission('bs:quotation-sheet:approvalBidding')") // @PreAuthorize("@ss.hasPermission('bs:quotation-sheet:approvalBidding')")
public CommonResult<String> approvalBidding(@RequestBody QuotationSheetUpdateReqVO pageVO) { public CommonResult<String> approvalBidding(@RequestBody QuotationSheetUpdateReqVO pageVO) {
return success(quotationSheetService.approvalBidding(pageVO)); return success(quotationSheetBiddingService.approvalBidding(pageVO));
} }
@PutMapping("/releaseFlag") @PutMapping("/releaseFlag")

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.bpm.framework.bpm.core.event; package cn.iocoder.yudao.module.bpm.framework.bpm.core.event;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
/** /**
@ -29,6 +30,6 @@ public abstract class BpmProcessInstanceResultEventListener
* *
* @param event * @param event
*/ */
protected abstract void onEvent(BpmProcessInstanceResultEvent event); protected abstract void onEvent(BpmProcessInstanceResultEvent event) ;
} }

@ -4,6 +4,9 @@ import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceRe
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener; import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener;
import cn.iocoder.yudao.module.bpm.service.quotationsheet.QuotationSheetService; import cn.iocoder.yudao.module.bpm.service.quotationsheet.QuotationSheetService;
import cn.iocoder.yudao.module.bpm.service.quotationsheet.QuotationSheetServiceImpl; import cn.iocoder.yudao.module.bpm.service.quotationsheet.QuotationSheetServiceImpl;
import cn.iocoder.yudao.module.bpm.service.quotationsheetbidding.QuotationSheetBiddingService;
import cn.iocoder.yudao.module.bpm.service.quotationsheetbidding.QuotationSheetBiddingServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -16,15 +19,15 @@ import javax.annotation.Resource;
@Component @Component
public class QuotationSheetBiddingResultListener extends BpmProcessInstanceResultEventListener{ public class QuotationSheetBiddingResultListener extends BpmProcessInstanceResultEventListener{
@Resource @Resource
private QuotationSheetService quotationSheetService; private QuotationSheetBiddingService quotationSheetBiddingService;
@Override @Override
protected String getProcessDefinitionKey() { protected String getProcessDefinitionKey() {
return QuotationSheetServiceImpl.BIDDING_KEY; return QuotationSheetBiddingServiceImpl.BIDDING_KEY;
} }
@Override @Override
protected void onEvent(BpmProcessInstanceResultEvent event) { protected void onEvent(BpmProcessInstanceResultEvent event) {
quotationSheetService.processInstanceCallBack2(Long.parseLong(event.getBusinessKey()), event.getResult()); quotationSheetBiddingService.processInstanceCallBack(Long.parseLong(event.getBusinessKey()), event.getResult());
} }
} }

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationS
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetUpdateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetUpdateReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO; import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.yulichang.base.MPJBaseService; import com.github.yulichang.base.MPJBaseService;
import liquibase.pro.packaged.S; import liquibase.pro.packaged.S;
@ -24,8 +25,7 @@ public interface QuotationSheetService extends MPJBaseService<QuotationSheetDO>
//报价单流程ID //报价单流程ID
public static final String PROCESS_KEY = "quotation_sheet_seq"; public static final String PROCESS_KEY = "quotation_sheet_seq";
//报价单中标流程
public static final String BIDDING_KEY = "quotation_sheet_bidding";
/** /**
* *
* *
@ -88,12 +88,7 @@ public interface QuotationSheetService extends MPJBaseService<QuotationSheetDO>
*/ */
PageResult<QuotationSheetDO> getQuotationSheetPageBidding(QuotationSheetPageReqVO pageVO); PageResult<QuotationSheetDO> getQuotationSheetPageBidding(QuotationSheetPageReqVO pageVO);
/**
*
* @param pageVO
* @return
*/
String approvalBidding(QuotationSheetUpdateReqVO pageVO);
/** /**
* *
@ -109,12 +104,6 @@ public interface QuotationSheetService extends MPJBaseService<QuotationSheetDO>
*/ */
void processInstanceCallBack(long id, Integer result); void processInstanceCallBack(long id, Integer result);
/**
*
* @param id
* @param result
*/
void processInstanceCallBack2(long id, Integer result);
void setNickNameField(List<QuotationSheetDO> list); void setNickNameField(List<QuotationSheetDO> list);

@ -29,12 +29,16 @@ 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.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import liquibase.pro.packaged.S;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -81,6 +85,7 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
private AdminUserApi adminUserApi; private AdminUserApi adminUserApi;
@Resource @Resource
@Lazy
private QuotationSheetBiddingService quotationSheetBiddingService; private QuotationSheetBiddingService quotationSheetBiddingService;
@Resource @Resource
@ -92,8 +97,7 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
@Resource @Resource
private TenantApi tenantApi; private TenantApi tenantApi;
@Resource
private BpmProcessInstanceService processInstanceService;
@Override @Override
public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) { public Long createQuotationSheet(QuotationSheetCreateReqVO createReqVO) {
@ -107,7 +111,7 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
quotationSheet.setApplicant(loginUser.getId()); quotationSheet.setApplicant(loginUser.getId());
quotationSheet.setQuotationStatus(1); quotationSheet.setQuotationStatus(1);
quotationSheet.setReleaseStatus(1); quotationSheet.setReleaseStatus(1);
quotationSheet.setBiddingStatus(QuotationSheetBiddingEnum.NO_CONFIRM.getValue()); quotationSheet.setBiddingStatus(QuotationSheetBiddingEnum.PRIMED_FOR_ACTION.getValue());
quotationSheet.setStatus("0"); quotationSheet.setStatus("0");
saveOrUpdate(quotationSheet); saveOrUpdate(quotationSheet);
if (createReqVO.getQuotationDetails().size() > 0){ if (createReqVO.getQuotationDetails().size() > 0){
@ -446,24 +450,7 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
return sheetDOPageResult; return sheetDOPageResult;
} }
@Override
public String approvalBidding(QuotationSheetUpdateReqVO pageVO) {
QuotationSheetDO questionDO = this.getById(pageVO.getId());
//发起实例
if (questionDO.getBiddingStatus().equals(QuotationSheetBiddingEnum.PRIMED_FOR_ACTION.getValue())) {
Map<String, Object> variables = new HashMap<>();
variables.put("bidding", JSON.toJSONString(pageVO.getQuotationSheetBiddingDOList()));
//variables.put("name", quotationSheet.getProductName());
// variables.put("number",quotationSheet.getNumber());
// variables.put("deptId", quotationSheet.getDeptId());
String processInstanceId = processInstanceApi.createProcessInstance(questionDO.getApplicant(),
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
.setVariables(variables).setBusinessKey(String.valueOf(questionDO.getId())));
updateById(new QuotationSheetDO().setId(questionDO.getId()).setProcessId(processInstanceId));
return processInstanceId;
}
return null;
}
@Override @Override
public PageResult<QuotationSheetDO> tendereeQuery(QuotationSheetPageReqVO pageVO) { public PageResult<QuotationSheetDO> tendereeQuery(QuotationSheetPageReqVO pageVO) {
@ -501,36 +488,8 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
} }
} }
@Override
public void processInstanceCallBack2( long id, Integer result) {
QuotationSheetDO quotationShe = getById(id);
ProcessInstance proces = processInstanceService.getProcessInstance(quotationShe.getProcessId());
// String ts= (String) ;
/* QuotationSheetBiddingDO quotationSheetBiddingDO = JsonUtil.parse(JsonUtil.toJson(proces.getProcessVariables().get("bidding")), QuotationSheetBiddingDO.class);
JSONArray jsonObject = JSON.parseObject(result1).getJSONArray("list")*/
System.out.println(">>>>>>>>"+proces.getProcessVariables().get("bidding"));
if (BpmProcessInstanceResultEnum.APPROVE.getResult().equals(result)) {
//通过
quotationShe.setBiddingStatus(QuotationSheetBiddingEnum.CONFIRM.getValue());
updateById(quotationShe);
} else if (BpmProcessInstanceResultEnum.REJECT.getResult().equals(result)) {
//驳回
quotationShe.setBiddingStatus(QuotationSheetBiddingEnum.ABANDON.getValue());
updateById(quotationShe);
}else if (BpmProcessInstanceResultEnum.CANCEL.getResult().equals(result)) {
//驳回
quotationShe.setBiddingStatus(QuotationSheetBiddingEnum.NO_CONFIRM.getValue());
updateById(quotationShe);
}
}
@Override @Override
public void setNickNameField(List<QuotationSheetDO> list) { public void setNickNameField(List<QuotationSheetDO> list) {
List<Long> userIds = list.stream().map(QuotationSheetDO::getApplicant).distinct().collect(Collectors.toList()); List<Long> userIds = list.stream().map(QuotationSheetDO::getApplicant).distinct().collect(Collectors.toList());

@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.bpm.service.quotationsheetbidding;
import java.util.*; import java.util.*;
import javax.validation.*; import javax.validation.*;
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.QuotationSheetBiddingCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingExportReqVO; 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.QuotationSheetBiddingPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingUpdateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingUpdateReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO; import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.github.yulichang.base.MPJBaseService; import com.github.yulichang.base.MPJBaseService;
@ -72,4 +74,23 @@ public interface QuotationSheetBiddingService extends MPJBaseService<QuotationSh
*/ */
List<QuotationSheetBiddingDO> getQuotationSheetBiddingList(QuotationSheetBiddingExportReqVO exportReqVO); List<QuotationSheetBiddingDO> getQuotationSheetBiddingList(QuotationSheetBiddingExportReqVO exportReqVO);
/**
*
* @param id
* @param result
*/
void processInstanceCallBack(long id, Integer result);
/**
*
* @param pageVO
* @return
*/
String approvalBidding(QuotationSheetUpdateReqVO pageVO);
void setNickNameField(List<QuotationSheetDO> list);
void setDeptNameField(List<QuotationSheetDO> toList);
} }

@ -1,19 +1,35 @@
package cn.iocoder.yudao.module.bpm.service.quotationsheetbidding; 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.QuotationSheetBiddingCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingExportReqVO; 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.QuotationSheetBiddingPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheetbidding.vo.QuotationSheetBiddingUpdateReqVO; 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.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.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.TenantApi;
import cn.iocoder.yudao.module.system.api.tenant.dto.TenantDTO; 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 com.github.yulichang.base.MPJBaseServiceImpl;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO; import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; 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 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.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.*; import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
/** /**
@ -33,6 +50,8 @@ import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
@Validated @Validated
public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<QuotationSheetBiddingMapper, QuotationSheetBiddingDO> implements QuotationSheetBiddingService { public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<QuotationSheetBiddingMapper, QuotationSheetBiddingDO> implements QuotationSheetBiddingService {
//报价单中标流程
public static final String BIDDING_KEY = "quotation_sheet_bidding";
@Resource @Resource
private QuotationSheetBiddingMapper quotationSheetBiddingMapper; private QuotationSheetBiddingMapper quotationSheetBiddingMapper;
@ -42,6 +61,22 @@ public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<Quotati
@Resource @Resource
private TenantApi tenantApi; 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 @Override
public Long createQuotationSheetBidding(QuotationSheetBiddingCreateReqVO createReqVO) { public Long createQuotationSheetBidding(QuotationSheetBiddingCreateReqVO createReqVO) {
// 插入 // 插入
@ -115,4 +150,75 @@ public class QuotationSheetBiddingServiceImpl extends MPJBaseServiceImpl<Quotati
return quotationSheetBiddingMapper.selectList(exportReqVO); 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()));
}
}
} }

@ -130,4 +130,6 @@ public interface BpmTaskService {
void updateTaskExtAssign(Task task); void updateTaskExtAssign(Task task);
<T extends TenantBaseDO> List<T> handleApprovalAuthority(List<T> list); <T extends TenantBaseDO> List<T> handleApprovalAuthority(List<T> list);
<T extends TenantBaseDO> List<T> handleApprovalAuthority2(List<T> list);
} }

@ -372,4 +372,35 @@ public class BpmTaskServiceImpl implements BpmTaskService {
} }
return list; return list;
} }
@Override
public <T extends TenantBaseDO> List<T> handleApprovalAuthority2(List<T> list) {
if (CollUtil.isNotEmpty(list)) {
for (T t : list) {
Object processInstanceId = ReflectUtil.getFieldValue(t, "processId");
if (processInstanceId != null) {
List<HistoricTaskInstance> taskList = historyService.createHistoricTaskInstanceQuery()
.processInstanceId(Convert.toStr(processInstanceId))
.taskTenantId(TenantContextHolder.getTenantId().toString())
.list();
if (CollUtil.isNotEmpty(taskList)) {
//endtime为null表示未结束的task
List<String> taskIdS = taskList.stream().filter(tk -> tk.getEndTime() == null).map(HistoricTaskInstance::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(taskIdS)) {
LambdaQueryWrapperX<BpmTaskExtDO> wrapperX = new LambdaQueryWrapperX<>();
wrapperX.in(BpmTaskExtDO::getTaskId, taskIdS);
wrapperX.in(BpmTaskExtDO::getAssigneeUserId, SecurityFrameworkUtils.getLoginUserId());
boolean exists = taskExtMapper.exists(wrapperX);
if (exists) {
t.setIsAuthorised(true);
} else {
t.setIsAuthorised(false);
}
}
}
}
}
}
return list;
}
} }

@ -184,6 +184,11 @@ public class QuotationSheetDO extends TenantBaseDO {
*/ */
private String processId; private String processId;
/**
*
*/
private Long userId;
/** /**
* *
*/ */

@ -83,6 +83,8 @@ public class QuotationSheetBiddingDO extends BaseDO {
* *
*/ */
private Integer isWin; private Integer isWin;
/** /**
* *
*/ */

Loading…
Cancel
Save