|
@@ -10,6 +10,7 @@ import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.enums.CodingRuleEnum;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
|
+import com.fjhx.flow.core.FlowThreadLocalUtil;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseDataResourceEnum;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseDetailStatusEnum;
|
|
|
import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
|
|
@@ -22,7 +23,6 @@ import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
|
import com.fjhx.purchase.service.subscribe.SubscribeService;
|
|
|
-import com.fjhx.purchase.util.code.CodeEnum;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
import com.obs.services.internal.ServiceException;
|
|
@@ -59,6 +59,7 @@ public class PurchaseFlowByWdly extends FlowDelegate {
|
|
|
private ContractProductService contractProductService;
|
|
|
@Autowired
|
|
|
private CodingRuleService codingRuleService;
|
|
|
+
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
|
return "wdly_purchase";
|
|
@@ -77,7 +78,7 @@ public class PurchaseFlowByWdly extends FlowDelegate {
|
|
|
try {
|
|
|
Purchase purchase = submitData.toJavaObject(Purchase.class);
|
|
|
// purchase.setCode(CodeEnum.PURCHASE.getCode());
|
|
|
- purchase.setCode(codingRuleService.createCode(CodingRuleEnum.PURCHASE.getKey(),null));
|
|
|
+ purchase.setCode(codingRuleService.createCode(CodingRuleEnum.PURCHASE.getKey(), null));
|
|
|
purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
|
|
|
purchase.setProcessInstanceId("wdly_purchase");
|
|
|
purchase.setFlowId(flowId);
|
|
@@ -124,7 +125,7 @@ public class PurchaseFlowByWdly extends FlowDelegate {
|
|
|
String victoriatouristJson1 = purchase.getVictoriatouristJson();
|
|
|
JSONObject json1 = JSONObject.parseObject(victoriatouristJson1);
|
|
|
json1.put("receiptWarehouseId", receiptWarehouseId);
|
|
|
- purchase.setVictoriatouristJson(com.alibaba.fastjson2.JSONObject.toJSONString(json1,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ purchase.setVictoriatouristJson(com.alibaba.fastjson2.JSONObject.toJSONString(json1, JSONWriter.Feature.WriteLongAsString));
|
|
|
purchaseService.updateById(purchase);
|
|
|
}
|
|
|
return purchase.getId();
|
|
@@ -200,4 +201,67 @@ public class PurchaseFlowByWdly extends FlowDelegate {
|
|
|
.lambda().eq(PurchaseDetail::getPurchaseId, purchase.getId()));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 重新发起编辑方法
|
|
|
+ */
|
|
|
+ public void reStart() {
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.PURCHASE);
|
|
|
+ try {
|
|
|
+ //获取提交的数据
|
|
|
+ JSONObject submitData = FlowThreadLocalUtil.getCurrentData();
|
|
|
+ //修改采购信息
|
|
|
+ Purchase purchase = submitData.toJavaObject(Purchase.class);
|
|
|
+ purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
|
|
|
+ purchaseService.updateById(purchase);
|
|
|
+ //修改采购明细
|
|
|
+ List<PurchaseDetail> purchaseDetailList = purchase.getPurchaseDetailList();
|
|
|
+ if (CollectionUtils.isNotEmpty(purchaseDetailList)) {
|
|
|
+ for (PurchaseDetail s : purchaseDetailList) {
|
|
|
+ s.setPurchaseId(purchase.getId());
|
|
|
+ //计算采购数量是否大于申购数量
|
|
|
+ List<PurchaseDetail> purchaseDetailList1 = purchaseDetailService.list(q -> q.eq(PurchaseDetail::getSubscribeDetailId,
|
|
|
+ s.getSubscribeDetailId()));
|
|
|
+ //求和
|
|
|
+ BigDecimal purchaseCount = purchaseDetailList1.stream()
|
|
|
+ .map(PurchaseDetail::getCount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ //计算历史采购数量+本次采购数量之和
|
|
|
+ BigDecimal count = purchaseCount.add(s.getCount());
|
|
|
+ //判断采购数量是否大于申购数量
|
|
|
+ SubscribeDetail subscribeDetail = subscribeDetailService.getById(s.getSubscribeDetailId());
|
|
|
+ if (count.compareTo(subscribeDetail.getCount()) > 0) {
|
|
|
+ throw new ServiceException("采购数量不能大于申购数量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //更新明细列表信息
|
|
|
+ purchaseDetailService.editLinked(purchaseDetailList, PurchaseDetail::getPurchaseId, purchase.getId());
|
|
|
+ }
|
|
|
+ //根据申购明细id去申购单获取仓库id 名称
|
|
|
+ if (ObjectUtils.isNotEmpty(purchaseDetailList)) {
|
|
|
+ PurchaseDetail purchaseDetail = purchaseDetailList.get(0);
|
|
|
+ SubscribeDetail subscribeDetail = subscribeDetailService.getById(purchaseDetail.getSubscribeDetailId());
|
|
|
+ if (ObjectUtils.isEmpty(subscribeDetail)) {
|
|
|
+ throw new ServiceException("查询不到申购明细信息");
|
|
|
+ }
|
|
|
+ Subscribe subscribe = subscribeService.getById(subscribeDetail.getSubscribeId());
|
|
|
+ if (ObjectUtils.isEmpty(subscribe)) {
|
|
|
+ throw new ServiceException("查询不到申购信息");
|
|
|
+ }
|
|
|
+ String victoriatouristJson = subscribe.getVictoriatouristJson();
|
|
|
+ if (ObjectUtils.isNotEmpty(victoriatouristJson)) {
|
|
|
+ JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
+ Long receiptWarehouseId = json.getLong("receiptWarehouseId");
|
|
|
+
|
|
|
+ String victoriatouristJson1 = purchase.getVictoriatouristJson();
|
|
|
+ JSONObject json1 = JSONObject.parseObject(victoriatouristJson1);
|
|
|
+ json1.put("receiptWarehouseId", receiptWarehouseId);
|
|
|
+ purchase.setVictoriatouristJson(com.alibaba.fastjson2.JSONObject.toJSONString(json1, JSONWriter.Feature.WriteLongAsString));
|
|
|
+ purchaseService.updateById(purchase);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|