|
@@ -0,0 +1,86 @@
|
|
|
+package com.sd.business.flow;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fjhx.flow.core.FlowDelegate;
|
|
|
+import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
+import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.sd.business.entity.order.dto.OrderInfoDto;
|
|
|
+import com.sd.business.entity.order.po.OrderInfo;
|
|
|
+import com.sd.business.service.order.OrderService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 发起采购流程
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class OrderFlow extends FlowDelegate {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderService orderService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getFlowKey() {
|
|
|
+ return "order";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long start(Long flowId, JSONObject submitData) {
|
|
|
+
|
|
|
+ OrderInfoDto dto = submitData.toJavaObject(OrderInfoDto.class);
|
|
|
+ dto.setFlowId(flowId);
|
|
|
+ dto.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
+
|
|
|
+ if (dto.getId() == null) {
|
|
|
+ orderService.add(dto);
|
|
|
+ } else {
|
|
|
+ orderService.edit(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ return dto.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
+
|
|
|
+ orderService.update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, businessId)
|
|
|
+ .set(OrderInfo::getFlowStatus, (FlowStatusEnum.PASS.getKey()))
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void returnToOriginator(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ orderService.update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, businessId)
|
|
|
+ .set(OrderInfo::getFlowStatus, flowStatus.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
|
|
|
+ OrderInfoDto dto = submitData.toJavaObject(OrderInfoDto.class);
|
|
|
+ dto.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
+ orderService.edit(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ returnToOriginator(flowId, businessId, flowStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancellation(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ returnToOriginator(flowId, businessId, flowStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|