Kaynağa Gözat

新增sop快捷搜索

wangliang 1 yıl önce
ebeveyn
işleme
bd7f47bb35

+ 8 - 2
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -5,6 +5,7 @@ import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.bean.params.SopSaveParam;
+import com.qmth.sop.business.bean.params.UserArchivesAllocationParam;
 import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FormWidgetMetadataResult;
 import com.qmth.sop.business.entity.SysUser;
@@ -111,8 +112,13 @@ public class TBSopInfoController {
     @ApiOperation(value = "sop人员配置")
     @RequestMapping(value = "/allocation", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
-    public Result allocation(@ApiParam(value = "流程id", required = true) @RequestParam Long flowId) {
-        return ResultUtil.ok(tbSopInfoService.sopAllocation(flowId));
+    public Result allocation(@Valid @RequestBody UserArchivesAllocationParam userArchivesAllocationParam,
+            BindingResult bindingResult) {
+        //        tbSopInfoService.sopAllocation(flowId)
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok();
     }
 
     @ApiOperation(value = "sop删除")

+ 39 - 3
sop-api/src/main/java/com/qmth/sop/server/api/TBSopQuickController.java

@@ -1,10 +1,22 @@
 package com.qmth.sop.server.api;
 
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.params.SopQuickSearchParam;
+import com.qmth.sop.business.bean.result.EditResult;
+import com.qmth.sop.business.service.TBSopQuickSearchService;
+import com.qmth.sop.common.annotation.OperationLog;
 import com.qmth.sop.common.contant.SystemConstant;
-import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.qmth.sop.common.enums.LogTypeEnum;
+import com.qmth.sop.common.enums.SopQuickSearchTypeEnum;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
 
 /**
  * <p>
@@ -19,4 +31,28 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SOP_QUICK)
 public class TBSopQuickController {
 
+    @Resource
+    TBSopQuickSearchService tbSopQuickSearchService;
+
+    @ApiOperation(value = "sop快捷搜索列表")
+    @RequestMapping(value = "/search", method = RequestMethod.POST)
+    @OperationLog(logType = LogTypeEnum.SEARCH)
+    @ApiResponses({ @ApiResponse(code = 200, message = "sop快捷搜索信息", response = EditResult.class) })
+    public Result search(@ApiParam(value = "流程类型", required = true) @RequestParam TFCustomTypeEnum type,
+            @ApiParam(value = "内容类型", required = true) @RequestParam SopQuickSearchTypeEnum contentType) {
+        return ResultUtil.ok();
+    }
+
+    @ApiOperation(value = "sop快捷搜索保存")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @OperationLog(logType = LogTypeEnum.UPDATE)
+    @ApiResponses({ @ApiResponse(code = 200, message = "sop快捷搜索信息", response = EditResult.class) })
+    public Result save(
+            @Valid @ApiParam(value = "sop快捷搜索参数信息", required = true) @RequestBody SopQuickSearchParam sopQuickSearchParam,
+            BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(true);
+    }
 }

+ 26 - 12
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -669,9 +669,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     @Transactional
     public Boolean taskApproverExchange(Long userId, Long taskId) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
         Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
-
         //        if (Objects.nonNull(task.getAssignee()) && task.getAssignee().equals(userId.toString())) {
         //            throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
         //        } else {
@@ -684,12 +684,37 @@ public class ActivitiServiceImpl implements ActivitiService {
         //                }
         //            }
         //        }
+
         boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_EXCHANGE_PREFIX + taskId, taskId,
                 SystemConstant.LOCK_FLOW_TIME_OUT);
         if (!lock) {
             throw ExceptionResultEnum.ERROR.exception("正在转审中,请稍候再试!");
         }
         try {
+            TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
+                    new QueryWrapper<TFCustomFlowEntity>().lambda()
+                            .eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
+            Optional.ofNullable(tfCustomFlowEntity)
+                    .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+            TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
+            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+
+            FlowTaskResult flowTaskResultOne = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 1);
+            ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(tfCustomFlow.getType(), flowTaskResultOne);
+
+            FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+            LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+            FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
+                    GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+
+            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
+                if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN
+                        && currFlowTaskResult.getSetup().intValue() > 3) {
+                    return true;
+                }
+            }
+
             BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
             FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
             boolean multiInstance = false;
@@ -747,17 +772,6 @@ public class ActivitiServiceImpl implements ActivitiService {
             if (!replace) {
                 return true;
             }
-            TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
-                    new QueryWrapper<TFCustomFlowEntity>().lambda()
-                            .eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
-            Optional.ofNullable(tfCustomFlowEntity)
-                    .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
-
-            FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
-            LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
-            FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
-                    GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
-            SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getOrgId(), sysUser.getId(), sysUser.getId(),
                     currFlowTaskResult.getSetup(), Long.parseLong(task.getProcessInstanceId()),
                     Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), String.valueOf(userId));

+ 31 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopAllocationParam.java

@@ -0,0 +1,31 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: sop人员配置
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2024/5/21
+ */
+public class SopAllocationParam extends UserArchivesAllocationParam implements Serializable {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty("流程id")
+    @NotNull(message = "流程id不能为空")
+    private Long flowId;
+
+    public Long getFlowId() {
+        return flowId;
+    }
+
+    public void setFlowId(Long flowId) {
+        this.flowId = flowId;
+    }
+}

+ 82 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopQuickSearchParam.java

@@ -0,0 +1,82 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.enums.SopQuickSearchTypeEnum;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: sop快捷搜索参数
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2024/5/21
+ */
+public class SopQuickSearchParam implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    @ApiModelProperty(value = "流程类型,OFFICE_SOP_FLOW:教务处SOP,CLOUD_MARK_SOP_FLOW:研究生SOP,DING_EXCEPTION_FLOW:考勤异常审核流程,PROJECT_EXCHANGE_FLOW:项目计划变更流程,QUALITY_PROBLEM_FLOW:质量问题反馈流程")
+    @NotNull(message = "流程类型不能为空")
+    private TFCustomTypeEnum type;
+
+    @ApiModelProperty(value = "内容名称")
+    @NotNull(message = "内容名称不能为空")
+    private String name;
+
+    @ApiModelProperty(value = "内容")
+    @NotNull(message = "内容不能为空")
+    private String content;
+
+    @ApiModelProperty(value = "内容类型,VIEW:显示列表,SEARCH:快捷搜索")
+    @NotNull(message = "内容类型不能为空")
+    private SopQuickSearchTypeEnum contentType;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public TFCustomTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(TFCustomTypeEnum type) {
+        this.type = type;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public SopQuickSearchTypeEnum getContentType() {
+        return contentType;
+    }
+
+    public void setContentType(SopQuickSearchTypeEnum contentType) {
+        this.contentType = contentType;
+    }
+}

+ 2 - 3
sop-business/src/main/java/com/qmth/sop/business/bean/params/UserArchivesAllocationParam.java

@@ -5,9 +5,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import org.hibernate.validator.constraints.Range;
 
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -15,7 +14,7 @@ import java.util.List;
  * @Author: CaoZixuan
  * @Date: 2023-08-16
  */
-public class UserArchivesAllocationParam {
+public class UserArchivesAllocationParam implements Serializable {
 
     @ApiModelProperty("分配参数")
     private List<AllocationParam> allocationParams;

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java

@@ -13,6 +13,7 @@ import com.qmth.sop.business.bean.result.SopInfoResult;
 import com.qmth.sop.business.entity.TBSopInfo;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.business.entity.TFCustomFlowEntity;
+import com.qmth.sop.common.enums.ServiceScopeEnum;
 import com.qmth.sop.common.enums.SopStatusEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 
@@ -188,4 +189,13 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @return
      */
     Boolean updateFlowSetupOne(Long flowId, Long crmDetailId);
+
+    /**
+     * 查询服务范围
+     *
+     * @param type
+     * @param flowTaskResult
+     * @return
+     */
+    ServiceScopeEnum findServiceScope(TFCustomTypeEnum type, FlowTaskResult flowTaskResult);
 }

+ 21 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBSopQuickSearchService.java

@@ -1,7 +1,12 @@
 package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.params.SopQuickSearchParam;
 import com.qmth.sop.business.entity.TBSopQuickSearch;
+import com.qmth.sop.common.enums.SopQuickSearchTypeEnum;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,20 @@ import com.qmth.sop.business.entity.TBSopQuickSearch;
  */
 public interface TBSopQuickSearchService extends IService<TBSopQuickSearch> {
 
+    /**
+     * sop快捷搜索列表
+     *
+     * @param type
+     * @param contentType
+     * @return
+     */
+    List<TBSopQuickSearch> list(TFCustomTypeEnum type, SopQuickSearchTypeEnum contentType);
+
+    /**
+     * sop快捷搜索保存
+     *
+     * @param sopQuickSearchParam
+     * @return
+     */
+    boolean save(SopQuickSearchParam sopQuickSearchParam);
 }

+ 26 - 10
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -885,17 +885,8 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     public List<String> getNextApproveUserIds(TFCustomTypeEnum type, FlowTaskResult flowTaskResult,
             FlowTaskResult currFlowTaskResult, CrmProjectResult crmProjectResult) {
         List<String> approveUserIds = new ArrayList<>();
+        ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(type, flowTaskResult);
         if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
-            List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
-            ServiceScopeEnum scopeEnum = null;
-            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
-                if (f.getFormId().contains(ProcessLimitedEnum.SERVICE_SCOPE_RADIO.getKey())) {
-                    JSONObject jsonObject = JSONObject.parseObject(f.getValue());
-                    String value = jsonObject.getString(SystemConstant.VALUE);
-                    scopeEnum = ServiceScopeEnum.valueOf(value);
-                    break;
-                }
-            }
             if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN_MARK) {//扫描+阅卷,12345是项目经理
                 for (UserArchivesDto u : crmProjectResult.getProjectManagerList()) {
                     approveUserIds.add(u.getUserId().toString());
@@ -1231,4 +1222,29 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Objects.requireNonNull(serviceId, "服务单元id不能为空");
         return this.baseMapper.findFlowByServiceId(serviceId);
     }
+
+    /**
+     * 查询服务范围
+     *
+     * @param type
+     * @param flowTaskResult
+     * @return
+     */
+    public ServiceScopeEnum findServiceScope(TFCustomTypeEnum type, FlowTaskResult flowTaskResult) {
+        ServiceScopeEnum scopeEnum = null;
+        if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
+            List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
+            for (FlowFormWidgetResult f : flowFormWidgetResultList) {
+                if (f.getFormId().contains(ProcessLimitedEnum.SERVICE_SCOPE_RADIO.getKey())) {
+                    JSONObject jsonObject = JSONObject.parseObject(f.getValue());
+                    String value = jsonObject.getString(SystemConstant.VALUE);
+                    scopeEnum = ServiceScopeEnum.valueOf(value);
+                    break;
+                }
+            }
+        } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
+
+        }
+        return scopeEnum;
+    }
 }

+ 57 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopQuickSearchServiceImpl.java

@@ -1,10 +1,25 @@
 package com.qmth.sop.business.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.bean.params.SopQuickSearchParam;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBSopQuickSearch;
 import com.qmth.sop.business.mapper.TBSopQuickSearchMapper;
 import com.qmth.sop.business.service.TBSopQuickSearchService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FieldUniqueEnum;
+import com.qmth.sop.common.enums.SopQuickSearchTypeEnum;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
+import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
 
 /**
  * <p>
@@ -15,6 +30,47 @@ import org.springframework.stereotype.Service;
  * @since 2024-05-21
  */
 @Service
-public class TBSopQuickSearchServiceImpl extends ServiceImpl<TBSopQuickSearchMapper, TBSopQuickSearch> implements TBSopQuickSearchService {
+public class TBSopQuickSearchServiceImpl extends ServiceImpl<TBSopQuickSearchMapper, TBSopQuickSearch>
+        implements TBSopQuickSearchService {
+
+    /**
+     * sop快捷搜索列表
+     *
+     * @param type
+     * @param contentType
+     * @return
+     */
+    @Override
+    public List<TBSopQuickSearch> list(TFCustomTypeEnum type, SopQuickSearchTypeEnum contentType) {
+        return null;
+    }
+
+    /**
+     * sop快捷搜索保存
+     *
+     * @param sopQuickSearchParam
+     * @return
+     */
+    @Override
+    @Transactional
+    public boolean save(SopQuickSearchParam sopQuickSearchParam) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        try {
 
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            if (e instanceof DuplicateKeyException) {
+                String errorColumn = e.getCause().toString();
+                String[] strs = StringUtils.split(errorColumn, "-");
+                String[] columns = StringUtils.split(strs[strs.length - 1], "\\'");
+                throw ExceptionResultEnum.SQL_ERROR.exception(
+                        "[" + FieldUniqueEnum.convertToTitle(columns[columns.length - 1]) + "]数据不允许重复插入");
+            } else if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        }
+        return false;
+    }
 }

+ 5 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -157,4 +157,8 @@ CREATE TABLE `t_b_sop_quick_search` (
                                         `content_type` varchar(20) NOT NULL COMMENT '内容类型,VIEW:显示列表,SEARCH:快捷搜索',
                                         PRIMARY KEY (`id`),
                                         UNIQUE KEY `t_b_sop_quick_search_unique` (`type`,`name`,`content_type`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop快捷搜索表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop快捷搜索表';
+
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(40, NULL, 'sop.quick.count', 'sop快捷条数', '10', NULL, 1, 1, 1, NULL, NULL, NULL);

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -205,6 +205,7 @@ public class SystemConstant {
     public static final String SMS_SOP_AFTER_REMIND_CODE = "sms.sop.after.remind.code";
     public static final String SMS_VIOLATION_REMIND_CODE = "sms.violation.remind.code";
     public static final String SMS_CUSTOM_INFO_MISSING_REMIND_CODE = "sms.custom.info.missing.remind.code";
+    public static final String SOP_QUICK_COUNT = "sop.quick.count";
 //    public static final String WXAPP_APP_ID = "wxapp.appid";
 //    public static final String WXAPP_REQUEST_URL = "wxapp.request.url";
 //    public static final String WXAPP_PHONE_BIND_NEW_URL = "wxapp.phone.bind.new.url";