浏览代码

企业双百强功能

xiao547607 4 年之前
父节点
当前提交
66738542b5

+ 3 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/DoubleHundred.java

@@ -51,4 +51,7 @@ public class DoubleHundred {
     private String corporate;
     @ApiModelProperty(value = "法人联系方式")
     private String corporatePhone;
+    @ApiModelProperty(value = "区域")
+    private String region;
+
 }

+ 19 - 1
common/src/main/resources/mapper/base/DoubleHundred.xml

@@ -19,6 +19,7 @@
 			<result property="openId" column="open_id" />
 			<result property="corporate" column="corporate_" />
 			<result property="corporatePhone" column="corporate_phone" />
+			<result property="region" column="region_" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.DoubleHundred">
 	<!--
@@ -29,7 +30,7 @@
 	<![CDATA[
 		insert into base_double_hundred
 	    (id_,information_,person_,phone_,introduction_,income_,pay_taxes,create_by,create_time,update_by,update_time,del_flag,
-	    open_id,corporate_,corporate_phone)
+	    open_id,corporate_,corporate_phone,region_)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -47,6 +48,7 @@
 ,#{openId,jdbcType=VARCHAR}
 ,#{corporate,jdbcType=VARCHAR}
 ,#{corporatePhone,jdbcType=VARCHAR}
+,#{region,jdbcType=VARCHAR}
 		)
 	]]>
 	</insert>
@@ -98,6 +100,10 @@
 			<if test="corporatePhone!=null">
 				corporate_phone=#{corporatePhone,jdbcType=VARCHAR},
 			</if>
+			<if test="region!=null">
+				region_=#{region,jdbcType=VARCHAR},
+			</if>
+
 		</set>
 	where id_=#{id}
 	</update>
@@ -119,6 +125,18 @@
 			<if test="searchParams.id != null">
 				and ID_ like #{searchParams.id}
 			</if>
+			<if test="searchParams.information != null">
+				and information_ like #{searchParams.information}
+			</if>
+			<if test="searchParams.person != null">
+				and person_ like #{searchParams.person}
+			</if>
+			<if test="searchParams.phone != null">
+				and phone_ like #{searchParams.phone}
+			</if>
+			<if test="searchParams.region != null">
+				and region_ like #{searchParams.region}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 97 - 4
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/DoubleHundredController.java

@@ -1,20 +1,29 @@
 package com.jpsoft.enterprise.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.enterprise.config.OSSConfig;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
 import com.jpsoft.enterprise.modules.common.dto.Sort;
 import com.jpsoft.enterprise.modules.base.entity.DoubleHundred;
 import com.jpsoft.enterprise.modules.base.service.DoubleHundredService;
+import com.jpsoft.enterprise.modules.common.utils.OSSUtil;
 import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -32,6 +41,9 @@ public class DoubleHundredController {
     @Autowired
     private DoubleHundredService doubleHundredService;
 
+    @Autowired
+    private OSSConfig ossConfig;
+
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
     public MessageResult<DoubleHundred> create(){
@@ -200,31 +212,112 @@ public class DoubleHundredController {
 
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
-    public MessageResult<Map> pageList(
+    public MessageResult<Object> pageList(
             String id,
+            @RequestParam(value="information",defaultValue="") String information,
+            @RequestParam(value="person",defaultValue="") String person,
+            @RequestParam(value="phone",defaultValue="") String phone,
+            @RequestParam(value="region",defaultValue="") String region,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
             @RequestAttribute String subject){
 
         //当前用户ID
         System.out.println(subject);
 
-        MessageResult<Map> msgResult = new MessageResult<>();
+        MessageResult<Object> msgResult = new MessageResult<>();
 
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("create_time","desc"));
 
         if (StringUtils.isNotEmpty(id)) {
             searchParams.put("id","%" + id + "%");
         }
 
+        if (StringUtils.isNotEmpty(information)) {
+            searchParams.put("information","%" + information + "%");
+        }
+        if (StringUtils.isNotEmpty(person)) {
+            searchParams.put("person","%" + person + "%");
+        }
+        if (StringUtils.isNotEmpty(phone)) {
+            searchParams.put("phone","%" + phone + "%");
+        }
+        if (StringUtils.isNotEmpty(region)) {
+            searchParams.put("region","%" + region + "%");
+        }
+
+        List<Map> mapList = new ArrayList<>();
+
         Page<DoubleHundred> page = doubleHundredService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
+        if(exportFlag) {
+            String filePath = exportXls(page.getResult());
+            msgResult.setData(filePath);
+        }else {
+            msgResult.setData(PojoUtils.pageWrapper(page));
+        }
         msgResult.setResult(true);
-        msgResult.setData(PojoUtils.pageWrapper(page));
+
 
         return msgResult;
     }
+
+    private String exportXls(List<DoubleHundred> dhList) {
+        String downloadUrl = "";
+
+        Workbook workbook = new HSSFWorkbook();
+        Sheet sheet = workbook.createSheet();
+
+        //表头
+        Row rowTitle = sheet.createRow(0);
+
+        String[] titles = new String[]{"序号","区域","企业信息","联系人","联系电话","企业介绍",
+                "收入(亿)","纳税(万)","企业法人","法人联系方式"};
+
+        for (int i=0;i<titles.length;i++) {
+            Cell cell = rowTitle.createCell(i);
+            cell.setCellValue(titles[i]);
+        }
+
+        for (int i=0;i<dhList.size();i++){
+            DoubleHundred dh = dhList.get(i);
+
+            Row row = sheet.createRow(i+1);
+
+            int colIndex = 0;
+            row.createCell(colIndex++).setCellValue(i+1);
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getRegion(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getInformation(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getPerson(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getPhone(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getIntroduction(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getIncome(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getPayTaxes(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getCorporate(),""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.enterprise.modules.common.utils.StringUtils.strValue(dh.getCorporatePhone(),""));
+        }
+
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+        try {
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
+            String now = sdf.format(new Date());
+            String fileName = "企业双百强导出" + now + ".xls";
+            downloadUrl = OSSUtil.upload(ossConfig,"doubleHundred",fileName,input);
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+        }
+
+        return downloadUrl;
+    }
 }

+ 3 - 0
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/DoubleHundredApiController.java

@@ -44,6 +44,7 @@ public class DoubleHundredApiController {
             @ApiImplicitParam(name = "payTaxes", value = "纳税", required = true, paramType = "form"),
             @ApiImplicitParam(name = "corporate", value = "企业法人", required = true, paramType = "form"),
             @ApiImplicitParam(name = "corporatePhone", value = "法人联系方式", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "region", value = "区域", required = true, paramType = "form"),
             @ApiImplicitParam(name = "personId", value = "提交用户ID(没有则不传)", paramType = "form"),
             @ApiImplicitParam(name = "openId", value = "openId", paramType = "form"),
     })
@@ -57,6 +58,7 @@ public class DoubleHundredApiController {
             @RequestParam(value="personId",defaultValue="") String personId,
             @RequestParam(value="corporate",defaultValue="") String corporate,
             @RequestParam(value="corporatePhone",defaultValue="") String corporatePhone,
+            @RequestParam(value="region",defaultValue="") String region,
             @RequestParam(value="openId",defaultValue="") String openId) {
         MessageResult<Map> messageResult = new MessageResult<>();
         try {
@@ -79,6 +81,7 @@ public class DoubleHundredApiController {
             dh.setIncome(income);
             dh.setPayTaxes(payTaxes);
             dh.setCorporate(corporate);
+            dh.setRegion(region);
             dh.setCorporatePhone(corporatePhone);
             if(StringUtils.isNotEmpty(personId)) {
                 dh.setCreateBy(personId);