소스 검색

机构分析统计

huangzhiguo 2 년 전
부모
커밋
96680c00c5

+ 1 - 1
src/main/java/com/caimei/modules/user/service/NewCmClubService.java

@@ -297,7 +297,7 @@ public class NewCmClubService extends CrudService<NewCmClubDao, NewCmClub> {
                 number += 3;
             }
             if (StringUtils.isNotBlank(clubStatistics.getHeadpic())) {
-                number += 6;
+                number += 5;
             }
             if (StringUtils.isNotBlank(clubStatistics.getSocialCreditCode())) {
                 number += 5;

+ 47 - 7
src/main/java/com/caimei/modules/user/web/newUser/AgencyController.java

@@ -50,14 +50,15 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.swing.filechooser.FileSystemView;
 import java.awt.*;
 import java.awt.datatransfer.StringSelection;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -1422,14 +1423,21 @@ public class AgencyController extends BaseController {
 
     @ResponseBody
     @RequestMapping(value = "/club/export")
-    public void easyExcel(ClubStatistics statistics) {
-        String fileName = "机构分析统计.xlsx";
+    public void easyExcel(ClubStatistics statistics, HttpServletResponse response, RedirectAttributes redirectAttributes) {
+        String fileName = "club_Data.xlsx";
         String template = Global.getConfig("export.template");
         String templataFileName = template + "/club_analyse_tabulation.xlsx";
+        String name = "";
+        String path = "";
         try {
+
+            ServletOutputStream os = response.getOutputStream();
             FileSystemView view = FileSystemView.getFileSystemView();
             File homeDirectory = view.getHomeDirectory();
-            fileName = homeDirectory+"/"+System.currentTimeMillis()+fileName;
+            name = System.currentTimeMillis()+fileName;
+            path = homeDirectory+"\\";
+            fileName = path+name;
+
             List<ClubStatistics> statisticsList = newCmClubService.exportExcel(statistics);
             //得到模板文件路径(线上直接读取服务器位置文件)
             String config = Global.getConfig("cm.config");
@@ -1440,11 +1448,43 @@ public class AgencyController extends BaseController {
             WriteSheet writeSheet = EasyExcel.writerSheet().build();
             excel.fill(statisticsList,writeSheet);
             excel.finish();
+            downLoadFile(fileName , response);
+            /*File file = new File(fileName);
+            file.delete();*/
+//            return "redirect:"+Global.getAdminPath()+"/new/user/agency/statisticsList?"+statistics;
+        } catch (Exception e) {
+            addMessage(redirectAttributes,"机构分析统计导出失败",e.getMessage());
+            e.printStackTrace();
+//            return "redirect:"+Global.getAdminPath()+"/new/user/agency/statisticsList?"+statistics;
+        }
+//        return "redirect:"+Global.getAdminPath()+"/new/user/agency/statisticsList";
+    }
+    /**
+     * 文件流传输浏览器
+     * @param path
+     * @param response
+     */
+    private static void downLoadFile(String path, HttpServletResponse response) {
+        try {
+            File file = new File(path);
+            String filename = file.getName();
+            // 以流的形式下载文件。
+            InputStream fis = new BufferedInputStream(new FileInputStream(path));
+            byte[] buffer = new byte[fis.available()];
+            fis.read(buffer);
+            fis.close();
+            // 清空response
+            response.reset();
+            response.setContentType("application/octet-stream;charset=UTF-8");
+            String fileName = new String(filename.getBytes("gb2312"), "iso8859-1");
+            response.setHeader("Content-disposition", "attachment;filename=" + fileName);
+            OutputStream ouputStream = response.getOutputStream();
+            ouputStream.write(buffer);
+            ouputStream.flush();
+            ouputStream.close();
         } catch (Exception e) {
-//            addMessage(redirectAttributes,"机构分析统计导出失败",e.getMessage());
             e.printStackTrace();
         }
-
     }
 
     @RequestMapping("/clubPortrait")

+ 26 - 3
src/main/webapp/WEB-INF/views/modules/userNew/cmAgencyStatisticsList.jsp

@@ -315,10 +315,33 @@ $(function () {
             type: "post",
             data: formData,
             contentType : 'application/json;charset=UTF-8', //contentType很重要
-            success: function (data) {
-                console.log("导出成功");
-            }
+            // responseType: 'blob',
+
+        }).then(res => {
+            console.log("00000");
+            /*const content = res // 文件流
+            const blob = new Blob([content], {
+                // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
+                type: "application/msexcel;charset=utf-8",
+            })
+            //var myDate = new Date() | ' + myDate.getTime() + '
+            const fileName = '机构.xlsx'
+            if ('download' in document.createElement('a')) {
+                // 非IE下载
+                const link = document.createElement('a')
+                link.download = fileName
+                link.style.display = 'none'
+                link.href = URL.createObjectURL(blob)
+                document.body.appendChild(link)
+                link.click()
+                URL.revokeObjectURL(link.href) // 释放URL 对象
+                document.body.removeChild(link)
+            } else {
+                // IE10+下载
+                navigator.msSaveBlob(blob, fileName)
+            }*/
         })
+
     })
 })
 /*function reExport() {

+ 110 - 80
src/main/webapp/WEB-INF/views/modules/userNew/cmClubData.jsp

@@ -28,96 +28,126 @@
         <div class="flex-header">
             <div class="flex-header-main">
                 <div class="header-main-box">
-                    <p>机构名称:<span>${newCmClub.name}</span></p>
-                    <p>联系人:<span>${newCmClub.userName}</span></p>
-                    <p>联系人身份:
-                        <span>
-                            <c:if test="${newCmClub.linkManIdentity eq '1'}">老板</c:if>
-                            <c:if test="${newCmClub.linkManIdentity eq '2'}">采购</c:if>
-                            <c:if test="${newCmClub.linkManIdentity eq '3'}">运营</c:if>
-                            <c:if test="${newCmClub.linkManIdentity ne '1' || newCmClub.linkManIdentity ne '2' || newCmClub.linkManIdentity ne '3'}">其他</c:if>
-                        </span>
-                    </p>
-                    <p>手机号:<span>${newCmClub.bindMobile}</span></p>
-                    <p>机构类型:
-                        <span>
-                            <c:if test="${cmClubinfo.firstClubType == '1'}">医美</c:if>
-                            <c:if test="${cmClubinfo.firstClubType == '2'}">生美</c:if>
-                            <c:if test="${cmClubinfo.firstClubType == '3'}">项目公司</c:if>
-                            <c:if test="${cmClubinfo.firstClubType == '4'}">个人</c:if>
-                            <c:if test="${cmClubinfo.firstClubType == '5'}">其他</c:if>
-                            -
-                            <c:if test="${cmClubinfo.secondClubType eq '1'}"> - 诊所</c:if>
-                            <c:if test="${cmClubinfo.secondClubType eq '2'}"> - 门诊</c:if>
-                            <c:if test="${cmClubinfo.secondClubType eq '3'}"> - 医院</c:if>
-                            <c:if test="${cmClubinfo.secondClubType eq '4'}"> - 其他</c:if>
-                            <c:if test="${cmClubinfo.secondClubType eq '5'}"> - 美容院</c:if>
-                            <c:if test="${cmClubinfo.secondClubType eq '6'}"> - 养生馆</c:if>
-                            <c:if test="${cmClubinfo.secondClubType eq '7'}"> - 其他</c:if>
-                        </span>
-                    </p>
-                    <p>地址:<span>${newCmClub.province } ${newCmClub.city } ${newCmClub.town } ${newCmClub.address}</span></p>
-                    <p>状态:<span>${fns:getDictLabel(newCmClub.status, 'club_status', newCmClub.status)}</span></p>
-                    <p>注册时间:<span><fmt:formatDate value="${newCmClub.registerTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></span></p>
+                    <c:if test="${newCmClub.name ne null}"><p>机构名称:<span>${newCmClub.name}</span></p></c:if>
+                    <c:if test="${newCmClub.userName ne null}"> <p>联系人:<span>${newCmClub.userName}</span></p></c:if>
+                    <c:if test="${newCmClub.linkManIdentity ne null}">
+                        <p>联系人身份:
+                            <span>
+                                <c:if test="${newCmClub.linkManIdentity eq '1'}">老板</c:if>
+                                <c:if test="${newCmClub.linkManIdentity eq '2'}">采购</c:if>
+                                <c:if test="${newCmClub.linkManIdentity eq '3'}">运营</c:if>
+                                <c:if test="${newCmClub.linkManIdentity ne '1' || newCmClub.linkManIdentity ne '2' || newCmClub.linkManIdentity ne '3'}">其他</c:if>
+                            </span>
+                        </p>
+                    </c:if>
+                    <c:if test="${newCmClub.bindMobile ne null}"><p>手机号:<span>${newCmClub.bindMobile}</span></p></c:if>
+                    <c:if test="${cmClubinfo.firstClubType ne null and cmClubinfo.secondClubType ne null}">
+                        <p>机构类型:
+                            <span>
+                                <c:if test="${cmClubinfo.firstClubType == '1'}">医美</c:if>
+                                <c:if test="${cmClubinfo.firstClubType == '2'}">生美</c:if>
+                                <c:if test="${cmClubinfo.firstClubType == '3'}">项目公司</c:if>
+                                <c:if test="${cmClubinfo.firstClubType == '4'}">个人</c:if>
+                                <c:if test="${cmClubinfo.firstClubType == '5'}">其他</c:if>
+
+                                <c:if test="${cmClubinfo.secondClubType eq '1'}"> - 诊所</c:if>
+                                <c:if test="${cmClubinfo.secondClubType eq '2'}"> - 门诊</c:if>
+                                <c:if test="${cmClubinfo.secondClubType eq '3'}"> - 医院</c:if>
+                                <c:if test="${cmClubinfo.secondClubType eq '4'}"> - 其他</c:if>
+                                <c:if test="${cmClubinfo.secondClubType eq '5'}"> - 美容院</c:if>
+                                <c:if test="${cmClubinfo.secondClubType eq '6'}"> - 养生馆</c:if>
+                                <c:if test="${cmClubinfo.secondClubType eq '7'}"> - 其他</c:if>
+                            </span>
+                        </p>
+                    </c:if>
+                    <c:if test="${newCmClub.province ne null and newCmClub.city ne null and newCmClub.town ne null and newCmClub.address ne null}"><p>地址:<span>${newCmClub.province } ${newCmClub.city } ${newCmClub.town } ${newCmClub.address}</span></p></c:if>
+                    <c:if test="${newCmClub.status ne null}"><p>状态:<span>${fns:getDictLabel(newCmClub.status, 'club_status', newCmClub.status)}</span></p></c:if>
+                    <c:if test="${newCmClub.registerTime ne null}"><p>注册时间:<span><fmt:formatDate value="${newCmClub.registerTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></span></p></c:if>
                 </div>
                 <div class="header-main-box">
                     <div class="main-box">
-                        <div class="main-box-tp">
-                            <p>机构类别:
-                                <span>
-                                    <c:if test="${cmClubinfo.userIdentity eq 4}">个人机构</c:if>
-                                    <c:if test="${cmClubinfo.userIdentity eq 2}">资质机构</c:if>
-                                    <c:if test="${cmClubinfo.svipUserFlag eq 1}"><font color="red">(超级会员)</font></c:if>
-                                    <c:if test="${cmClubinfo.userIdentity eq 2 and cmClubinfo.svipUserFlag eq 0}"><font color="red">(普通会员)</font></c:if>
-                                </span>
-                            </p>
-                        </div>
-                        <div class="main-box-bt">
-                            <p>医疗许可证:</p>
-                            <a class="main-box-img" target="_blank" href="${cmClubinfo.medicalPracticeLicenseImg}"><img src="${cmClubinfo.medicalPracticeLicenseImg}"/></a>
-                        </div>
+                        <c:if test="${cmClubinfo.userIdentity ne null and cmClubinfo.svipUserFlag ne null}">
+                            <div class="main-box-tp">
+                                <p>机构类别:
+                                    <span>
+                                        <c:if test="${cmClubinfo.userIdentity eq 4}">个人机构</c:if>
+                                        <c:if test="${cmClubinfo.userIdentity eq 2}">资质机构</c:if>
+                                        <c:if test="${cmClubinfo.svipUserFlag eq 1}"><font color="red">(超级会员)</font></c:if>
+                                        <c:if test="${cmClubinfo.userIdentity eq 2 and cmClubinfo.svipUserFlag eq 0}"><font color="red">(普通会员)</font></c:if>
+                                    </span>
+                                </p>
+                            </div>
+                        </c:if>
+                        <c:if test="${cmClubinfo.medicalPracticeLicenseImg ne null}">
+                            <div class="main-box-bt">
+                                <p>医疗许可证:</p>
+                                <a class="main-box-img" target="_blank" href="${cmClubinfo.medicalPracticeLicenseImg}"><img src="${cmClubinfo.medicalPracticeLicenseImg}"/></a>
+                            </div>
+                        </c:if>
                     </div>
                     <div class="main-box">
-                        <div class="main-box-tp">
-                            <p>营业执照编号:<span>${newCmClub.socialCreditCode}</span></p>
-                        </div>
-                        <div class="main-box-bt">
-                            <p>营业执照:</p>
-                            <a class="main-box-img" target="_blank" href="${newCmClub.businessLicenseImage}"><img src="${newCmClub.businessLicenseImage}"/></a>
-                        </div>
+                        <c:if test="${newCmClub.socialCreditCode ne null}">
+                            <div class="main-box-tp">
+                                <p>营业执照编号:<span>${newCmClub.socialCreditCode}</span></p>
+                            </div>
+                        </c:if>
+                        <c:if test="${newCmClub.businessLicenseImage ne null}">
+                            <div class="main-box-bt">
+                                <p>营业执照:</p>
+                                <a class="main-box-img" target="_blank" href="${newCmClub.businessLicenseImage}"><img src="${newCmClub.businessLicenseImage}"/></a>
+                            </div>
+                        </c:if>
                     </div>
                 </div>
             </div>
         </div>
         <div class="flex-content">
-            <div class="flex-p">
-                <p>机构简称:<span>${newCmClub.sname}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>注册邮箱:<span>${newCmClub.contractEmail}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>门头照:<span></span></p>
-                <a class="flex-p-img" target="_blank" href="${newCmClub.headpic}"><img src="${newCmClub.headpic}" alt=""></a>
-            </div>
-            <div class="flex-p">
-                <p>科室:<span>${cmClubinfo.department}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>主营内容:<span>${cmClubinfo.mainpro}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>固定电话:<span>${cmClubinfo.contractPhone}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>传真:<span>${cmClubinfo.fax}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>员工人数:<span>${cmClubinfo.empnum}</span></p>
-            </div>
-            <div class="flex-p">
-                <p>公司简介:<span>${cmClubinfo.info}</span></p>
-            </div>
+            <c:if test="${newCmClub.sname ne null}">
+                <div class="flex-p">
+                    <p>机构简称:<span>${newCmClub.sname}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${newCmClub.contractEmail ne null}">
+                <div class="flex-p">
+                    <p>注册邮箱:<span>${newCmClub.contractEmail}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${newCmClub.headpic ne null}">
+                <div class="flex-p">
+                    <p>门头照:<span></span></p>
+                    <a class="flex-p-img" target="_blank" href="${newCmClub.headpic}"><img src="${newCmClub.headpic}" alt=""></a>
+                </div>
+            </c:if>
+            <c:if test="${cmClubinfo.department ne null}">
+                <div class="flex-p">
+                    <p>科室:<span>${cmClubinfo.department}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${cmClubinfo.mainpro ne null}">
+                <div class="flex-p">
+                    <p>主营内容:<span>${cmClubinfo.mainpro}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${cmClubinfo.contractPhone ne null}">
+                <div class="flex-p">
+                    <p>固定电话:<span>${cmClubinfo.contractPhone}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${cmClubinfo.fax ne null}">
+                <div class="flex-p">
+                    <p>传真:<span>${cmClubinfo.fax}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${cmClubinfo.empnum ne null}">
+                <div class="flex-p">
+                    <p>员工人数:<span>${cmClubinfo.empnum}</span></p>
+                </div>
+            </c:if>
+            <c:if test="${cmClubinfo.info ne null}">
+                <div class="flex-p">
+                    <p>公司简介:<span>${cmClubinfo.info}</span></p>
+                </div>
+            </c:if>
             <div style="display: none">
                 <div class="flex-p"><p>基本信息:</p></div>
                 <div class="flex-p"><p>机构面积:<span>${cmClubinfo.area}</span></p></div>