Browse Source

抽取专家 返回 专家姓名 采购品种 抽取时间

sunhh 2 năm trước cách đây
mục cha
commit
6d687ec7c8

+ 5 - 1
purchase-system/src/main/java/com/ozs/base/mapper/BaseExpertMapper.java

@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.base.domain.BaseExpert;
 import com.ozs.base.domain.BaseUnitInformation;
 import com.ozs.base.domain.vo.BaseExpertVo;
+import com.ozs.pm.doman.PmDemandExpertRef;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface BaseExpertMapper extends BaseMapper<BaseExpert> {
@@ -17,5 +19,7 @@ public interface BaseExpertMapper extends BaseMapper<BaseExpert> {
 
     Integer insertBaseUnitInformation(BaseUnitInformation baseUnitInformation);
 
-    List<String> getExpertNameList(@Param("demandId") Long demandId);
+    Map<String, String> getExpertNameList(@Param("expertList") List<Long> expertList);
+
+    List<PmDemandExpertRef> getExpertIdList(@Param("demandId") Long demandId);
 }

+ 11 - 2
purchase-system/src/main/java/com/ozs/base/service/impl/BaseExpertServiceImpl.java

@@ -103,9 +103,18 @@ public class BaseExpertServiceImpl extends ServiceImpl<BaseExpertMapper, BaseExp
         // 遍历项目 查询专家姓名
         for (PmDemandResVo pmDemandResVo : pmDemandResponseVoList) {
             Long demandId = pmDemandResVo.getDemandId();
-            List<String> expertNameList = baseExpertMapper.getExpertNameList(pmDemandResVo.getDemandId());
-            String expertNameStr = expertNameList.stream().collect(Collectors.joining(",", "{", "}"));
+            // 查询项目专家关联表 专家ID,关联时间
+            List<PmDemandExpertRef> pmDemandExpertRefList = baseExpertMapper.getExpertIdList(demandId);
+            // 专家ID列表
+            List<Long> expertList= pmDemandExpertRefList.stream().map(PmDemandExpertRef::getExpertId).collect(Collectors.toList());
+            // 获取抽取时间(列表中取其中一个时间)
+            Date accessTime = pmDemandExpertRefList.get(0).getAccessTime();
+            Map<String, String> map = baseExpertMapper.getExpertNameList(expertList);
+            String expertNameStr = map.get("expertName");
+            String varietyPurchaseStr = map.get("varietyPurchase");
             pmDemandResVo.setExpertNameStr(expertNameStr);
+            pmDemandResVo.setVarietyPurchaseStr(varietyPurchaseStr);
+            pmDemandResVo.setAccessTime(accessTime);
         }
         PageHelper.startPage(baseExpertVo.getPageNum().intValue(), baseExpertVo.getPageSize().intValue());
         PageInfo<PmDemandResVo> pageInfo = new PageInfo<>(pmDemandResponseVoList);

+ 8 - 0
purchase-system/src/main/java/com/ozs/pm/doman/vo/responseVo/PmDemandResVo.java

@@ -255,4 +255,12 @@ public class PmDemandResVo extends BaseEntity
      * 抽取专家名称
      */
     private String expertNameStr;
+    /**
+     * 抽取专家的采购品种
+     */
+    private String varietyPurchaseStr;
+    /**
+     * 抽取时间
+     */
+    private Date accessTime;
 }

+ 6 - 2
purchase-system/src/main/resources/mapper/base/BaseExpertMapper.xml

@@ -158,7 +158,11 @@
         </trim>
     </insert>
 
-    <select id="getExpertNameList" resultType="java.lang.String" parameterType="java.lang.Long">
-        select expert_name from base_expert where id in (select expert_id from pm_demand_expert_ref where demand_id = #{demandId})
+    <select id="getExpertIdList" resultType="com.ozs.pm.doman.PmDemandExpertRef" parameterType="java.lang.Long">
+        select * from pm_demand_expert_ref where demand_id = #{demandId}
+    </select>
+
+    <select id="getExpertNameList" resultType="java.util.Map" parameterType="java.util.List">
+        select GROUP_CONCAT(variety_purchase) varietyPurchase, GROUP_CONCAT(expert_name) expertName from base_expert where id in #{expertList}
     </select>
 </mapper>