Browse Source

Merge remote-tracking branch 'origin/children_day' into children_day

周箭河 4 years ago
parent
commit
9c67af489e

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ChildrenDayReserveDao.java

@@ -24,7 +24,7 @@ public interface ChildrenDayReserveDao extends BaseDAO<Integer, ChildrenDayReser
      * @param params
      * @param params
      * @return
      * @return
      */
      */
-    Integer countChildrenStatistics(Map<String, Object> params);
+    int countChildrenStatistics(Map<String, Object> params);
 
 
     /**
     /**
      * 根据用户id获取用户预约信息
      * 根据用户id获取用户预约信息

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ChildrenStatisticsDetailDto.java

@@ -7,7 +7,7 @@ public class ChildrenStatisticsDetailDto {
 
 
     private Integer userId;
     private Integer userId;
 
 
-    private boolean isReserve;
+    private boolean isReserve = false;
 
 
     public String getPhone() {
     public String getPhone() {
         return phone;
         return phone;

+ 39 - 9
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ChildrenStatisticsDto.java

@@ -4,29 +4,59 @@ import java.math.BigDecimal;
 
 
 public class ChildrenStatisticsDto {
 public class ChildrenStatisticsDto {
 
 
+    private Integer organId;
+
+    private Integer cooperationOrganId;
+
+    private String musicGroupId;
+
     private String organName;
     private String organName;
 
 
     private String cooperationOrganName;
     private String cooperationOrganName;
 
 
     private  String musicGroupName;
     private  String musicGroupName;
 
 
-    private  Integer normalNum;
+    private  Integer normalNum = 0;
+
+    private Integer reserveNum = 0;
 
 
-    private Integer reserveNum;
+    private Integer noReserveNum = 0;
 
 
-    private Integer noReserveNum;
+    private Integer instrumentalMusicNum = 0;
 
 
-    private Integer instrumentalMusicNum;
+    private Integer musicTheoryNum = 0;
 
 
-    private Integer musicTheoryNum;
+    private Integer buyVipNum = 0;
 
 
-    private Integer buyVipNum;
+    private BigDecimal buyVipAmount = BigDecimal.ZERO;
 
 
-    private BigDecimal buyVipAmount;
+    private Integer buyMusicTheoryNum = 0;
 
 
-    private Integer buyMusicTheoryNum;
+    private BigDecimal buyMusicTheoryAmount = BigDecimal.ZERO;
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
 
 
-    private BigDecimal buyMusicTheoryAmount;
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
+    }
+
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
+    }
+
+    public String getMusicGroupId() {
+        return musicGroupId;
+    }
+
+    public void setMusicGroupId(String musicGroupId) {
+        this.musicGroupId = musicGroupId;
+    }
 
 
     public String getOrganName() {
     public String getOrganName() {
         return organName;
         return organName;

+ 15 - 10
mec-biz/src/main/resources/config/mybatis/ChildrenDayReserveMapper.xml

@@ -87,14 +87,13 @@
         <result property="reserveNum" column="reserve_num_"/>
         <result property="reserveNum" column="reserve_num_"/>
     </resultMap>
     </resultMap>
     <select id="queryChildrenStatistics" resultMap="ChildrenStatisticsDtoMap">
     <select id="queryChildrenStatistics" resultMap="ChildrenStatisticsDtoMap">
-        SELECT o.name_ organ_name_,co.name_ cooperation_organ_name_,mg.name_ music_group_name_,COUNT(sr.user_id_)
-        normal_num_,
-        COUNT(CASE WHEN cdr.is_reserve_ = 1 THEN 1 ELSE NULL END) 'reserve_num_',
-        COUNT(CASE WHEN cdr.is_reserve_ = 0 THEN 1 ELSE NULL END) 'no_reserve_num_'
+        SELECT o.name_ organ_name_,co.name_ cooperation_organ_name_,mg.name_ music_group_name_,COUNT(sr.user_id_) normal_num_,cdr.organ_id_,
+        cdr.cooperation_organ_id_,cdr.music_group_id_,
+        COUNT(DISTINCT CASE WHEN cdr.is_reserve_ = 1 THEN 1 ELSE NULL END) 'reserve_num_',
+        COUNT(DISTINCT CASE WHEN cdr.is_reserve_ = 0 THEN 1 ELSE NULL END) 'no_reserve_num_'
         FROM children_day_reserve cdr
         FROM children_day_reserve cdr
         LEFT JOIN music_group mg ON mg.id_ = cdr.music_group_id_
         LEFT JOIN music_group mg ON mg.id_ = cdr.music_group_id_
-        LEFT JOIN student_registration sr ON sr.music_group_id_ = cdr.music_group_id_ AND sr.music_group_status_ =
-        'NORMAL'
+        LEFT JOIN student_registration sr ON sr.music_group_id_ = cdr.music_group_id_ AND sr.music_group_status_ = 'NORMAL' AND cdr.user_id_ = sr.user_id_
         LEFT JOIN cooperation_organ co ON co.id_ = cdr.cooperation_organ_id_
         LEFT JOIN cooperation_organ co ON co.id_ = cdr.cooperation_organ_id_
         LEFT JOIN organization o ON o.id_ = cdr.organ_id_
         LEFT JOIN organization o ON o.id_ = cdr.organ_id_
         <include refid="queryChildrenStatisticsSql"/>
         <include refid="queryChildrenStatisticsSql"/>
@@ -102,11 +101,11 @@
         ORDER BY cdr.id_ DESC
         ORDER BY cdr.id_ DESC
         <include refid="global.limit"/>
         <include refid="global.limit"/>
     </select>
     </select>
-    <select id="countChildrenStatistics" resultType="java.lang.Integer">
-        SELECT COUNT(cdr.id_)
+    <select id="countChildrenStatistics" resultType="int">
+        SELECT COUNT(c.id_) FROM (SELECT COUNT(cdr.id_) id_
         FROM children_day_reserve cdr
         FROM children_day_reserve cdr
         <include refid="queryChildrenStatisticsSql"/>
         <include refid="queryChildrenStatisticsSql"/>
-        GROUP BY cdr.music_group_id_
+        GROUP BY cdr.music_group_id_) c
     </select>
     </select>
     <sql id="queryChildrenStatisticsSql">
     <sql id="queryChildrenStatisticsSql">
         <where>
         <where>
@@ -134,7 +133,7 @@
         <result property="isReserve" column="is_reserve_"/>
         <result property="isReserve" column="is_reserve_"/>
         <result property="phone" column="phone_"/>
         <result property="phone" column="phone_"/>
     </resultMap>
     </resultMap>
-    <select id="countChildrenStatisticsDetail" resultType="java.lang.Integer">
+    <select id="countChildrenStatisticsDetail" resultType="int">
         SELECT COUNT(cdr.id_) FROM children_day_reserve cdr
         SELECT COUNT(cdr.id_) FROM children_day_reserve cdr
         LEFT JOIN sys_user su ON su.id_ = cdr.user_id_
         LEFT JOIN sys_user su ON su.id_ = cdr.user_id_
         <include refid="queryChildrenStatisticsDetailSql"/>
         <include refid="queryChildrenStatisticsDetailSql"/>
@@ -155,6 +154,12 @@
             <if test="isReserve != null">
             <if test="isReserve != null">
                 AND cdr.is_reserve_ = #{isReserve}
                 AND cdr.is_reserve_ = #{isReserve}
             </if>
             </if>
+            <if test="musicGroupId != null and musicGroupId != ''">
+                AND cdr.music_group_id_ = #{musicGroupId}
+            </if>
+            <if test="musicGroupId == null">
+                AND cdr.music_group_id_ IS NULL
+            </if>
         </where>
         </where>
     </sql>
     </sql>
 </mapper>
 </mapper>

+ 102 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -139,6 +139,108 @@ public class ExportController extends BaseController {
     private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
     private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
     @Autowired
     @Autowired
     private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
     private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
+    @Autowired
+    private ChildrenDayReserveService childrenDayReserveService;
+
+    @ApiOperation(value = "21年暑期考级活动统计页面详情导出")
+    @PostMapping("export/statisticsDetailPage")
+    @PreAuthorize("@pcs.hasPermissions('export/statisticsDetailPage')")
+    public void statisticsDetailPage(HttpServletResponse response, ChildrenReserveQueryInfo queryInfo) throws IOException {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            throw new BizException("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                throw new BizException("非法请求");
+            }
+        }
+        queryInfo.setPage(1);
+        queryInfo.setRows(49999);
+        List<ChildrenStatisticsDetailDto> rows = childrenDayReserveService.queryStatisticsDetailPage(queryInfo).getRows();
+        if(rows.size() < 1){
+           throw new BizException("没有可导出数据");
+       }
+        OutputStream outputStream = response.getOutputStream();
+        try {
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员姓名", "学员编号", "手机号", "是否预约"}, new String[]{
+                    "username", "userId", "phone", "isReserve == true ?'是':'否'"}, rows);
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attac:wq" +
+                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");
+            response.flushBuffer();
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    @ApiOperation(value = "21年暑期考级活动统计页面导出")
+    @PostMapping("export/statisticsPage")
+    @PreAuthorize("@pcs.hasPermissions('export/statisticsPage')")
+    public void statisticsPage(HttpServletResponse response, ChildrenReserveQueryInfo queryInfo) throws IOException {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            throw new BizException("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                throw new BizException("非法请求");
+            }
+        }
+        queryInfo.setPage(1);
+        queryInfo.setRows(49999);
+        List<ChildrenStatisticsDto> rows = childrenDayReserveService.queryStatisticsPage(queryInfo).getRows();
+        if(rows.size() < 1){
+           throw new BizException("没有可导出数据");
+       }
+        OutputStream outputStream = response.getOutputStream();
+        try {
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部名称", "合作单位", "乐团名称", "在读人数",
+                    "预约人数", "未预约人数", "器乐考级人数", "乐理考级人数", "VIP课购买人数", "VIP课成交金额", "乐理课购买人数", "乐理课成交金额"}, new String[]{
+                    "organName", "cooperationOrganName", "musicGroupName", "normalNum",
+                    "reserveNum", "noReserveNum", "instrumentalMusicNum", "musicTheoryNum","buyVipNum","buyVipAmount","buyMusicTheoryNum","buyMusicTheoryAmount"}, rows);
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attac:wq" +
+                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");
+            response.flushBuffer();
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 
 
     @ApiOperation(value = "学生个人账户余额导出")
     @ApiOperation(value = "学生个人账户余额导出")
     @PostMapping("export/userCashAccountDetail")
     @PostMapping("export/userCashAccountDetail")