Sfoglia il codice sorgente

excel 显示与导出

Longlin 5 anni fa
parent
commit
ce1b74fbb2

+ 2 - 2
whepi-doc/group.sql

@@ -17,7 +17,7 @@ create table jm_buy (
     INDEX user_id(user_id) USING BTREE
 )
 ENGINE = InnoDB
-DEFAULT CHARSET = utf8
+DEFAULT CHARSET = utf8mb4
 COMMENT = '居民团购表'
 ;
 
@@ -41,6 +41,6 @@ create table jm_tuangou (
     INDEX uptown_id(uptown_id) USING BTREE
 )
 ENGINE = InnoDB
-DEFAULT CHARSET = utf8
+DEFAULT CHARSET = utf8mb4
 COMMENT = '团购表'
 ;

+ 1 - 1
whepi-ui/templates/groupBuying/groupBuyingXx.ftl

@@ -123,7 +123,7 @@
     });
 
     $('#gb_ck').on('click', function () {
-        console.log("查看");
+        window.location.href = "/yeweihui/tuangou/member/list.html?jmId=" + tgItem.jmId + "&userId=" + userId;
     });
 
     function goback() {

+ 43 - 0
whepi-ui/templates/home/frag.head.ftl

@@ -82,6 +82,49 @@
         .tuan_gou_weui_tab_bd_item_active {
             display: block !important;
         }
+
+        .msgInfoTabHeaderDiv {
+            background-color: gray;
+            width: 100%;
+            height: 8vw;
+            display: -webkit-flex;
+            display: flex;
+            text-align: center;
+        }
+
+        .msgInfoTabFooterDiv {
+            background-color: gray;
+            width: 100%;
+            height: 0.7vw;
+        }
+
+        .msgInfoTabColumn1 {
+            width: 30%;
+            background-color: white;
+            height: 7.3vw;
+            line-height: 7.3vw;
+            margin-left: 0.5vw;
+            margin-top: 0.7vw;
+        }
+
+        .msgInfoTabColumn2 {
+            width: 26%;
+            background-color: white;
+            height: 7.3vw;
+            line-height: 7.3vw;
+            margin-left: 0.5vw;
+            margin-top: 0.7vw;
+        }
+
+        .msgInfoTabColumn3 {
+            width: 42%;
+            background-color: white;
+            height: 7.3vw;
+            line-height: 7.3vw;
+            margin-left: 0.5vw;
+            margin-right: 0.5vw;
+            margin-top: 0.7vw;
+        }
     </style>
 </head>
 <span hidden="hidden" id="id"></span>

+ 83 - 0
whepi-ui/templates/yeweihui/tuangouMemberList.ftl

@@ -0,0 +1,83 @@
+<#assign title="参团详情"/>
+<#include "/home/frag.head.ftl" />
+
+<div class="weui-tab">
+    <div class="weui-btn-area" style="display: flex; flex-direction: row;">
+        <a class="weui-btn weui-btn_primary" href="javascript:goback();" style="width: 25vw; height: 6vh; line-height: 6vh;">返回</a>
+        <div style="width: 65%;"></div>
+    </div>
+
+    <div class="weui-btn-area">
+        <div style="display: flex; flex-direction: row; justify-content: space-around;">
+            <div id="tg_member_xiaoqu">敬业小区</div>
+            <div id="tg_member_num">当前已团: </div>
+        </div>
+
+        <div class="msgInfoTabHeaderDiv">
+            <div class="msgInfoTabColumn1">房间号</div>
+            <div class="msgInfoTabColumn2" style="text-align: center;">参团数量</div>
+            <div class="msgInfoTabColumn3">联系方式</div>
+        </div>
+        <div id="member_list">
+            <div class="msgInfoTabHeaderDiv">
+                <div class="msgInfoTabColumn1">房间号</div>
+                <div class="msgInfoTabColumn2" style="text-align: center;">参团数量</div>
+                <div class="msgInfoTabColumn3">联系方式</div>
+            </div>
+            <div class="msgInfoTabHeaderDiv">
+                <div class="msgInfoTabColumn1">房间号</div>
+                <div class="msgInfoTabColumn2" style="text-align: center;">参团数量</div>
+                <div class="msgInfoTabColumn3">联系方式</div>
+            </div>
+        </div>
+        <div class="msgInfoTabFooterDiv">
+        </div>
+
+        <div class="weui-btn-area" style="display: grid;">
+            <a id="tg_member_export" class="weui-btn weui-btn_primary" href="javascript:">导出清单</a>
+        </div>
+
+        <div id="tg_member_export_url">
+            <div class="weui-cells__title">复制下面下载链接到浏览器下载</div>
+            <div class="weui-cells">
+                <div class="weui-cell">
+                    <div class="weui-cell__bd">
+                        <input class="weui-input" type="text" id="tg_member_export_url_detail" readonly="readonly"/>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<#include "/home/frag.foot.ftl" />
+
+<script>
+
+    var userId = ${userId};
+    var tgItem = ${tgItemJson};
+
+    var members = ${members};
+
+    function goback() {
+        window.location.href = "/yeweihui/groupBuyingXx.html?jmId=" + tgItem.jmId + "&userId=" + userId;
+    }
+
+    $('#member_list').empty();
+    let totalNum = 0;
+    for (let i = 0; i < members.length; i++) {
+        let member = members[i];
+        totalNum += member.buyCount;
+
+        $('#member_list').append($('<div class="msgInfoTabHeaderDiv">\n' +
+            '                <div class="msgInfoTabColumn1">' + member.ridgepole + '-' + member.unit + '-' + member.houseNumber + '</div>\n' +
+            '                <div class="msgInfoTabColumn2" style="text-align: center;">' + member.buyCount + '</div>\n' +
+            '                <div class="msgInfoTabColumn3">' + member.phone + '</div>\n' +
+            '            </div>'))
+    }
+
+    $('#tg_member_xiaoqu').html(members[0].uptownName);
+    $('#tg_member_num').append(totalNum);
+    $("#tg_member_export").attr('href', '/yeweihui/tuangou/member/list/export?jmId=' + tgItem.jmId);
+    $('#tg_member_export_url_detail').val(window.location.hostname + '/yeweihui/tuangou/member/list/export?jmId=' + tgItem.jmId);
+</script>

+ 17 - 0
whepi-web/src/main/java/com/bofeng/dao/JmTuangouMemberDao.java

@@ -0,0 +1,17 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.JmTuangouMember;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface JmTuangouMemberDao extends BaseMapper<JmTuangouMember> {
+
+    List<JmTuangouMember> querMemberListByJmId(@Param("JmId") Long JmId);
+
+}

+ 38 - 0
whepi-web/src/main/java/com/bofeng/entity/JmTuangouMember.java

@@ -0,0 +1,38 @@
+package com.bofeng.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+@Data
+public class JmTuangouMember {
+
+    /**
+     * 栋
+     */
+    @ExcelProperty(value = "楼栋", index = 0)
+    private String ridgepole;
+    /**
+     * 单元
+     */
+    @ExcelProperty(value = "单元", index = 1)
+    private String unit;
+    /**
+     * 门牌号
+     */
+    @ExcelProperty(value = "门牌号", index = 2)
+    private String houseNumber;
+    /**
+     * 参团数量
+     */
+    @ExcelProperty(value = "参团数量", index = 3)
+    private Integer buyCount;
+    /**
+     * 联系方式
+     */
+    @ExcelProperty(value = "联系方式", index = 4)
+    private String phone;
+
+    private Integer uptownId;
+
+    private String uptownName;
+}

+ 21 - 0
whepi-web/src/main/java/com/bofeng/service/JmTuangouMemberService.java

@@ -0,0 +1,21 @@
+package com.bofeng.service;
+
+import com.bofeng.dao.JmTuangouMemberDao;
+import com.bofeng.entity.JmTuangouMember;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Service
+@Transactional(readOnly = true)
+public class JmTuangouMemberService {
+
+    @Autowired
+    private JmTuangouMemberDao jmTuangouMemberDao;
+
+    public List<JmTuangouMember> querMemberListByJmId (Long jmId) {
+        return jmTuangouMemberDao.querMemberListByJmId(jmId);
+    }
+}

+ 33 - 0
whepi-web/src/main/java/com/bofeng/wx/controller/YeWeiHuiController.java

@@ -53,6 +53,9 @@ public class YeWeiHuiController {
     @Autowired
     private RbMapper rbMapper;
 
+    @Autowired
+    private JmTuangouMemberService jmTuangouMemberService;
+
     @GetMapping("/yeweihui/home.html")
     public ModelAndView yeweihui(ModelMap model,@RequestParam(value = "userId") Long userId, @RequestParam(value = "show", required = false, defaultValue = "-") String show) {
 
@@ -307,6 +310,36 @@ public class YeWeiHuiController {
         return new ModelAndView("/groupBuying/groupBuyingXx.ftl", model);
     }
 
+    @GetMapping("/yeweihui/tuangou/member/list.html")
+    public ModelAndView tuangouMemberList(@Pd(name = "jmId") Long jmId, @Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
+
+        JmTuangou item = jmTuangouService.queryByJmId(jmId);
+
+        List<JmTuangouMember> members = jmTuangouMemberService.querMemberListByJmId(jmId);
+
+        model.put("tgItemJson", new JsonWapper(item));
+        model.put("tgItem", item);
+
+        model.put("members", YvanUtil.toJsonPretty(members));
+
+        model.put("userId", "\""+userId+"\"");
+
+        return new ModelAndView("/yeweihui/tuangouMemberList.ftl", model);
+    }
+
+    @ApiOperation("导出团购家庭信息")
+    @GetMapping("/yeweihui/tuangou/member/list/export")
+    @SneakyThrows
+    public void tgMembersExport(@Pd(name = "jmId") Long jmId,
+                               HttpServletResponse resp) {
+
+        List<JmTuangouMember> members = jmTuangouMemberService.querMemberListByJmId(jmId);
+
+        String fileName = "团购家庭信息";
+        ExcelUtils.writeSheet(JmTuangouMember.class, members).export(resp, fileName);
+
+    }
+
     @PostMapping("/yeweihui/groupBuyingCx/remark/add.json")
     public Model groupBuyingCxRemarkAdd(@Pd(name = "jmId") Long jmId, @Pd(name = "status", required = false, defaultValue = "0") Long status, @Pd(name = "remark", required = false) String remark) {
 

+ 5 - 7
whepi-web/src/main/resources/mapper/JmTuangouMapper.xml

@@ -3,35 +3,33 @@
 <mapper namespace="com.bofeng.dao.JmTuangouDao">
 
     <select id="queryTuangouListByUptownId" resultType="com.bofeng.entity.JmTuangou">
-        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
         from jm_tuangou a
         where uptown_id=#{uptownId}
     </select>
 
     <select id="queryTuangouListByUptownIdAndTitle" resultType="com.bofeng.entity.JmTuangou">
-        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
         from jm_tuangou a
         where uptown_id=#{uptownId} and tg_title like concat('%', #{title}, '%')
     </select>
 
     <select id="queryTuangouListByUserId" resultType="com.bofeng.entity.JmTuangou">
-        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
         from jm_tuangou a
         where user_id=#{userId}
     </select>
 
     <select id="queryTuangouListByUserIdAndTitle" resultType="com.bofeng.entity.JmTuangou">
-        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
         from jm_tuangou a
         where user_id=#{userId} and tg_title like concat('%', #{title}, '%')
     </select>
 
     <select id="selectJmTuangouByJmId" resultType="com.bofeng.entity.JmTuangou">
-
-        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
         from jm_tuangou a
         where jm_id=#{JmId}
-
     </select>
 
     <update id="updateRemarkByJmId">

+ 20 - 0
whepi-web/src/main/resources/mapper/JmTuangouMemberMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bofeng.dao.JmTuangouMemberDao">
+
+    <select id="querMemberListByJmId" resultType="com.bofeng.entity.JmTuangouMember">
+        select a.user_id,a.buy_count,a.phone, y.houseNumber, y.ridgepole, y.unit, y.uptown_id, y.uptown_name from jm_buy a
+        LEFT JOIN
+          (
+              select a.user_id, b.house_id, b.doorplate as houseNumber, c.uptown_id, c.ridgepole, c.unit, u.uptown_name
+              FROM sys_user_role a
+                       INNER JOIN sys_uptown_house b on a.property_id=b.house_id
+                       INNER JOIN sys_uptown_unit c on c.unit_id=b.unit_id
+                       INNER JOIN sys_uptown u on u.uptown_id = c.uptown_id
+              where a.user_id in (select user_id from jm_buy where jm_id=#{JmId})
+          ) y
+          on a.user_id=y.user_id
+        where a.jm_id=#{JmId}
+    </select>
+
+</mapper>