Ver código fonte

1、完成采购申请的增删改查、及审核、归档、作废等功能

fuwb 4 meses atrás
pai
commit
c1449c8219

+ 1 - 1
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/constants/DictConstants.java

@@ -67,7 +67,7 @@ public class DictConstants {
     /**
      * 拟采购方式
      */
-    public static final String PROCUREMENT_METHOD = "PROCUREMENT_METHOD";
+    public static final String PROCUREMENT_METHOD = "procurement_method";
 
     /**
      * 性别

+ 27 - 0
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/constants/FlowStatusConstants.java

@@ -0,0 +1,27 @@
+package com.zjugis.module.business.constants;
+
+/**
+ * @author ljy
+ * @version 1.0
+ * @date 2023/11/29 14:19
+ */
+public class FlowStatusConstants {
+
+    // 未开始
+    public static final int FLOW_NOT_START = 0;
+
+    // 进行中
+    public static final int FLOW_PROCESS = 1;
+
+    // 出纳付款
+    public static final int FLOW_PAYMENT = 89;
+
+    // 子合同/子项目
+    public static final int FLOW_CHILD = 99;
+
+    // 作废
+    public static final int FLOW_NULLY = 20;
+
+    // 已完成
+    public static final int FLOW_FINISHED = 90;
+}

+ 1 - 0
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/converter/procurement/ProcurementConvert.java

@@ -17,4 +17,5 @@ public interface ProcurementConvert {
 
     ProcurementApplication convert(ProcurementVO createVO);
 
+    ProcurementVO convert(ProcurementApplication createVO);
 }

+ 5 - 1
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/flow/procurement/entity/ProcurementApplication.java

@@ -1,5 +1,8 @@
 package com.zjugis.module.business.flow.procurement.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.zjugis.module.business.mybatis.entity.BaseEntity;
 import lombok.Data;
@@ -25,6 +28,7 @@ public class ProcurementApplication extends BaseEntity {
     /**
      * 采购申请的唯一标识编号,自增生成
      */
+    @TableId(type = IdType.AUTO)
     private Long applicationId;
 
     /**
@@ -50,7 +54,7 @@ public class ProcurementApplication extends BaseEntity {
     /**
      * 申报时间,系统默认取当前时间
      */
-    private LocalDate reportTime;
+    private LocalDateTime reportTime;
 
     /**
      * 提交采购申请的用户

+ 176 - 0
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/flow/procurement/event/ProcurementApplicationEvent.java

@@ -0,0 +1,176 @@
+package com.zjugis.module.business.flow.procurement.event;
+
+import com.zjugis.framework.common.util.date.LocalDateTimeUtils;
+import com.zjugis.framework.workflow.exception.BusinessException;
+import com.zjugis.framework.workflow.model.BaseController;
+import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
+import com.zjugis.framework.workflow.spring.resovler.ParamModel;
+import com.zjugis.module.business.converter.procurement.ProcurementConvert;
+import com.zjugis.module.business.flow.procurement.entity.ProcurementApplication;
+import com.zjugis.module.business.flow.procurement.service.IProcurementApplicationService;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Objects;
+
+import static com.zjugis.module.business.constants.FlowStatusConstants.*;
+
+/**
+ * @author: Fuwb
+ * @date: 2025/2/27
+ * @time: 16:03
+ * @description:
+ */
+@RestController
+@RequestMapping("/procurement-application")
+public class ProcurementApplicationEvent extends BaseController {
+    public static final Logger log = LoggerFactory.getLogger(ProcurementApplicationEvent.class);
+
+    @Resource
+    private IProcurementApplicationService procurementService;
+    @Resource
+    private WorkflowClient workflowClient;
+
+    /**
+     * 设置流程描述
+     *
+     * @param flowInstance     流程实例
+     * @param activityInstance 活动实例
+     * @return true/false
+     */
+    @PostMapping("/setFlowDesc")
+    public String setFlowDesc(@ParamModel Map flowInstance, @ParamModel Map activityInstance) {
+        try {
+            if (!Objects.isNull(activityInstance) && activityInstance.containsKey("flowInstanceId")) {
+                String flowInstanceId = activityInstance.get("flowInstanceId").toString();
+                ProcurementApplication entity = procurementService.findByInstanceId(flowInstanceId);
+                String applyTime = LocalDateTimeUtils.format(entity.getCreateTime(), null);
+                String flowDesc = StringUtils.join(Arrays.asList(entity.getReporter(), applyTime, entity.getReportDepartment()), "/");
+                entity.setFlowStatus(FLOW_PROCESS);
+                procurementService.updateProcurement(ProcurementConvert.INSTANCE.convert(entity));
+                workflowClient.saveFlowDescribe(flowInstanceId, flowDesc);
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 流程归档事件
+     *
+     * @param flowInstance                  流程实例
+     * @param triggerFinishActivityInstance 触发归档的结束活动实例
+     * @return
+     */
+    @PostMapping("/flowArchingEvent")
+    public String flowArchingEvent(@ParamModel Map flowInstance, @ParamModel Map triggerFinishActivityInstance) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                ProcurementApplication entity = procurementService.findByInstanceId(flowInstanceId);
+                entity.setFlowStatus(FLOW_FINISHED);
+                entity.setFlowFinishtime(LocalDateTime.now());
+                procurementService.updateProcurement(ProcurementConvert.INSTANCE.convert(entity));
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 作废事件
+     *
+     * @param flowInstance     流程实例
+     * @param activityInstance 申请作废所在活动实例
+     * @param nullyApplyUserId 作废申请人ID
+     * @return
+     */
+    @PostMapping("/nullyEvent")
+    public String nullyEvent(@ParamModel Map flowInstance, @ParamModel Map activityInstance, String nullyApplyUserId) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                ProcurementApplication entity = procurementService.findByInstanceId(flowInstanceId);
+                entity.setFlowStatus(FLOW_NULLY);
+                entity.setIsvalid(0);
+                procurementService.updateProcurement(ProcurementConvert.INSTANCE.convert(entity));
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 作废恢复事件
+     *
+     * @param flowInstance      流程实例
+     * @param activityInstance  申请作废所在活动实例
+     * @param nullyApplyUserId  作废申请人ID
+     * @param nullyRecoverserId 作废恢复人ID
+     * @return
+     */
+    @PostMapping("/nullyRecoverEvent")
+    public String nullyRecoverEvent(@ParamModel Map flowInstance, @ParamModel Map activityInstance, String nullyApplyUserId, String nullyRecoverserId) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                ProcurementApplication entity = procurementService.findByInstanceId(flowInstanceId);
+                entity.setFlowStatus(FLOW_PROCESS);
+                entity.setIsvalid(1);
+                procurementService.updateProcurement(ProcurementConvert.INSTANCE.convert(entity));
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 彻底作废事件
+     *
+     * @param flowInstance        流程实例
+     * @param activityInstance    申请作废所在活动实例
+     * @param nullyApplyUserId    作废申请人ID
+     * @param nullyCompleteUserId 彻底作废人ID
+     * @return
+     */
+    @PostMapping("/nullyCompleteEvent")
+    public String nullyCompleteEvent(@ParamModel Map flowInstance, @ParamModel Map activityInstance, String nullyApplyUserId, String nullyCompleteUserId) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                ProcurementApplication entity = procurementService.findByInstanceId(flowInstanceId);
+                procurementService.deleteProcurement(entity.getApplicationId());
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+}

+ 6 - 5
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/flow/procurement/service/impl/ProcurementApplicationServiceImpl.java

@@ -1,6 +1,5 @@
 package com.zjugis.module.business.flow.procurement.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.log.Log;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -24,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
@@ -65,8 +63,9 @@ public class ProcurementApplicationServiceImpl implements IProcurementApplicatio
                 entity = new ProcurementApplication();
                 entity.setInstanceId(flowInstanceId);
                 entity.setReportNumber(flowInstance.getCode());
-                entity.setReportTime(LocalDate.now());
+                entity.setReportTime(LocalDateTime.now());
                 entity.setCreateTime(LocalDateTime.now());
+                entity.setIsvalid(1);
                 CommonResult<AdminUserRespDTO> result = adminUserApi.getUser(userId);
                 if (result.isSuccess()) {
                     entity.setReporter(result.getData().getNickname());
@@ -95,7 +94,8 @@ public class ProcurementApplicationServiceImpl implements IProcurementApplicatio
             Log.get().error(ErrorCodeConstants.PROCUREMENT_NOT_EXISTS.getMsg());
         }
         ProcurementApplication procurement = ProcurementConvert.INSTANCE.convert(updateReqVO);
-        procurementMapper.updateById(procurement);
+        procurementMapper.update(procurement, new LambdaQueryWrapper<ProcurementApplication>()
+                .eq(ProcurementApplication::getApplicationId, updateReqVO.getApplicationId()));
     }
 
     @Override
@@ -107,7 +107,8 @@ public class ProcurementApplicationServiceImpl implements IProcurementApplicatio
             Log.get().error(ErrorCodeConstants.PROCUREMENT_NOT_EXISTS.getMsg());
         }
         //删除
-        procurementMapper.deleteById(application);
+        procurementMapper.delete(new LambdaQueryWrapper<ProcurementApplication>()
+                .eq(ProcurementApplication::getApplicationId, id));
     }
 
 

+ 4 - 2
zjugis-module-business/zjugis-module-business-biz/src/main/java/com/zjugis/module/business/flow/procurement/vo/ProcurementVO.java

@@ -1,11 +1,13 @@
 package com.zjugis.module.business.flow.procurement.vo;
 
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
 
+import static com.zjugis.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
 /**
  * @author: Fuwb
  * @date: 2025/2/26
@@ -44,7 +46,7 @@ public class ProcurementVO implements Serializable {
     /**
      * 申报时间,系统默认取当前时间
      */
-    private LocalDate reportTime;
+    private LocalDateTime reportTime;
 
     /**
      * 提交采购申请的用户

+ 6 - 6
zjugis-module-business/zjugis-module-business-biz/src/main/resources/templates/ProcurementApplication/index.ftl

@@ -3,7 +3,7 @@ styles=[ '/flow/css/formCommon.css','/OwCommon/OwCommon.css' ]>
     <div class="z-position form-boss ow-tabs" name="createReqVO">
         <div class="z-form-row" style="display: none;">
             <input type="text" value="${formEntity.instanceId!}" name="createReqVO$instanceId">
-            <input type="text" value="${formEntity.id!}" name="createReqVO$id">
+            <input type="text" value="${formEntity.applicationId!}" name="createReqVO$applicationId">
         </div>
 
 
@@ -62,8 +62,8 @@ styles=[ '/flow/css/formCommon.css','/OwCommon/OwCommon.css' ]>
                             <td>
                                 <div class="form-group">
                                     <div class="form-item">
-                                        <div class="z-comp-input  z-readonly" name="createReqVO$userNickname">
-                                            <input type="text" value="${formEntity.userNickname!}">
+                                        <div class="z-comp-input  z-readonly" name="createReqVO$reporter">
+                                            <input type="text" value="${formEntity.reporter!}">
                                         </div>
                                     </div>
                                 </div>
@@ -74,8 +74,8 @@ styles=[ '/flow/css/formCommon.css','/OwCommon/OwCommon.css' ]>
                             <td>
                                 <div class="form-group">
                                     <div class="form-item">
-                                        <div class="z-comp-input  z-readonly" name="createReqVO$deptName">
-                                            <input type="text" value="${formEntity.deptName!}">
+                                        <div class="z-comp-input  z-readonly" name="createReqVO$reportDepartment">
+                                            <input type="text" value="${formEntity.reportDepartment!}">
                                         </div>
                                     </div>
                                 </div>
@@ -88,7 +88,7 @@ styles=[ '/flow/css/formCommon.css','/OwCommon/OwCommon.css' ]>
                             <td colspan="3">
                                 <div class="form-group">
                                     <div class="form-item">
-                                        <div class="z-comp-date" name="createReqVO$projectName">
+                                        <div class="z-comp-input" name="createReqVO$projectName">
                                             <input type="text" value="${formEntity.projectName!}">
                                         </div>
                                     </div>