|
@@ -1,9 +1,6 @@
|
|
|
package com.sd.business.flow;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
|
import com.fjhx.flow.core.FlowThreadLocalUtil;
|
|
|
import com.fjhx.flow.enums.FlowStatusEnum;
|
|
@@ -13,16 +10,11 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.sd.business.entity.apply.dto.ApplyBuyDto;
|
|
|
import com.sd.business.entity.apply.po.ApplyBuy;
|
|
|
import com.sd.business.entity.apply.po.ApplyBuyBom;
|
|
|
-import com.sd.business.entity.apply.vo.ApplyBuyBomVo;
|
|
|
-import com.sd.business.service.apply.ApplyBuyBomService;
|
|
|
import com.sd.business.service.apply.ApplyBuyService;
|
|
|
-import com.sd.business.util.CodeEnum;
|
|
|
import com.sd.framework.util.Assert;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -35,9 +27,6 @@ public class ApplyBuyFlow extends FlowDelegate {
|
|
|
@Autowired
|
|
|
private ApplyBuyService applyBuyService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ApplyBuyBomService applyBuyBomService;
|
|
|
-
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
|
return "apply_buy";
|
|
@@ -49,24 +38,16 @@ public class ApplyBuyFlow extends FlowDelegate {
|
|
|
ApplyBuyDto applyBuyDto = submitData.toJavaObject(ApplyBuyDto.class);
|
|
|
validated(applyBuyDto);
|
|
|
|
|
|
- Long applyBuyId = IdWorker.getId();
|
|
|
-
|
|
|
- applyBuyDto.setId(applyBuyId);
|
|
|
- applyBuyDto.setCode(CodeEnum.APPLY_BUY_CODE.getCode());
|
|
|
applyBuyDto.setFlowId(flowId);
|
|
|
applyBuyDto.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
|
|
|
- List<ApplyBuyBomVo> applyBuyBomVoList = applyBuyDto.getApplyBuyBomVoList();
|
|
|
- List<ApplyBuyBom> applyBuyBomList = BeanUtil.copyToList(applyBuyBomVoList, ApplyBuyBom.class);
|
|
|
- for (ApplyBuyBom applyBuyBom : applyBuyBomList) {
|
|
|
- applyBuyBom.setApplyBuyId(applyBuyId);
|
|
|
- applyBuyBom.setPurchaseQuantity(BigDecimal.ZERO);
|
|
|
+ if (applyBuyDto.getId() == null) {
|
|
|
+ applyBuyService.add(applyBuyDto);
|
|
|
+ } else {
|
|
|
+ applyBuyService.edit(applyBuyDto);
|
|
|
}
|
|
|
|
|
|
- applyBuyService.save(applyBuyDto);
|
|
|
- applyBuyBomService.saveBatch(applyBuyBomList);
|
|
|
-
|
|
|
- return applyBuyId;
|
|
|
+ return applyBuyDto.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -79,6 +60,46 @@ public class ApplyBuyFlow extends FlowDelegate {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 流程退回到发起人
|
|
|
+ *
|
|
|
+ * @param flowId 流程id
|
|
|
+ * @param businessId 业务id
|
|
|
+ * @param flowStatus 流程状态枚举
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void returnToOriginator(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ applyBuyService.update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, FlowThreadLocalUtil.getBusinessId())
|
|
|
+ .set(ApplyBuy::getFlowStatus, flowStatus.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程重新发起
|
|
|
+ *
|
|
|
+ * @param flowId 流程id
|
|
|
+ * @param businessId 业务id
|
|
|
+ * @param flowStatus 流程状态枚举
|
|
|
+ * @param submitData 发起参数
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
|
|
|
+ ApplyBuyDto applyBuyDto = submitData.toJavaObject(ApplyBuyDto.class);
|
|
|
+ validated(applyBuyDto);
|
|
|
+ applyBuyDto.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
+ applyBuyService.edit(applyBuyDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程驳回
|
|
|
+ *
|
|
|
+ * @param flowId 流程id
|
|
|
+ * @param businessId 业务id
|
|
|
+ * @param flowStatus 流程状态枚举
|
|
|
+ */
|
|
|
@Override
|
|
|
public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
applyBuyService.update(q -> q
|