|
@@ -1,10 +1,12 @@
|
|
|
package com.sd.business.flow;
|
|
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
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.apply.po.ApplyBuy;
|
|
|
import com.sd.business.entity.apply.po.ApplyBuyBom;
|
|
|
import com.sd.business.entity.purchase.dto.PurchaseDto;
|
|
@@ -19,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -51,22 +54,12 @@ public class PurchaseFlow extends FlowDelegate {
|
|
|
purchase.setFlowStatus(PurchaseEnums.IN_PROGRESS.getKey());
|
|
|
purchase.setFlowId(flowId);
|
|
|
|
|
|
- // 获取到采购bom表的数据
|
|
|
- List<PurchaseBom> purchaseBomList = purchase.getPurchaseBomList();
|
|
|
-
|
|
|
- // 添加采购bom表的数据
|
|
|
- purchaseBomList.forEach(purchaseBom -> purchaseBom.setPurchaseId(purchase.getId()));
|
|
|
-
|
|
|
- // 判断是否存在采购ID,如果存在说明已经暂存
|
|
|
- if (ObjectUtil.isNotEmpty(purchase.getId())) {
|
|
|
- purchaseBomService.editLinked(purchaseBomList, PurchaseBom::getPurchaseId, purchase.getId());
|
|
|
+ if (purchase.getId() == null) {
|
|
|
+ purchaseService.add(purchase);
|
|
|
} else {
|
|
|
- purchaseBomService.saveBatch(purchaseBomList);
|
|
|
+ purchaseService.edit(purchase);
|
|
|
}
|
|
|
|
|
|
- // 更新或修改
|
|
|
- purchaseService.saveOrUpdate(purchase);
|
|
|
-
|
|
|
return purchase.getId();
|
|
|
}
|
|
|
|
|
@@ -100,19 +93,31 @@ public class PurchaseFlow extends FlowDelegate {
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 流程驳回
|
|
|
- * @param flowId
|
|
|
- * @param businessId
|
|
|
- * @param flowStatus
|
|
|
- */
|
|
|
+ @Override
|
|
|
+ public void returnToOriginator(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
+ purchaseService.update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, businessId)
|
|
|
+ .set(Purchase::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) {
|
|
|
+ PurchaseDto purchase = submitData.toJavaObject(PurchaseDto.class);
|
|
|
+ purchase.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
+ purchaseService.edit(purchase);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
- Purchase purchase = purchaseService.getById(businessId);
|
|
|
- purchase.setFlowStatus(PurchaseEnums.REJECTED.getKey());
|
|
|
- purchase.setFlowId(flowId);
|
|
|
- //修改采购暂存表的数据
|
|
|
- purchaseService.updateById(purchase);
|
|
|
+ purchaseService.update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, businessId)
|
|
|
+ .set(Purchase::getFlowStatus, flowStatus.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
}
|