Преглед изворни кода

物品申购流程引擎规则

大数据与最优化研究所 пре 1 година
родитељ
комит
9ba5135f7d

+ 10 - 0
src/main/java/com/xjrsoft/module/ledger/entity/WfSubscription.java

@@ -57,6 +57,16 @@ public class WfSubscription implements Serializable {
     */
     @ApiModelProperty("附件")
     private String folderId;
+    /**
+     * 编号
+     */
+    @ApiModelProperty("编号")
+    private String number;
+    /**
+     * 状态(0:未审核 1:审核)
+     */
+    @ApiModelProperty("状态(0:未审核 1:审核)")
+    private Integer status;
 
     /**
     * wfSubscriptionList

+ 2 - 0
src/main/java/com/xjrsoft/module/ledger/service/IWfSubscriptionService.java

@@ -60,4 +60,6 @@ public interface IWfSubscriptionService extends MPJBaseService<WfSubscription> {
      * 列表查询
      */
     List<WfSubscriptionExcelVo> getList(WfSubscriptionPageDto dto);
+
+    Boolean dataHandle(Long formId);
 }

+ 61 - 5
src/main/java/com/xjrsoft/module/ledger/service/impl/WfSubscriptionServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.ledger.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -20,6 +21,7 @@ import com.xjrsoft.module.ledger.vo.WfSubscriptionPageVo;
 import com.xjrsoft.module.ledger.vo.WorkflowRecordVo;
 import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.system.service.IFileService;
+import com.xjrsoft.module.textbook.entity.WfTextbookRecede;
 import com.xjrsoft.module.workflow.entity.WorkflowExtra;
 import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
 import com.xjrsoft.module.workflow.entity.WorkflowRecord;
@@ -31,11 +33,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -198,4 +198,60 @@ public class WfSubscriptionServiceImpl extends MPJBaseServiceImpl<WfSubscription
         }
         return result;
     }
+
+    @Override
+    public Boolean dataHandle(Long formId) {
+        WfSubscription wfSubscription = this.getById(formId);
+
+        if(wfSubscription != null){
+            //获取当前内存中的最大编号
+            LambdaQueryWrapper<WfSubscription> wfSubscriptionLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            wfSubscriptionLambdaQueryWrapper
+                    .select(WfSubscription::getNumber)
+                    .orderByDesc(WfSubscription::getNumber)
+                    .last("limit 1");
+            WfSubscription wfSubscriptionMax = this.getOne(wfSubscriptionLambdaQueryWrapper);
+            if(wfSubscriptionMax != null){
+                String number = wfSubscriptionMax.getNumber();
+                String ysarStr = "";
+                String lastThreeChars = "";
+                if(number != null && number.length() >= 3) {
+                    number = number.trim();
+                    ysarStr = number.substring(0, number.length() - 3);
+                    lastThreeChars = number.substring(number.length() - 3);
+                }
+
+                Date shenQingRiQi = wfSubscription.getShenQingRiQi4752();
+                LocalDate localDate = shenQingRiQi.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+
+                String year = String.valueOf(localDate.getYear());
+
+                WfSubscription wfSubscriptionNew = new WfSubscription();
+
+                if(year.equals(ysarStr)){
+                    int num = Integer.parseInt(lastThreeChars);
+                    num = num + 1;
+                    wfSubscriptionNew.setNumber(ysarStr+num);
+                }else {
+                    wfSubscriptionNew.setNumber(ysarStr+"001");
+                }
+                wfSubscriptionNew.setId(wfSubscription.getId());
+                wfSubscriptionNew.setStatus(1);
+
+                this.updateById(wfSubscriptionNew);
+            }else{
+                Date shenQingRiQi = wfSubscription.getShenQingRiQi4752();
+                LocalDate localDate = shenQingRiQi.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+
+                String year = String.valueOf(localDate.getYear());
+                WfSubscription wfSubscriptionNew = new WfSubscription();
+                wfSubscriptionNew.setNumber(year+"001");
+                wfSubscriptionNew.setId(wfSubscription.getId());
+                wfSubscriptionNew.setStatus(1);
+
+                this.updateById(wfSubscriptionNew);
+            }
+        }
+        return true;
+    }
 }

+ 31 - 0
src/main/java/com/xjrsoft/module/liteflow/node/WfSubscriptionNode.java

@@ -0,0 +1,31 @@
+package com.xjrsoft.module.liteflow.node;
+
+import cn.hutool.core.convert.Convert;
+import com.xjrsoft.module.ledger.service.IWfSubscriptionService;
+import com.xjrsoft.module.textbook.service.IWfTextbookRecedeService;
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * 物品申购流程走完节点
+ */
+@Component("wf_subscription_node")
+public class WfSubscriptionNode extends NodeComponent {
+    @Autowired
+    private IWfSubscriptionService wfSubscriptionService;
+
+    @Override
+    public void process() throws Exception {
+        // 获取表单中数据编号
+        Map<String, Object> params = this.getFirstContextBean();
+        Object value = util.getFormDatKey(params,"id");
+        Long formId = Convert.toLong(value);
+        if (formId != null) {
+            // 数据处理
+            wfSubscriptionService.dataHandle(formId);
+        }
+    }
+}

+ 17 - 0
src/test/java/com/xjrsoft/module/ledger/service/impl/WfSubscriptionServiceImplTest.java

@@ -0,0 +1,17 @@
+package com.xjrsoft.module.ledger.service.impl;
+
+import com.xjrsoft.module.ledger.service.IWfSubscriptionService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import static org.junit.jupiter.api.Assertions.*;
+@SpringBootTest
+class WfSubscriptionServiceImplTest {
+    @Autowired
+    private IWfSubscriptionService wfSubscriptionService;
+    @Test
+    void dataHandle() {
+        wfSubscriptionService.dataHandle(1732758742634655744L);
+    }
+}