Browse Source

qiugou code submission

ltt 2 years ago
parent
commit
a48b0cb7cb

+ 26 - 16
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -51,9 +51,10 @@ public class KwpWantBuyService {
     public PageRes<WantBuySelectRes> buyHallList(WantBuySelectParam wantBuySelectParam){
         //如果有求购方式的查询条件,需要先查询出求购方式的id
         if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
-            List<Long> longs = setWantBuyTradings(wantBuySelectParam);
-            wantBuySelectParam.setTradings(longs);
+            List<Long> longList = stringToLongList(wantBuySelectParam.getTrading());
+            wantBuySelectParam.setTradings(longList);
         }
+        PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
         List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.queryBuyHallList(wantBuySelectParam);
         if (CollectionUtils.isEmpty(wantBuyDto)) {
             return new PageRes<>();
@@ -73,8 +74,8 @@ public class KwpWantBuyService {
 
     public PageRes<WantBuySelectRes> select(WantBuySelectParam wantBuySelectParam) {
         if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
-            List<Long> longs = setWantBuyTradings(wantBuySelectParam);
-            wantBuySelectParam.setTradings(longs);
+            List<Long> longList = stringToLongList(wantBuySelectParam.getTrading());
+            wantBuySelectParam.setTradings(longList);
         }
         if (StringUtils.isNotBlank(wantBuySelectParam.getStatus())) {
             List<String> stringList = Arrays.asList(wantBuySelectParam.getStatus().split(","));
@@ -100,16 +101,25 @@ public class KwpWantBuyService {
         return new PageRes<>(new PageInfo<>(wantBuyDto));
     }
 
-    private List<Long> setWantBuyTradings(WantBuySelectParam wantBuySelectParam) {
-        List<String> stringList = Arrays.asList(wantBuySelectParam.getTrading().split(","));
-        LambdaQueryWrapper<KwoWantBuyTrading> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(KwoWantBuyTrading::getTrading, stringList);
-        List<KwoWantBuyTrading> wantBuyTradings = kwpWantBuyTradingMapper.selectList(wrapper);
-        //从上面的集合拿出所有tranding循环拼接成一个List<String>集合
-        return wantBuyTradings.stream().map(KwoWantBuyTrading::getWantBuyId).distinct().collect(Collectors.toList());
-
+    private List<Long> stringToLongList(String str) {
+        if (StringUtils.isBlank(str)) {
+            return null;
+        }
+        return Arrays.stream(str.split(","))
+                .map(Long::parseLong)
+                .collect(Collectors.toList());
     }
 
+//    private List<Long> setWantBuyTradings(WantBuySelectParam wantBuySelectParam) {
+//        List<String> stringList = Arrays.asList(wantBuySelectParam.getTrading().split(","));
+//        LambdaQueryWrapper<KwoWantBuyTrading> wrapper = new LambdaQueryWrapper<>();
+//        wrapper.in(KwoWantBuyTrading::getTrading, stringList);
+//        List<KwoWantBuyTrading> wantBuyTradings = kwpWantBuyTradingMapper.selectList(wrapper);
+//        //从上面的集合拿出所有tranding循环拼接成一个List<String>集合
+//        return wantBuyTradings.stream().map(KwoWantBuyTrading::getWantBuyId).distinct().collect(Collectors.toList());
+//
+//    }
+
 
     /**
      * @Desc 求购草稿新增
@@ -358,9 +368,9 @@ public class KwpWantBuyService {
 
 
     /**
+     * @Desc: 根据id查询求购信息
      * @param id
      * @return
-     * @Desc: 根据id查询求购信息
      */
     public KwoWantBuy selectOneById(Long id) {
         LambdaQueryWrapper<KwoWantBuy> queryWrapper = new LambdaQueryWrapper<>();
@@ -370,14 +380,14 @@ public class KwpWantBuyService {
     }
 
     /**
+     * @Desc: 查询求购角标统计数量
      * @param
      * @return
-     * @Desc: 查询求购角标统计数量
      */
     public Map statistic(WantBuySelectParam params) {
         if (StringUtils.isNotBlank(params.getTrading())) {
-            List<Long> longs = setWantBuyTradings(params);
-            params.setTradings(longs);
+            List<Long> longList = stringToLongList(params.getTrading());
+            params.setTradings(longList);
         }
         if (StringUtils.isNotBlank(params.getStatus())) {
             List<String> stringList = Arrays.asList(params.getStatus().split(","));

+ 42 - 48
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml

@@ -2,6 +2,21 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.order.dao.KwpWantBuyMapper">
 
+    <sql id="Base_Column_List">
+        kb.id
+        ,kb.`name`
+        , kb.ent_name entName
+        , kb.goods_type goodsType
+        , kb.spec
+        , kb.price
+        , kb.amount
+        , kb.status
+        , kb.remark
+        , kb.create_time createTime
+        , kt.want_buy_id wantBuyId
+        , kt.trading trading
+    </sql>
+
     <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
         <id column="id" property="id"/>
         <result column="name" property="name"/>
@@ -21,43 +36,29 @@
     </resultMap>
 
     <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
-        select id
-        ,`name`
-        ,ent_name entName
-        ,goods_type goodsType
-        , spec
-        , price
-        , amount
-        , status
-        , remark
-        , create_time createTime
-        , update_time updateTime
-        from kwo_want_buy
+        select
+        <include refid="Base_Column_List" />
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
         <where>
-            del_flag = 0
-            <if test="wantBuyReq.statuss != null and wantBuyReq.statuss.size() > 0">
-                and status in
-                <foreach collection="wantBuyReq.statuss" item="item" open="(" close=")" separator=",">
-                    #{item}
-                </foreach>
-            </if>
+            kb.del_flag = 0 and kt.del_flag = 0
             <if test="wantBuyReq.startCreateTime != null and wantBuyReq.endCreateTime != null">
-                and create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
+                and kb.create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
                 #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
-                and id in
+                and kt.trading in
                 <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
             <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
                 and (
-                `name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
+                kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
                 )
             </if>
         </where>
-        order by create_time desc
+        group by kb.id
+        order by kb.create_time desc
     </select>
 
 <!--    <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
@@ -70,69 +71,62 @@
     <select id="tradingSql" resultMap="tradIngMap">
         select want_buy_id wantBuyId, trading
         from kwo_want_buy_trading
+        where want_buy_id = #{wantBuyId}
     </select>
 
 
 
     <select id="statisticsCount"  resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
-        select `status` value
-        from kwo_want_buy
+        select kb.`status` value
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
         <where>
-            del_flag = 0
+            kb.del_flag = 0 and kt.del_flag = 0
             <if test="wantBuyReq.statuss != null">
-                and status = #{wantBuyReq.statuss}
+                and kb.status = #{wantBuyReq.statuss}
             </if>
             <if test="wantBuyReq.startCreateTime != null and wantBuyReq.endCreateTime != null">
-                and create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
+                and kb.create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
                 #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
-                and id in
+                and kt.trading in
                 <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
             <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
                 and (
-                `name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
+                kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
                 )
             </if>
         </where>
-        order by create_time desc
+        order by kb.create_time desc
     </select>
 
 
     <select id="queryBuyHallList"  resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
-        select id
-             ,`name`
-             , ent_name entName
-             , goods_type goodsType
-             , spec
-             , price
-             , amount
-             , status
-             , remark
-             , create_time createTime
-             , update_time updateTime
-        from kwo_want_buy
+        select
+            <include refid="Base_Column_List" />
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
         <where>
-            del_flag = 0
+            kb.del_flag = 0 and kt.del_flag = 0
             <if test="wantBuyReq.startCreateTime != null and wantBuyReq.endCreateTime != null">
-                and create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
+                and kb.create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
                 #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
             </if>
             <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
-                and id in
+                and kt.trading in
                 <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
             <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
                 and (
-                `name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
+                kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
                 )
             </if>
         </where>
-        order by create_time desc
+        group by kb.id
+        order by kb.create_time desc
     </select>
 </mapper>