|
@@ -10,6 +10,8 @@ import com.fjhx.account.entity.account.enums.PaymentTypeEnum;
|
|
|
import com.fjhx.account.entity.account.po.AccountPayment;
|
|
|
import com.fjhx.account.service.account.AccountPaymentService;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
+import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
|
import com.fjhx.flow.enums.FlowStatusEnum;
|
|
@@ -20,8 +22,10 @@ import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
|
import com.fjhx.purchase.service.pay.PayDetailService;
|
|
|
import com.fjhx.purchase.service.pay.PayService;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -65,7 +69,8 @@ public class PayFlow extends FlowDelegate {
|
|
|
|
|
|
/**
|
|
|
* 发起流程
|
|
|
- * @param flowId 流程ID
|
|
|
+ *
|
|
|
+ * @param flowId 流程ID
|
|
|
* @param submitData 采购付款数据
|
|
|
* @return
|
|
|
*/
|
|
@@ -73,24 +78,49 @@ public class PayFlow extends FlowDelegate {
|
|
|
public Long start(Long flowId, JSONObject submitData) {
|
|
|
Pay pay = submitData.toJavaObject(Pay.class);
|
|
|
|
|
|
+ //调用公共代码
|
|
|
+ pay = commStart(pay, 0);
|
|
|
+
|
|
|
+ return pay.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始公共代码抽取
|
|
|
+ *
|
|
|
+ * @param opType 操作类型 0直接发起 1重新发起
|
|
|
+ */
|
|
|
+ private Pay commStart(Pay pay, Integer opType) {
|
|
|
+ if (opType == 1) {
|
|
|
+ Assert.notEmpty(pay.getId(), "采购付款id不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
pay.setStatus(PayStatusEnum.UNDER_REVIEW.getKey());
|
|
|
pay.setCurrency("CNY");//默认币种人民币
|
|
|
- payService.save(pay);
|
|
|
+ payService.saveOrUpdate(pay);
|
|
|
|
|
|
List<PayDetail> payDetailList = pay.getPayDetailList();
|
|
|
if (CollectionUtils.isNotEmpty(payDetailList)) {
|
|
|
+ if (opType == 1) {
|
|
|
+ //先删除被删除的产品
|
|
|
+ payDetailService.editLinked(payDetailList, PayDetail::getPayId, pay.getId());
|
|
|
+ }
|
|
|
+
|
|
|
payDetailList.forEach(item -> item.setPayId(pay.getId()));
|
|
|
- payDetailService.saveBatch(payDetailList);
|
|
|
+ payDetailService.saveOrUpdateBatch(payDetailList);
|
|
|
}
|
|
|
|
|
|
- ObsFileUtil.saveFile(pay.getFileList(), pay.getId());
|
|
|
-
|
|
|
- return pay.getId();
|
|
|
+ if (opType == 1) {
|
|
|
+ ObsFileUtil.editFile(pay.getFileList(), pay.getId());
|
|
|
+ } else {
|
|
|
+ ObsFileUtil.saveFile(pay.getFileList(), pay.getId());
|
|
|
+ }
|
|
|
+ return pay;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 结束流程
|
|
|
- * @param flowId 流程ID
|
|
|
+ *
|
|
|
+ * @param flowId 流程ID
|
|
|
* @param businessId 业务ID
|
|
|
* @param submitData 数据
|
|
|
*/
|
|
@@ -144,7 +174,20 @@ public class PayFlow extends FlowDelegate {
|
|
|
|
|
|
@Override
|
|
|
public void defaultMethod(Long flowId, Long businessId, FlowStatusEnum flowStatusEnum, JSONObject submitData) {
|
|
|
-
|
|
|
+ //重新发起
|
|
|
+ if (FlowStatusEnum.READY_START.equals(flowStatusEnum)) {
|
|
|
+ Pay pay = submitData.toJavaObject(Pay.class);
|
|
|
+ commStart(pay, 1);
|
|
|
+ }
|
|
|
+ //驳回
|
|
|
+ if (FlowStatusEnum.REJECT.equals(flowStatusEnum)) {
|
|
|
+ payService.update(q -> q
|
|
|
+ .eq(Pay::getId, businessId)
|
|
|
+ .set(Pay::getStatus, FlowStatusEnum1.REJECT.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|