|
@@ -2,7 +2,6 @@ package com.fjhx.service.purchase.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
-import com.fjhx.constants.common.CommonConstant;
|
|
|
import com.fjhx.entity.apply.ApplyPurchase;
|
|
|
import com.fjhx.entity.purchase.Purchase;
|
|
|
import com.fjhx.enums.apply.ApplyPurchaseStatusEnum;
|
|
@@ -15,6 +14,7 @@ import com.fjhx.service.purchase.PurchaseFlowService;
|
|
|
import com.fjhx.service.purchase.PurchaseService;
|
|
|
import com.fjhx.uitl.code.CodeEnum;
|
|
|
import com.fjhx.uitl.flow.FlowUserUtil;
|
|
|
+import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.BigDecimalUtil;
|
|
|
import com.fjhx.utils.ExampleAbstract;
|
|
|
import com.fjhx.utils.FlowConstructor;
|
|
@@ -76,10 +76,18 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
|
|
|
@Override
|
|
|
public void end() {
|
|
|
Long id = getCacheData(Long.class);
|
|
|
-
|
|
|
- purchaseService.lambdaUpdate().set(Purchase::getStatus, PurchaseStatusEnum.STATUS_30.getKey()).eq(Purchase::getId, id).update();
|
|
|
-
|
|
|
- applyPurchaseService.lambdaUpdate().set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_40.getKey()).eq(ApplyPurchase::getPurchaseId, id).update();
|
|
|
+
|
|
|
+
|
|
|
+ purchaseService.lambdaUpdate()
|
|
|
+ .set(Purchase::getStatus, PurchaseStatusEnum.STATUS_30.getKey())
|
|
|
+ .eq(Purchase::getId, id)
|
|
|
+ .update();
|
|
|
+
|
|
|
+
|
|
|
+ applyPurchaseService.lambdaUpdate()
|
|
|
+ .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_60.getKey())
|
|
|
+ .eq(ApplyPurchase::getPurchaseId, id)
|
|
|
+ .update();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -89,31 +97,20 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
@Override
|
|
|
public void reject() {
|
|
|
- Purchase purchase = purchaseService.getById(getCacheData(Long.class));
|
|
|
- flowConstructor().deleteLogic(purchase.getFlowId());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 删除流程
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = {Exception.class})
|
|
|
- @Override
|
|
|
- public boolean deleteLogic() {
|
|
|
Long id = getCacheData(Long.class);
|
|
|
-
|
|
|
- purchaseService.lambdaUpdate().set(Purchase::getStatus, PurchaseStatusEnum.STATUS_20.getKey()).set(Purchase::getDelFlag, CommonConstant.YesOrNo.YES).eq(Purchase::getId, id).update();
|
|
|
-
|
|
|
+
|
|
|
+ purchaseService.lambdaUpdate()
|
|
|
+ .set(Purchase::getStatus, PurchaseStatusEnum.STATUS_20.getKey())
|
|
|
+ .eq(Purchase::getId, id)
|
|
|
+ .update();
|
|
|
+
|
|
|
+
|
|
|
applyPurchaseService.lambdaUpdate()
|
|
|
- .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_30.getKey())
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_50.getKey())
|
|
|
.eq(ApplyPurchase::getPurchaseId, id)
|
|
|
.update();
|
|
|
- return true;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
);
|
|
|
}
|
|
@@ -127,15 +124,18 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
@Override
|
|
|
public void start(Purchase entity) {
|
|
|
+ List<ApplyPurchase> goodsList = entity.getGoodsList();
|
|
|
+ Assert.notEmpty(goodsList, "采购物品不能为空");
|
|
|
+
|
|
|
if (!redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
|
|
|
if (Func.isEmpty(entity.getId())) {
|
|
|
entity.setId(IdWorker.getId());
|
|
|
}
|
|
|
|
|
|
if (Func.isBlank(entity.getCode())) {
|
|
|
-
|
|
|
+
|
|
|
entity.setCode(CodeEnum.APPLY_PURCHASE.getCode());
|
|
|
-
|
|
|
+
|
|
|
if (!checkCodeIsExist(null, entity.getCode())) {
|
|
|
throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + entity.getCode());
|
|
|
}
|
|
@@ -144,7 +144,7 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
|
|
|
|
|
|
String title = AuthUtil.getUserName() + " 在" + LocalDate.now() + "日发起了 采购审批流程(单号:" + entity.getCode() + ")";
|
|
|
|
|
|
- ExampleResult exampleResult = null;
|
|
|
+ ExampleResult exampleResult;
|
|
|
if (Func.isEmpty(entity.getFlowId())) {
|
|
|
|
|
|
exampleResult = flowConstructor().create(entity.getId(), title, entity.getFlowRemark(), entity.getId());
|
|
@@ -155,7 +155,6 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
|
|
|
exampleResult = flowConstructor().jump(entity.getId(), buttonId, entity.getFlowRemark(), entity.getId());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
ExampleResult finalExampleResult = exampleResult;
|
|
|
exampleResult.after(() -> {
|
|
|
|
|
@@ -168,16 +167,15 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
|
|
|
|
|
|
BigDecimal price = new BigDecimal(BigDecimal.ZERO.intValue());
|
|
|
|
|
|
- for (ApplyPurchase goods : entity.getGoodsList()) {
|
|
|
+ for (ApplyPurchase goods : goodsList) {
|
|
|
goods.setPurchaseId(entity.getId());
|
|
|
goods.setPurchaseCode(entity.getCode());
|
|
|
- goods.setStatus(ApplyPurchaseStatusEnum.STATUS_20.getKey());
|
|
|
+ goods.setStatus(ApplyPurchaseStatusEnum.STATUS_40.getKey());
|
|
|
price = price.add(BigDecimalUtil.multiply(goods.getQuantity(), goods.getUnitPrice(), 2));
|
|
|
}
|
|
|
entity.setPrice(price);
|
|
|
purchaseService.saveOrUpdate(entity);
|
|
|
-
|
|
|
- applyPurchaseService.saveOrUpdateBatch(entity.getGoodsList());
|
|
|
+ applyPurchaseService.saveOrUpdateBatch(goodsList);
|
|
|
});
|
|
|
return true;
|
|
|
})) {
|