Эх сурвалжийг харах

fix. 追加工时查询更改

caozixuan 7 сар өмнө
parent
commit
7cf2b61c54

+ 44 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/SopInfoDto.java

@@ -0,0 +1,44 @@
+package com.qmth.sop.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 派单详情信息
+ * @Author: CaoZixuan
+ * @Date: 2024-11-08
+ */
+public class SopInfoDto {
+
+    @ApiModelProperty("sopNo")
+    private String sopNo;
+
+    @ApiModelProperty("客户名称")
+    private String customName;
+
+    @ApiModelProperty("科目名称")
+    private String courseName;
+
+    public String getSopNo() {
+        return sopNo;
+    }
+
+    public void setSopNo(String sopNo) {
+        this.sopNo = sopNo;
+    }
+
+    public String getCustomName() {
+        return customName;
+    }
+
+    public void setCustomName(String customName) {
+        this.customName = customName;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+}

+ 7 - 5
sop-business/src/main/java/com/qmth/sop/business/bean/result/CanChooseSopResult.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.business.bean.result;
 
+import com.qmth.sop.business.bean.dto.SopInfoDto;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.util.List;
@@ -10,18 +11,19 @@ import java.util.List;
  * @Date: 2024-11-05
  */
 public class CanChooseSopResult {
+
     @ApiModelProperty("sopNo集合")
-    private List<String> sopNoList;
+    private List<SopInfoDto> crmDetailInfo;
 
     @ApiModelProperty("是否需要选择(区协不用选择sopNo)")
     private Boolean needChoose;
 
-    public List<String> getSopNoList() {
-        return sopNoList;
+    public List<SopInfoDto> getCrmDetailInfo() {
+        return crmDetailInfo;
     }
 
-    public void setSopNoList(List<String> sopNoList) {
-        this.sopNoList = sopNoList;
+    public void setCrmDetailInfo(List<SopInfoDto> crmDetailInfo) {
+        this.crmDetailInfo = crmDetailInfo;
     }
 
     public Boolean getNeedChoose() {

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingAddMapper.java

@@ -1,7 +1,11 @@
 package com.qmth.sop.business.mapper;
 
+import com.qmth.sop.business.bean.dto.SopInfoDto;
 import com.qmth.sop.business.entity.TBDingAdd;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TBDingAddMapper extends BaseMapper<TBDingAdd> {
 
+    /**
+     * 根据serviceId和userId查询可追加的sop信息
+     *
+     * @param serviceId 服务单元id
+     * @param userId    被追加用户id
+     * @return 信息
+     */
+    List<SopInfoDto> findSopInfoByServiceIdAndUserId(@Param("serviceId") Long serviceId, @Param("userId") Long userId);
 }

+ 1 - 18
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingAddServiceImpl.java

@@ -4,25 +4,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.params.DingAddParam;
 import com.qmth.sop.business.bean.result.CanChooseSopResult;
-import com.qmth.sop.business.entity.TBCrmDetail;
 import com.qmth.sop.business.entity.TBDingAdd;
-import com.qmth.sop.business.entity.TBUserArchivesAllocation;
 import com.qmth.sop.business.mapper.TBDingAddMapper;
 import com.qmth.sop.business.service.TBCrmDetailService;
 import com.qmth.sop.business.service.TBDingAddService;
 import com.qmth.sop.business.service.TBUserArchivesAllocationService;
 import com.qmth.sop.business.service.TBUserArchivesService;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
-import com.qmth.sop.common.enums.SopRoleTypeEnum;
-import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.List;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -52,18 +46,7 @@ public class TBDingAddServiceImpl extends ServiceImpl<TBDingAddMapper, TBDingAdd
             result.setNeedChoose(false);
         } else {
             result.setNeedChoose(true);
-            List<Long> crmDetailIdList = tbUserArchivesAllocationService.list(
-                            new QueryWrapper<TBUserArchivesAllocation>().lambda().select(TBUserArchivesAllocation::getCrmDetailId)
-                                    .eq(TBUserArchivesAllocation::getServiceId, serviceId)
-                                    .eq(TBUserArchivesAllocation::getUserId, userId).ne(TBUserArchivesAllocation::getSopRoleType, SopRoleTypeEnum.REGION_COORDINATOR)).stream()
-                    .map(TBUserArchivesAllocation::getCrmDetailId).distinct().collect(Collectors.toList());
-
-            if (CollectionUtils.isNotEmpty(crmDetailIdList)) {
-                List<String> sopNoList = tbCrmDetailService.listByIds(crmDetailIdList).stream().map(TBCrmDetail::getSopNo).distinct().collect(Collectors.toList());
-                if (CollectionUtils.isNotEmpty(sopNoList)) {
-                    result.setSopNoList(sopNoList);
-                }
-            }
+            result.setCrmDetailInfo(this.baseMapper.findSopInfoByServiceIdAndUserId(serviceId, userId));
         }
         return result;
     }

+ 28 - 0
sop-business/src/main/resources/mapper/TBDingAddMapper.xml

@@ -2,4 +2,32 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.TBDingAddMapper">
 
+    <select id="findSopInfoByServiceIdAndUserId" resultType="com.qmth.sop.business.bean.dto.SopInfoDto">
+        SELECT
+            tbcd.sop_no AS sopNo,
+            sc.name AS customName,
+            tbcd.course_name AS courseName
+        FROM
+            t_b_crm_detail tbcd
+                LEFT JOIN
+            t_b_crm tbc ON tbcd.crm_no = tbc.crm_no
+                LEFT JOIN
+            sys_custom sc ON tbc.custom_id = sc.id
+        <where>
+            AND EXISTS( SELECT
+                        1
+                    FROM
+                        t_b_user_archives_allocation tbuaa
+                    WHERE
+                        tbuaa.crm_detail_id = tbcd.id
+                        AND tbuaa.sop_role_type != 'REGION_COORDINATOR'
+                      <if test="serviceId != null">
+                          AND tbuaa.service_id = #{serviceId}
+                      </if>
+                      <if test="userId != null">
+                          AND tbuaa.user_id = #{userId}
+                      </if>
+                      )
+        </where>
+    </select>
 </mapper>