gongdecai 1 năm trước cách đây
mục cha
commit
38496a8573

+ 95 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/workflow/SalesTransferInfoListener.java

@@ -0,0 +1,95 @@
+package com.yh.saas.plugin.yiliangyiyun.workflow;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.winsea.svc.base.base.entity.AuditHistory;
+import com.winsea.svc.base.base.service.IAuditHistoryService;
+import com.yh.saas.common.support.workflow.AbstractWorkflowTaskListener;
+import com.yh.saas.common.support.workflow.annotation.WorkflowTaskListener;
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
+import com.yh.saas.plugin.yiliangyiyun.entity.PurchasePrice;
+import com.yh.saas.plugin.yiliangyiyun.entity.SaleOrder;
+import com.yh.saas.plugin.yiliangyiyun.entity.StatusRecord;
+import com.yh.saas.plugin.yiliangyiyun.mapper.CommonUserMapper;
+import com.yh.saas.plugin.yiliangyiyun.mapper.StatusRecordMapper;
+import com.yh.saas.plugin.yiliangyiyun.service.IPurchasePriceService;
+import com.yh.saas.plugin.yiliangyiyun.service.ISaleOrderService;
+import com.yh.saas.toolkit.workflow.service.IWorkflowHistoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@WorkflowTaskListener(name = "收购管理", group = "仓库设置")
+public class AcquisitionListener extends AbstractWorkflowTaskListener {
+
+    private static final long serialVersionUID = 4103656734835351132L;
+
+    @Autowired
+    private IPurchasePriceService purchasePriceService;
+    @Autowired
+    private IAuditHistoryService auditHistoryService;
+    @Autowired
+    private CommonUserMapper commonUserMapper;
+    @Autowired
+    private StatusRecordMapper statusRecordMapper;
+
+    @Override
+    public void handleStatusChanged(String businessKey, String status, String statusEn, boolean processIsEnd) {
+        PurchasePrice purchasePrice = purchasePriceService.selectById(businessKey);
+        StatusRecord statusRecord = new StatusRecord();
+        StatusRecord statusRecord1 = statusRecordMapper.selectById(businessKey);
+        if (purchasePrice == null) {
+            return;
+        }
+        if (processIsEnd) {
+            purchasePrice.setStatusFlag(StatusEnum.ORDER_PASSED.getFlag());
+            purchasePrice.setStatus(StatusEnum.ORDER_PASSED.getName());
+            purchasePrice.setWorkflowId(null);
+            purchasePrice.setApproveStatus(null);
+
+            if(statusRecord1 != null){
+                statusRecord1.setStatus(StatusEnum.ORDER_PASSED.getName());
+                statusRecordMapper.updateById(statusRecord1);
+            }
+            else{
+                statusRecord.setId(businessKey);
+                statusRecord.setStatus(StatusEnum.ORDER_PASSED.getName());
+                statusRecordMapper.insert(statusRecord);
+            }
+        } else {
+            purchasePrice.setApproveStatus(status);
+
+            if(statusRecord1 != null){
+                statusRecord1.setStatus(status);
+                statusRecordMapper.updateById(statusRecord1);
+            }
+            else{
+                statusRecord.setId(businessKey);
+                statusRecord.setStatus(status);
+                statusRecordMapper.insert(statusRecord);
+            }
+        }
+        purchasePriceService.updateAllColumnById(purchasePrice);
+    }
+
+    @Override
+    public void handleRejectApplicationRepulsed(String workflowId, String businessKey, boolean needReapply) {
+        PurchasePrice purchasePrice = purchasePriceService.selectById(businessKey);
+        if (purchasePrice == null) {
+            return;
+        }
+        purchasePrice.setStatusFlag(StatusEnum.PURCHASE_FAILED.getFlag());
+        purchasePrice.setStatus(StatusEnum.PURCHASE_FAILED.getName());
+        purchasePrice.setApproveStatus(null);
+        purchasePriceService.updateAllColumnById(purchasePrice);
+        StatusRecord statusRecord = new StatusRecord();
+        StatusRecord statusRecord1 = statusRecordMapper.selectById(businessKey);
+        if(statusRecord1 != null){
+            statusRecord1.setStatus(StatusEnum.PURCHASE_FAILED.getName());
+            statusRecordMapper.updateById(statusRecord1);
+        }
+        else{
+            statusRecord.setId(businessKey);
+            statusRecord.setStatus(StatusEnum.PURCHASE_FAILED.getName());
+            statusRecordMapper.insert(statusRecord);
+        }
+    }
+
+}