Pārlūkot izejas kodu

管理端功能

xiao547607 4 gadi atpakaļ
vecāks
revīzija
c9c050b287
18 mainītis faili ar 474 papildinājumiem un 17 dzēšanām
  1. 2 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/dao/CompanyInfoDAO.java
  2. 4 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsInfo.java
  3. 2 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsType.java
  4. 2 1
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/PersonInfo.java
  5. 2 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/service/CompanyInfoService.java
  6. 5 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/service/impl/CompanyInfoServiceImpl.java
  7. 1 0
      common/src/main/java/com/jpsoft/enterprise/modules/sys/dao/DataDictionaryDAO.java
  8. 1 1
      common/src/main/java/com/jpsoft/enterprise/modules/sys/service/DataDictionaryService.java
  9. 5 0
      common/src/main/java/com/jpsoft/enterprise/modules/sys/service/impl/DataDictionaryServiceImpl.java
  10. 5 1
      common/src/main/resources/mapper/base/CompanyInfo.xml
  11. 28 3
      common/src/main/resources/mapper/base/NewsInfo.xml
  12. 16 3
      common/src/main/resources/mapper/base/NewsType.xml
  13. 24 2
      common/src/main/resources/mapper/base/PersonInfo.xml
  14. 9 0
      common/src/main/resources/mapper/sys/DataDictionary.xml
  15. 161 0
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/CompanyInfoController.java
  16. 15 4
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsInfoController.java
  17. 28 1
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsTypeController.java
  18. 164 1
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/PersonInfoController.java

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dao/CompanyInfoDAO.java

@@ -16,4 +16,6 @@ public interface CompanyInfoDAO {
 	int delete(String id);
 	List<CompanyInfo> list();
 	List<CompanyInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
+
+	CompanyInfo findByName(String name);
 }

+ 4 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsInfo.java

@@ -21,8 +21,12 @@ public class NewsInfo {
     private String id;
     @ApiModelProperty(value = "新闻类型id")
     private String newsTypeId;
+    @ApiModelProperty(value = "新闻类型名称")
+    private String newsTypeName;
     @ApiModelProperty(value = "公司id")
     private String companyId;
+    @ApiModelProperty(value = "公司名称")
+    private String companyName;
     @ApiModelProperty(value = "标题")
     private String title;
     @ApiModelProperty(value = "内容")

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsType.java

@@ -23,6 +23,8 @@ public class NewsType {
     private String name;
     @ApiModelProperty(value = "父id")
     private String parentId;
+    @ApiModelProperty(value = "父类型名称")
+    private String parentName;
     @ApiModelProperty(value = "创建人")
     private String createBy;
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")

+ 2 - 1
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/PersonInfo.java

@@ -58,5 +58,6 @@ public class PersonInfo {
     @ApiModelProperty(value = "注册类型名称")
     private String registerTypeName;
 
-
+    @ApiModelProperty(value = "企业名称")
+    private String companyName;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/service/CompanyInfoService.java

@@ -15,4 +15,6 @@ public interface CompanyInfoService {
 	int delete(String id);
 	List<CompanyInfo> list();
 	Page<CompanyInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+
+	CompanyInfo findByName(String name);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/service/impl/CompanyInfoServiceImpl.java

@@ -69,4 +69,9 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
         
         return page;
 	}
+
+	@Override
+	public CompanyInfo findByName(String name) {
+		return companyInfoDAO.findByName(name);
+	}
 }

+ 1 - 0
common/src/main/java/com/jpsoft/enterprise/modules/sys/dao/DataDictionaryDAO.java

@@ -25,4 +25,5 @@ public interface DataDictionaryDAO {
 	List<DataDictionary> findByCatalogName(String catalogName);
 
 	String findNameByCatalogNameAndValue(String catalogName, String value);
+	String findValueByCatalogNameAndName(String catalogName, String name);
 }

+ 1 - 1
common/src/main/java/com/jpsoft/enterprise/modules/sys/service/DataDictionaryService.java

@@ -22,6 +22,6 @@ public interface DataDictionaryService {
 	Page<DataDictionary> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, List<Sort> sortList);
 	List<DataDictionary> findByCatalogName(String catalogName);
 	String findNameByCatalogNameAndValue(String catalogName, String value);
-
+	String findValueByCatalogNameAndName(String catalogName, String name);
     Map<String, DataDictionary> findMapByCatalogName(String catalogName);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/enterprise/modules/sys/service/impl/DataDictionaryServiceImpl.java

@@ -102,6 +102,11 @@ public class DataDictionaryServiceImpl implements DataDictionaryService {
 		return dataDictionaryDAO.findNameByCatalogNameAndValue(catalogName,value);
 	}
 
+	@Override
+	public String findValueByCatalogNameAndName(String catalogName, String name){
+		return dataDictionaryDAO.findValueByCatalogNameAndName(catalogName,name);
+	}
+
 	@Override
 	public Map<String, DataDictionary> findMapByCatalogName(String catalogName) {
 		Map<String,DataDictionary> ddMap = new HashMap<>();

+ 5 - 1
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -117,7 +117,7 @@
 		select count(*) from base_company_info where id_=#{0}
 	</select>
 	<select id="list" resultMap="CompanyInfoMap">
-		select * from base_company_info where del_flag = 0
+		select * from base_company_info where del_flag = 0 order by create_time asc
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="CompanyInfoMap">
 		<![CDATA[
@@ -148,4 +148,8 @@
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+	<select id="findByName" parameterType="string" resultMap="CompanyInfoMap">
+		select * from base_company_info a where company_name=#{0} and del_flag = 0
+	</select>
 </mapper>

+ 28 - 3
common/src/main/resources/mapper/base/NewsInfo.xml

@@ -17,6 +17,8 @@
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
 			<result property="topFlag" column="top_flag"/>
+			<result property="newsTypeName" column="news_type_name"/>
+			<result property="companyName" column="company_name" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.NewsInfo">
 	<!--
@@ -91,7 +93,18 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="NewsInfoMap">
-		select * from base_news_info where id_=#{0}
+		select
+			a.*,
+			b.name_ as news_type_name,
+			c.company_name as company_name
+			from base_news_info a
+			left join base_news_type b on a.news_type_id = b.id_
+			left join base_company_info c on a.company_id = c.id_
+			where
+			a.del_flag = 0
+			and b.del_flag = 0
+			and c.del_flag = 0
+			and a.id_ =#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_news_info where id_=#{0}
@@ -101,12 +114,18 @@
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="NewsInfoMap">
 		<![CDATA[
-			select * from base_news_info a left join base_news_type b
-			on a.news_type_id = b.id_
+			select
+			a.*,
+			b.name_ as news_type_name,
+			c.company_name as company_name
+			from base_news_info a
+			left join base_news_type b on a.news_type_id = b.id_
+			left join base_company_info c on a.company_id = c.id_
 		]]>
 		<where>
 			a.del_flag = 0
 			and b.del_flag = 0
+			and c.del_flag = 0
 			<if test="searchParams.id != null">
 				and a.id_ like #{searchParams.id}
 			</if>
@@ -131,6 +150,12 @@
             <if test="searchParams.code != null">
                 and b.code_ = #{searchParams.code}
             </if>
+			<if test="searchParams.companyName != null">
+				and c.company_name = #{searchParams.companyName}
+			</if>
+			<if test="searchParams.title != null">
+				and a.title_ like #{searchParams.title}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 16 - 3
common/src/main/resources/mapper/base/NewsType.xml

@@ -14,6 +14,7 @@
 			<result property="delFlag" column="del_flag" />
 			<result property="code" column="code_"/>
 			<result property="showFlag" column="show_flag"/>
+			<result property="parentName" column="parent_name"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.NewsType">
 	<!--
@@ -82,15 +83,27 @@
 		select count(*) from base_news_type where id_=#{0}
 	</select>
 	<select id="list" resultMap="NewsTypeMap">
-		select * from base_news_type
+		select * from base_news_type where del_flag = 0 and show_flag = 1 ORDER BY parent_id ASC,id_ ASC
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="NewsTypeMap">
 		<![CDATA[
-			select * from base_news_type
+			SELECT
+				a.*,
+				b.name_ as parent_name
+			FROM
+				base_news_type a
+				LEFT JOIN base_news_type b ON a.parent_id = b.id_
 		]]>
 		<where>
+			a.del_flag = 0
 			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+				and a.ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.name != null">
+				and a.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.parentName != null">
+				and b.name_ like #{searchParams.parentName}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 24 - 2
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -22,6 +22,7 @@
 			<result property="delFlag" column="del_flag" />
 			<result property="remark" column="remark_" />
 			<result property="registerTypeName" column="register_type_name"/>
+			<result property="companyName" column="company_name"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.PersonInfo">
 	<!--
@@ -122,11 +123,32 @@
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="PersonInfoMap">
 		<![CDATA[
-			select * from base_person_info
+			SELECT
+				a.*,
+				b.company_name AS company_name
+			FROM
+				base_person_info a
+				LEFT JOIN base_company_info b ON a.company_id = b.id_
 		]]>
 		<where>
+			a.del_flag = 0
 			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+				and a.ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.companyName != null">
+				and b.company_name like #{searchParams.companyName}
+			</if>
+			<if test="searchParams.registerType != null">
+				and a.register_type = #{searchParams.registerType}
+			</if>
+			<if test="searchParams.personName != null">
+				and a.person_name like #{searchParams.personName}
+			</if>
+			<if test="searchParams.idCard != null">
+				and a.id_card like #{searchParams.idCard}
+			</if>
+			<if test="searchParams.openId != null">
+				and a.open_id = #{searchParams.openId}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 9 - 0
common/src/main/resources/mapper/sys/DataDictionary.xml

@@ -174,4 +174,13 @@
         order by a.sort_no asc
         limit 1
     </select>
+    <select id="findValueByCatalogNameAndName" parameterType="map" resultType="string">
+        select a.value_
+        from sys_data_dictionary a,sys_data_dictionary b
+        where a.parent_id =b.id_ and b.name_=#{catalogName}
+        and a.del_flag = 0
+        and a.name_=#{name}
+        order by a.sort_no asc
+        limit 1
+    </select>
 </mapper>

+ 161 - 0
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/CompanyInfoController.java

@@ -1,21 +1,34 @@
 package com.jpsoft.enterprise.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.enterprise.config.OSSConfig;
 import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
 import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
+import com.jpsoft.enterprise.modules.common.utils.OSSUtil;
+import com.jpsoft.enterprise.modules.common.utils.POIUtils;
 import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
 import com.jpsoft.enterprise.modules.common.dto.Sort;
+import com.jpsoft.enterprise.modules.sys.entity.DataDictionary;
+import com.jpsoft.enterprise.modules.sys.entity.User;
 import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
+import com.jpsoft.enterprise.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+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 org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -33,6 +46,10 @@ public class CompanyInfoController {
     private CompanyInfoService companyInfoService;
     @Autowired
     private DataDictionaryService dataDictionaryService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private OSSConfig ossConfig;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -255,4 +272,148 @@ public class CompanyInfoController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="所有单位列表")
+    @RequestMapping(value = "list",method = RequestMethod.POST)
+    public MessageResult<List<CompanyInfo>> list(String companyName,
+                 @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+                 @RequestParam(value="pageSize",defaultValue="10") int pageSize,
+                 @RequestAttribute String subject){
+
+        MessageResult<List<CompanyInfo>> msgResult = new MessageResult<>();
+//        User user = userService.get(subject);
+//
+//        String companyId = "";
+//
+//        if (userService.hasRole(subject, "SYSADMIN") || "all".equals(scope)) {
+//            companyId = "";
+//        }
+//        else{
+//            CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+//            companyId = companyInfo.getId();
+//        }
+
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time","desc"));
+
+        if (StringUtils.isNotEmpty(companyName)) {
+            searchParams.put("companyName","%" + companyName + "%");
+        }
+
+        Page<CompanyInfo> page = companyInfoService.pageSearch(searchParams,pageIndex,pageSize,false,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(page.getResult());
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="导入企业")
+    @PostMapping("importXls")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "uploadFile",value = "上传文件", required = true,paramType="form", dataType = "__file")
+    })
+    public MessageResult<String> importXls(MultipartFile uploadFile,
+                                           @RequestAttribute String subject){
+        User user = userService.get(subject);
+
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
+            int sheetIndex = 0;
+            Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
+
+            int affectCount = 0;
+            int failCount = 0;
+            int validateColIndex = 10;
+
+            for(int rowIndex=1 ; rowIndex<=sheet1.getLastRowNum(); rowIndex++){
+                try {
+                    String sort = (String)poiUtils.getCellValue(sheetIndex,rowIndex,0).toString().replace(" ","");
+                    String name = (String)poiUtils.getCellValue(sheetIndex,rowIndex,1).toString().replace(" ","");
+                    String type = (String)poiUtils.getCellValue(sheetIndex,rowIndex,2).toString().replace(" ","");
+                    String scale = (String)poiUtils.getCellValue(sheetIndex,rowIndex,3).toString().replace(" ","");
+                    String region = (String)poiUtils.getCellValue(sheetIndex,rowIndex,4).toString().replace(" ","");
+                    String industry = (String)poiUtils.getCellValue(sheetIndex,rowIndex,5).toString().replace(" ","");
+                    String creditCode = (String)poiUtils.getCellValue(sheetIndex,rowIndex,6).toString().replace(" ","");
+                    String address = (String)poiUtils.getCellValue(sheetIndex,rowIndex,7).toString().replace(" ","");
+                    String companyIntroduction = (String)poiUtils.getCellValue(sheetIndex,rowIndex,8).toString().replace(" ","");
+                    String enterpriserIntroduction = (String)poiUtils.getCellValue(sheetIndex,rowIndex,9).toString().replace(" ","");
+
+                    if(StringUtils.isEmpty(name)){
+                        break;
+                    }
+
+                    CompanyInfo companyInfo = companyInfoService.findByName(name);
+
+                    if (companyInfo != null) {
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("该企业已存在!");
+                        failCount++;
+                        continue;
+                    } else {
+                        companyInfo = new CompanyInfo();
+                        companyInfo.setId(UUID.randomUUID().toString());
+                        companyInfo.setCompanyName(name);
+
+                        companyInfo.setIndustry(dataDictionaryService.findValueByCatalogNameAndName("所属行业",industry));
+                        companyInfo.setType(dataDictionaryService.findValueByCatalogNameAndName("企业类型",type));
+                        companyInfo.setScale(dataDictionaryService.findValueByCatalogNameAndName("企业规模",scale));
+                        companyInfo.setRegion(dataDictionaryService.findValueByCatalogNameAndName("区域",region));
+
+                        companyInfo.setCreditCode(creditCode);
+                        companyInfo.setAddress(address);
+                        companyInfo.setCompanyIntroduction(companyIntroduction);
+                        companyInfo.setEnterpriserIntroduction(enterpriserIntroduction);
+
+                        companyInfo.setDelFlag(false);
+                        companyInfo.setCreateBy(subject);
+                        companyInfo.setCreateTime(new Date());
+
+                        companyInfoService.insert(companyInfo);
+                        affectCount++;
+                    }
+                }
+                catch(Exception innerEx){
+                    logger.error(innerEx.getMessage(),innerEx);
+                }
+            }
+
+            if (failCount>0){
+                //有导入失败的记录
+                msgResult.setResult(false);
+                msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
+
+                //todo 只保留错误数据的sheet
+                Workbook wb = poiUtils.exportErrorXls(sheetIndex,validateColIndex,1 + affectCount + failCount);
+
+                //todo 将wb保存到oss
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                wb.write(output);
+
+                byte[] buffer = output.toByteArray();
+                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+
+                //todo 返回导入失败报表下载链接
+                msgResult.setData(downloadUrl);
+            }
+            else{
+                msgResult.setResult(true);
+                msgResult.setMessage("数据成功导入" + affectCount + "条");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 15 - 4
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsInfoController.java

@@ -197,7 +197,10 @@ public class NewsInfoController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
-            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="title",defaultValue="") String title,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
+            @RequestParam(value="newsTypeId",defaultValue="") String newsTypeId,
+            @RequestParam(value="pageIndex",defaultValue="0") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
 
@@ -209,10 +212,18 @@ public class NewsInfoController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("a.create_time","desc"));
 
-        if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+        if (StringUtils.isNotEmpty(title)) {
+            searchParams.put("title","%" + title + "%");
+        }
+
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId",companyId);
+        }
+
+        if (StringUtils.isNotEmpty(newsTypeId)) {
+            searchParams.put("newsTypeId",newsTypeId);
         }
 
         Page<NewsInfo> page = newsInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);

+ 28 - 1
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsTypeController.java

@@ -1,11 +1,13 @@
 package com.jpsoft.enterprise.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
 import com.jpsoft.enterprise.modules.base.entity.NewsType;
 import com.jpsoft.enterprise.modules.base.service.NewsTypeService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
 import com.jpsoft.enterprise.modules.common.dto.Sort;
 import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
+import com.jpsoft.enterprise.modules.sys.entity.Menu;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -197,6 +199,8 @@ public class NewsTypeController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="parentName",defaultValue="") String parentName,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -209,12 +213,21 @@ public class NewsTypeController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("a.parent_id","asc"));
+        sortList.add(new Sort("a.create_time","asc"));
 
         if (StringUtils.isNotEmpty(id)) {
             searchParams.put("id","%" + id + "%");
         }
 
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+
+        if (StringUtils.isNotEmpty(parentName)) {
+            searchParams.put("parentName","%" + parentName + "%");
+        }
+
         Page<NewsType> page = newsTypeService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
         msgResult.setResult(true);
@@ -222,4 +235,18 @@ public class NewsTypeController {
 
         return msgResult;
     }
+
+    @ApiOperation(value = "查询")
+    @RequestMapping(value = "list", method = RequestMethod.POST)
+    public MessageResult<List<NewsType>> list(
+            @RequestAttribute String subject) {
+
+        MessageResult<List<NewsType>> msgResult = new MessageResult<>();
+        List<NewsType> list = newsTypeService.list();
+
+        msgResult.setResult(true);
+        msgResult.setData(list);
+
+        return msgResult;
+    }
 }

+ 164 - 1
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/PersonInfoController.java

@@ -1,23 +1,43 @@
 package com.jpsoft.enterprise.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.enterprise.config.OSSConfig;
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
 import com.jpsoft.enterprise.modules.base.entity.PersonInfo;
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
 import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
 import com.jpsoft.enterprise.modules.common.dto.Sort;
+import com.jpsoft.enterprise.modules.common.utils.AESUtil;
+import com.jpsoft.enterprise.modules.common.utils.OSSUtil;
+import com.jpsoft.enterprise.modules.common.utils.POIUtils;
 import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
+import com.jpsoft.enterprise.modules.sys.entity.User;
+import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
+import com.jpsoft.enterprise.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+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 org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+/**
+ * 企业用户管理
+ * sz
+ */
 @RestController
 @RequestMapping("/base/personInfo")
 @Api(description = "personInfo")
@@ -26,6 +46,14 @@ public class PersonInfoController {
 
     @Autowired
     private PersonInfoService personInfoService;
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+    @Autowired
+    private CompanyInfoService companyInfoService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private OSSConfig ossConfig;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -197,6 +225,11 @@ public class PersonInfoController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
+            @RequestParam(value="companyName",defaultValue="") String companyName,
+            @RequestParam(value="registerType",defaultValue="") String registerType,
+            @RequestParam(value="personName",defaultValue="") String personName,
+            @RequestParam(value="idCard",defaultValue="") String idCard,
+            @RequestParam(value="openId",defaultValue="") String openId,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -209,17 +242,147 @@ public class PersonInfoController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("a.company_id","asc"));
+        sortList.add(new Sort("a.create_time","asc "));
 
         if (StringUtils.isNotEmpty(id)) {
             searchParams.put("id","%" + id + "%");
         }
 
+        if (StringUtils.isNotEmpty(companyName)) {
+            searchParams.put("companyName","%" + companyName + "%");
+        }
+        if (StringUtils.isNotEmpty(registerType)) {
+            searchParams.put("registerType",registerType);
+        }
+        if (StringUtils.isNotEmpty(personName)) {
+            searchParams.put("personName","%" + personName + "%");
+        }
+        if (StringUtils.isNotEmpty(idCard)) {
+            searchParams.put("idCard","%" + idCard + "%");
+        }
+        if (StringUtils.isNotEmpty(openId)) {
+            searchParams.put("openId",openId);
+        }
+
         Page<PersonInfo> page = personInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+        for(PersonInfo pi : page.getResult()){
+            pi.setRegisterTypeName(dataDictionaryService.findNameByCatalogNameAndValue("注册用户类型",pi.getRegisterType()));
+        }
 
         msgResult.setResult(true);
         msgResult.setData(PojoUtils.pageWrapper(page));
 
         return msgResult;
     }
+
+    @ApiOperation(value="导入用户")
+    @PostMapping("importXls")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "uploadFile",value = "上传文件", required = true,paramType="form", dataType = "__file")
+    })
+    public MessageResult<String> importXls(MultipartFile uploadFile,
+                                           @RequestAttribute String subject){
+        User user = userService.get(subject);
+
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
+            int sheetIndex = 0;
+            Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
+
+            int affectCount = 0;
+            int failCount = 0;
+            int validateColIndex = 10;
+
+            for(int rowIndex=1 ; rowIndex<=sheet1.getLastRowNum(); rowIndex++){
+                try {
+                    String sort = (String)poiUtils.getCellValue(sheetIndex,rowIndex,0).toString().replace(" ","");
+                    String companyName = (String)poiUtils.getCellValue(sheetIndex,rowIndex,1).toString().replace(" ","");
+                    String registerType = (String)poiUtils.getCellValue(sheetIndex,rowIndex,2).toString().replace(" ","");
+                    String userName = (String)poiUtils.getCellValue(sheetIndex,rowIndex,3).toString().replace(" ","");
+                    String personName = (String)poiUtils.getCellValue(sheetIndex,rowIndex,4).toString().replace(" ","");
+                    String idCard = (String)poiUtils.getCellValue(sheetIndex,rowIndex,5).toString().replace(" ","");
+                    String phone = (String)poiUtils.getCellValue(sheetIndex,rowIndex,6).toString().replace(" ","");
+                    String remark = (String)poiUtils.getCellValue(sheetIndex,rowIndex,7).toString().replace(" ","");
+
+                    if(StringUtils.isEmpty(personName)){
+                        break;
+                    }else {
+                        PersonInfo pi = personInfoService.findByUserName(userName);
+                        if(pi != null){
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("该用户已存在!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+
+                    CompanyInfo companyInfo = companyInfoService.findByName(companyName);
+
+                    if (companyInfo == null) {
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("该企业不存在!");
+                        failCount++;
+                        continue;
+                    } else {
+                        PersonInfo personInfo = new PersonInfo();
+                        personInfo.setId(UUID.randomUUID().toString());
+                        personInfo.setCompanyId(companyInfo.getId());
+
+                        personInfo.setRegisterType(dataDictionaryService.findValueByCatalogNameAndName("注册用户类型",registerType));
+
+                        personInfo.setUserName(userName);
+                        personInfo.setPersonName(personName);
+                        personInfo.setPassword(AESUtil.encrypt("123456",AESUtil.MYSQL_ENC_KEY));
+                        personInfo.setIdCard(idCard);
+                        personInfo.setPhone(phone);
+                        personInfo.setRemark(remark);
+
+                        personInfo.setDelFlag(false);
+                        personInfo.setCreateBy(subject);
+                        personInfo.setCreateTime(new Date());
+
+                        personInfoService.insert(personInfo);
+                        affectCount++;
+                    }
+                }
+                catch(Exception innerEx){
+                    logger.error(innerEx.getMessage(),innerEx);
+                }
+            }
+
+            if (failCount>0){
+                //有导入失败的记录
+                msgResult.setResult(false);
+                msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
+
+                //todo 只保留错误数据的sheet
+                Workbook wb = poiUtils.exportErrorXls(sheetIndex,validateColIndex,1 + affectCount + failCount);
+
+                //todo 将wb保存到oss
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                wb.write(output);
+
+                byte[] buffer = output.toByteArray();
+                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+
+                //todo 返回导入失败报表下载链接
+                msgResult.setData(downloadUrl);
+            }
+            else{
+                msgResult.setResult(true);
+                msgResult.setMessage("数据成功导入" + affectCount + "条");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }