ソースを参照

新增sop快捷搜索

wangliang 1 年間 前
コミット
d4a021dc61

+ 13 - 5
sop-api/src/main/java/com/qmth/sop/server/api/TBSopQuickController.java

@@ -35,12 +35,12 @@ public class TBSopQuickController {
     TBSopQuickSearchService tbSopQuickSearchService;
 
     @ApiOperation(value = "sop快捷搜索列表")
-    @RequestMapping(value = "/search", method = RequestMethod.POST)
+    @RequestMapping(value = "/list", 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();
+    public Result list(@ApiParam(value = "流程类型", required = true) @RequestParam TFCustomTypeEnum type,
+            @ApiParam(value = "内容类型") @RequestParam(required = false) SopQuickSearchTypeEnum contentType) {
+        return ResultUtil.ok(tbSopQuickSearchService.list(type, contentType));
     }
 
     @ApiOperation(value = "sop快捷搜索保存")
@@ -53,6 +53,14 @@ public class TBSopQuickController {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok(true);
+        return ResultUtil.ok(tbSopQuickSearchService.save(sopQuickSearchParam));
+    }
+
+    @ApiOperation(value = "sop快捷搜索删除")
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @OperationLog(logType = LogTypeEnum.DELETE)
+    @ApiResponses({ @ApiResponse(code = 200, message = "sop快捷搜索信息", response = EditResult.class) })
+    public Result delete(@ApiParam(value = "id", required = true) @RequestParam Long id) {
+        return ResultUtil.ok(tbSopQuickSearchService.delete(id));
     }
 }

+ 6 - 5
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopInfoListParam.java

@@ -69,7 +69,8 @@ public class SopInfoListParam extends TBSopInfo implements Serializable {
     String taskKey;
 
     @ApiModelProperty(value = "客户经理")
-    String customManagerName;
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long crmUserId;
 
     @ApiModelProperty(value = "项目名称")
     String crmName;
@@ -183,12 +184,12 @@ public class SopInfoListParam extends TBSopInfo implements Serializable {
         this.taskKey = taskKey;
     }
 
-    public String getCustomManagerName() {
-        return customManagerName;
+    public Long getCrmUserId() {
+        return crmUserId;
     }
 
-    public void setCustomManagerName(String customManagerName) {
-        this.customManagerName = customManagerName;
+    public void setCrmUserId(Long crmUserId) {
+        this.crmUserId = crmUserId;
     }
 
     public String getCrmName() {

+ 26 - 1
sop-business/src/main/java/com/qmth/sop/business/entity/TBSopQuickSearch.java

@@ -2,6 +2,8 @@ package com.qmth.sop.business.entity;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.business.bean.params.SopQuickSearchParam;
+import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.SopQuickSearchTypeEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import io.swagger.annotations.ApiModel;
@@ -17,7 +19,7 @@ import java.io.Serializable;
  * @author wangliang
  * @since 2024-05-21
  */
-@ApiModel(value="TBSopQuickSearch对象", description="sop快捷搜索表")
+@ApiModel(value = "TBSopQuickSearch对象", description = "sop快捷搜索表")
 public class TBSopQuickSearch implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -48,6 +50,29 @@ public class TBSopQuickSearch implements Serializable {
     @ApiModelProperty(value = "内容类型,VIEW:显示列表,SEARCH:快捷搜索")
     private SopQuickSearchTypeEnum contentType;
 
+    public TBSopQuickSearch() {
+
+    }
+
+    public TBSopQuickSearch(SopQuickSearchParam sopQuickSearchParam, String flowDeploymentId, Integer version,
+            Long userId) {
+        this.id = SystemConstant.getDbUuid();
+        this.type = sopQuickSearchParam.getType();
+        this.name = sopQuickSearchParam.getName();
+        this.content = sopQuickSearchParam.getContent();
+        this.contentType = sopQuickSearchParam.getContentType();
+        this.flowDeploymentId = flowDeploymentId;
+        this.version = version;
+        this.userId = userId;
+    }
+
+    public void updateInfo(SopQuickSearchParam sopQuickSearchParam) {
+        this.type = sopQuickSearchParam.getType();
+        this.name = sopQuickSearchParam.getName();
+        this.content = sopQuickSearchParam.getContent();
+        this.contentType = sopQuickSearchParam.getContentType();
+    }
+
     public Long getId() {
         return id;
     }

+ 9 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java

@@ -84,13 +84,21 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
      * @param fieldValue
      * @param dpr
      * @param fieldOrder
+     * @param leadId
+     * @param crmUserId
+     * @param customName
+     * @param taskKey
+     * @param crmName
+     * @param sopNo
      * @return
      */
     @SuppressWarnings("MybatisXMapperMethodInspection")
     IPage<Map> list(IPage<Map> iPage, @Param("type") String type, @Param("serviceId") Long serviceId,
             @Param("tableName") String tableName, @Param("fieldName") String fieldName,
             @Param("fieldValue") String fieldValue, @Param("dpr") DataPermissionDto dpr,
-            @Param("fieldOrder") String fieldOrder);
+            @Param("fieldOrder") String fieldOrder, @Param("leadId") Long leadId, @Param("crmUserId") Long crmUserId,
+            @Param("customName") String customName, @Param("taskKey") String taskKey, @Param("crmName") String crmName,
+            @Param("sopNo") String sopNo);
 
     /**
      * 根据crmNo查询在途的sop信息

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

@@ -34,4 +34,12 @@ public interface TBSopQuickSearchService extends IService<TBSopQuickSearch> {
      * @return
      */
     boolean save(SopQuickSearchParam sopQuickSearchParam);
+
+    /**
+     * 根据id删除
+     *
+     * @param id
+     * @return
+     */
+    boolean delete(Long id);
 }

+ 3 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -824,7 +824,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         IPage<Map> list = this.baseMapper.list(
                 new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()),
                 Objects.nonNull(sopInfoListParam.getType()) ? sopInfoListParam.getType().name() : null,
-                sopInfoListParam.getServiceId(), tableName, fieldName, fieldValue, dpr, fieldOrder);
+                sopInfoListParam.getServiceId(), tableName, fieldName, fieldValue, dpr, fieldOrder,
+                sopInfoListParam.getLeadId(), sopInfoListParam.getCrmUserId(), sopInfoListParam.getCustomName(),
+                sopInfoListParam.getTaskKey(), sopInfoListParam.getCrmName(), sopInfoListParam.getSopNo());
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         for (Map m : list.getRecords()) {
             String engineerUsersId = (String) m.get("engineer_users_id");

+ 63 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopQuickSearchServiceImpl.java

@@ -1,12 +1,17 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.cache.CommonCacheService;
+import com.qmth.sop.business.entity.SysConfig;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBSopQuickSearch;
+import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.business.mapper.TBSopQuickSearchMapper;
 import com.qmth.sop.business.service.TBSopQuickSearchService;
+import com.qmth.sop.business.service.TFCustomFlowService;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
@@ -19,7 +24,10 @@ import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
 
 /**
  * <p>
@@ -33,6 +41,15 @@ import java.util.List;
 public class TBSopQuickSearchServiceImpl extends ServiceImpl<TBSopQuickSearchMapper, TBSopQuickSearch>
         implements TBSopQuickSearchService {
 
+    @Resource
+    CommonCacheService commonCacheService;
+
+    @Resource
+    TFCustomFlowService tfCustomFlowService;
+
+    @Resource
+    TBSopQuickSearchService tbSopQuickSearchService;
+
     /**
      * sop快捷搜索列表
      *
@@ -42,7 +59,14 @@ public class TBSopQuickSearchServiceImpl extends ServiceImpl<TBSopQuickSearchMap
      */
     @Override
     public List<TBSopQuickSearch> list(TFCustomTypeEnum type, SopQuickSearchTypeEnum contentType) {
-        return null;
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        QueryWrapper<TBSopQuickSearch> tbSopQuickSearchQueryWrapper = new QueryWrapper<>();
+        tbSopQuickSearchQueryWrapper.lambda().eq(TBSopQuickSearch::getType, type)
+                .eq(TBSopQuickSearch::getUserId, sysUser.getId());
+        if (Objects.nonNull(contentType)) {
+            tbSopQuickSearchQueryWrapper.lambda().eq(TBSopQuickSearch::getContentType, contentType);
+        }
+        return this.list(tbSopQuickSearchQueryWrapper);
     }
 
     /**
@@ -56,7 +80,32 @@ public class TBSopQuickSearchServiceImpl extends ServiceImpl<TBSopQuickSearchMap
     public boolean save(SopQuickSearchParam sopQuickSearchParam) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         try {
-
+            SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SOP_QUICK_COUNT);
+            Objects.requireNonNull(sysConfig, "未设置sop快捷条数");
+            Objects.requireNonNull(sysConfig.getConfigValue(), "未设置sop快捷条数值");
+            Integer count = Integer.parseInt(sysConfig.getConfigValue());
+            TBSopQuickSearch tbSopQuickSearch = null;
+            if (Objects.isNull(sopQuickSearchParam.getId())) {//新增
+                Integer countDb = this.count(new QueryWrapper<TBSopQuickSearch>().lambda()
+                        .eq(TBSopQuickSearch::getType, sopQuickSearchParam.getType())
+                        .eq(TBSopQuickSearch::getUserId, sysUser.getId())
+                        .eq(TBSopQuickSearch::getContentType, sopQuickSearchParam.getContentType()));
+                if (countDb.intValue() > count.intValue()) {
+                    throw ExceptionResultEnum.ERROR.exception(
+                            "超过[" + sopQuickSearchParam.getContentType().getTitle() + "]最大条数" + count);
+                }
+                TFCustomFlow maxTfCustomFlow = tfCustomFlowService.findMaxVersion(null, null,
+                        sopQuickSearchParam.getType());
+                Optional.ofNullable(maxTfCustomFlow)
+                        .orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+                tbSopQuickSearch = new TBSopQuickSearch(sopQuickSearchParam, maxTfCustomFlow.getFlowDeploymentId(),
+                        maxTfCustomFlow.getVersion(), sysUser.getId());
+            } else {//更新
+                tbSopQuickSearch = this.getById(sopQuickSearchParam.getId());
+                Objects.requireNonNull(tbSopQuickSearch, "未找到sop快捷数据");
+                tbSopQuickSearch.updateInfo(sopQuickSearchParam);
+            }
+            tbSopQuickSearchService.saveOrUpdate(tbSopQuickSearch);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof DuplicateKeyException) {
@@ -73,4 +122,16 @@ public class TBSopQuickSearchServiceImpl extends ServiceImpl<TBSopQuickSearchMap
         }
         return false;
     }
+
+    /**
+     * 根据id删除
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    @Transactional
+    public boolean delete(Long id) {
+        return tbSopQuickSearchService.removeById(id);
+    }
 }

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

@@ -161,4 +161,21 @@ CREATE TABLE `t_b_sop_quick_search` (
 
 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);
+VALUES(40, NULL, 'sop.quick.count', 'sop快捷条数', '10', NULL, 1, 1, 1, NULL, NULL, NULL);
+
+-- 2024-05-22
+UPDATE sys_privilege
+SET name='教务处SOP管理', url='office', `type`='MENU', parent_id=40, `sequence`=1, property=NULL, related='3034,3035,3091,3092,3093', enable=1, default_auth=0, front_display=1
+WHERE id=41;
+UPDATE sys_privilege
+SET name='研究生SOP管理', url='cloudMark', `type`='MENU', parent_id=40, `sequence`=2, property=NULL, related='3034,3035,3091,3092,3093', enable=1, default_auth=0, front_display=1
+WHERE id=42;
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3091, 'sop快捷搜索保存', '/api/admin/sop/quick/save', 'URL', 40, 14, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3092, 'sop快捷搜索列表', '/api/admin/sop/quick/list', 'URL', 40, 15, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3093, 'sop快捷搜索删除', '/api/admin/sop/quick/delete', 'URL', 40, 16, 'AUTH', NULL, 1, 1, 0);

+ 25 - 0
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -108,6 +108,31 @@
             <if test="fieldValue != null and fieldValue != ''">
                 ${fieldValue}
             </if>
+            <if test="leadId != null and leadId != ''">
+                and tbc.lead_id = #{leadId}
+            </if>
+            <if test="crmUserId != null and crmUserId != ''">
+                and tbc.crm_user_id = #{leadId}
+            </if>
+            <if test="customName != null and customName != ''">
+                and sc.name like concat('%', #{customName} , '%')
+            </if>
+            <if test="crmName != null and crmName != ''">
+                and tbc.name like concat('%', #{crmName} , '%')
+            </if>
+            <if test="sopNo != null and sopNo != ''">
+                and tbsi.sop_no like concat('%', #{sopNo} , '%')
+            </if>
+            <if test="taskKey != null and taskKey != ''">
+                <choose>
+                    <when test="taskKey == '已完结'">
+                        and tffa.status IN ('FINISH')
+                    </when>
+                    <otherwise>
+                        and art.NAME_ = #{taskKey}
+                    </otherwise>
+                </choose>
+            </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasThirdPmo">