|
@@ -1,88 +0,0 @@
|
|
-package com.fjhx.purchase.flow;
|
|
|
|
-
|
|
|
|
-import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
-import com.fjhx.common.constant.SourceConstant;
|
|
|
|
-import com.fjhx.flow.core.FlowDelegate;
|
|
|
|
-import com.fjhx.purchase.entity.purchase.enums.PurchaseDetailStatusEnum;
|
|
|
|
-import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
|
|
-import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
|
|
-import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
|
|
|
|
-import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
|
|
-import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
|
-import com.fjhx.purchase.util.code.CodeEnum;
|
|
|
|
-import com.obs.services.internal.ServiceException;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
-
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 采购流程
|
|
|
|
- * @Author:caozj
|
|
|
|
- * @DATE:2023/4/3 17:38
|
|
|
|
- */
|
|
|
|
-@DS(SourceConstant.PURCHASE)
|
|
|
|
-@Component
|
|
|
|
-public class PurchaseFlow extends FlowDelegate {
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public String getFlowKey() {
|
|
|
|
- return "purchase_flow";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 发起流程
|
|
|
|
- * @param flowId 流程ID
|
|
|
|
- * @param submitData 申购数据
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public Long start(Long flowId, JSONObject submitData) {
|
|
|
|
- PurchaseService purchaseService = SpringUtil.getBean(PurchaseService.class);
|
|
|
|
- PurchaseDetailService purchaseDetailService = SpringUtil.getBean(PurchaseDetailService.class);
|
|
|
|
- Purchase purchase = submitData.toJavaObject(Purchase.class);
|
|
|
|
- purchase.setCode(CodeEnum.PURCHASE.getCode());
|
|
|
|
- purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
|
|
|
|
- purchaseService.save(purchase);
|
|
|
|
- List<PurchaseDetail> purchaseDetailList = purchase.getPurchaseDetailList();
|
|
|
|
- if(CollectionUtils.isNotEmpty(purchaseDetailList)){
|
|
|
|
- for(PurchaseDetail s : purchaseDetailList){
|
|
|
|
- s.setPurchaseId(purchase.getId());
|
|
|
|
- }
|
|
|
|
- purchaseDetailService.saveBatch(purchaseDetailList);
|
|
|
|
- }
|
|
|
|
- return purchase.getId();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 结束流程
|
|
|
|
- * @param flowId 流程ID
|
|
|
|
- * @param businessId 业务ID
|
|
|
|
- * @param submitData 数据
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
|
- PurchaseService purchaseService = SpringUtil.getBean(PurchaseService.class);
|
|
|
|
- PurchaseDetailService purchaseDetailService = SpringUtil.getBean(PurchaseDetailService.class);
|
|
|
|
- //通过业务ID查询申购数据
|
|
|
|
- Purchase purchase = purchaseService.getById(businessId);
|
|
|
|
- if(ObjectUtils.isEmpty(purchase)){
|
|
|
|
- throw new ServiceException("采购单不存在");
|
|
|
|
- }
|
|
|
|
- //修改采购状态为审批通过
|
|
|
|
- purchase.setPurchaseStatus(PurchaseStatusEnum.PASS.getKey());
|
|
|
|
- purchase.setApprovedDate(new Date());
|
|
|
|
- purchaseService.updateById(purchase);
|
|
|
|
- //修改采购明细为待采购
|
|
|
|
- PurchaseDetail detail = new PurchaseDetail();
|
|
|
|
- detail.setStatus(PurchaseDetailStatusEnum.PASS.getKey());
|
|
|
|
- purchaseDetailService.update(detail,Wrappers.<PurchaseDetail>query()
|
|
|
|
- .lambda().eq(PurchaseDetail::getPurchaseId,purchase.getId()));
|
|
|
|
- }
|
|
|
|
-}
|
|
|