소스 검색

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

yanliming 5 년 전
부모
커밋
f25beb6b4e

+ 8 - 0
common/pom.xml

@@ -137,6 +137,14 @@
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>3.1.0</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
         <!-- aliyun oss end -->
     </dependencies>
 

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java

@@ -1,5 +1,6 @@
 package com.jpsoft.smart.modules.base.dao;
 
+import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
 import org.springframework.stereotype.Repository;
 
 /**
@@ -10,4 +11,5 @@ import org.springframework.stereotype.Repository;
 public interface PersonDeviceLogDAO {
 
 
+    void insert(PersonDeviceLog personDeviceLog);
 }

+ 2 - 1
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceLog.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.Date;
 
 /**
@@ -32,7 +33,7 @@ public class PersonDeviceLog {
      * 人员id
      */
     @ApiModelProperty(value = "人员id")
-    private String personId;
+    private Integer personId;
 
     /**
      * 记录温度

+ 3 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java

@@ -2,7 +2,9 @@ package com.jpsoft.smart.modules.base.service;
 
 import cn.hutool.json.JSONObject;
 
+import java.io.IOException;
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * @author 墨鱼_mo
@@ -18,5 +20,5 @@ public interface PersonDeviceLogService {
      * @param libMatInfoListJson
      * @param matchPersonInfo
      */
-    void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo);
+    void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) ;
 }

+ 69 - 4
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -1,17 +1,29 @@
 package com.jpsoft.smart.modules.base.service.impl;
 
 import cn.hutool.json.JSONObject;
+import com.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.modules.base.dao.AlarmInfoDAO;
 import com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
+import com.jpsoft.smart.modules.common.utils.BASE64DecodedMultipartFile;
+import com.jpsoft.smart.modules.common.utils.Base64;
 import com.jpsoft.smart.modules.common.utils.IApiUtil;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Decoder;
 
 import javax.annotation.Resource;
+import javax.xml.crypto.Data;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.UUID;
 
 /**
@@ -22,11 +34,14 @@ import java.util.UUID;
 @Component(value="personDeviceLogService")
 public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
 
+    @Autowired
+    private OSSConfig ossConfig;
+
     @Resource(name="personDeviceLogDAO")
     private PersonDeviceLogDAO personDeviceLogDAO;
 
-    @Override
-    public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo) {
+    /*@Override
+    public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Data data) {
         PersonDeviceLog personDeviceLog = new PersonDeviceLog();
         personDeviceLog.setId(UUID.randomUUID().toString());
         personDeviceLog.setDeviceNo(deviceNo);
@@ -35,10 +50,60 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
         personDeviceLog.setMatchMsg(IApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
         personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
+        personDeviceLog.setRecordTime(data);
+
+
+    }*/
+
+    @Override
+    public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date)  {
+        String retFileUrl = "";
+        try{
+
+            BASE64Decoder decoder = new BASE64Decoder();
+
+            byte[] imgData = decoder.decodeBuffer(faceImageJson.getStr("Data"));
+
+            for (int i = 0; i < imgData.length; ++i) {
+                if (imgData[i] < 0) {// 调整异常数据
+                    imgData[i] += 256;
+                }
+            }
 
-      //  long timestamp = jsonObject.getLong("Timestamp");
-      //  personDeviceLog.setRecordTime();
+            ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
 
 
+
+             retFileUrl = OSSUtil.upload(ossConfig,"/devicePersonLog",faceImageJson.getStr("Name"), inputStream);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+
+        PersonDeviceLog personDeviceLog = new PersonDeviceLog();
+        personDeviceLog.setId(UUID.randomUUID().toString());
+        personDeviceLog.setDeviceNo(deviceNo);
+        if (!StringUtils.isBlank(matchPersonInfo.getStr("PersonCode"))){
+            personDeviceLog.setPersonId(matchPersonInfo.getInt("PersonCode"));
+        }else {
+            personDeviceLog.setPersonId(0);
+        }
+
+        personDeviceLog.setTemperature(temperature);
+        if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))){
+            System.out.println();
+            personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
+            personDeviceLog.setMatchMsg(IApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
+            personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
+        }else {
+            personDeviceLog.setMatchStatus(0);
+            personDeviceLog.setMatchFaceId(0);
+        }
+
+        personDeviceLog.setRecordTime(date);
+        personDeviceLog.setDelFlag(false);
+        personDeviceLog.setCreateTime(new Date());
+        personDeviceLog.setFaceImage(retFileUrl);
+        personDeviceLogDAO.insert(personDeviceLog);
     }
 }

+ 95 - 0
common/src/main/java/com/jpsoft/smart/modules/common/utils/BASE64DecodedMultipartFile.java

@@ -0,0 +1,95 @@
+package com.jpsoft.smart.modules.common.utils;
+
+import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Decoder;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-3-15 16:06
+ */
+public class BASE64DecodedMultipartFile implements MultipartFile {
+
+    private final byte[] imgContent;
+    private final String header;
+
+    public BASE64DecodedMultipartFile(byte[] imgContent, String header) {
+        this.imgContent = imgContent;
+        this.header = header.split(";")[0];
+    }
+
+
+
+    @Override
+    public String getName() {
+        return null;
+    }
+
+    @Override
+    public String getOriginalFilename() {
+        return null;
+    }
+
+    @Override
+    public String getContentType() {
+        return null;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return false;
+    }
+
+    @Override
+    public long getSize() {
+        return 0;
+    }
+
+    @Override
+    public byte[] getBytes() throws IOException {
+        return new byte[0];
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return null;
+    }
+
+    @Override
+    public void transferTo(File file) throws IOException, IllegalStateException {
+
+    }
+
+    /**
+     * base64转MultipartFile文件
+     *
+     * @param base64
+     * @return
+     */
+    public static MultipartFile base64ToMultipart(String base64) {
+        try {
+            String[] baseStrs = base64.split(",");
+
+            System.out.println("base64:"+base64);
+            BASE64Decoder decoder = new BASE64Decoder();
+            byte[] b = new byte[0];
+            b = decoder.decodeBuffer(baseStrs[1]);
+
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
+                }
+            }
+
+            return new BASE64DecodedMultipartFile(b, baseStrs[0]);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+}

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/common/utils/IApiUtil.java

@@ -3,6 +3,7 @@ package com.jpsoft.smart.modules.common.utils;
 import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.HashMap;
 
@@ -99,5 +100,8 @@ public class IApiUtil {
 
         return matchMsg;
     }
+
+
+
 }
 

+ 51 - 0
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -0,0 +1,51 @@
+<?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">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO">
+    <resultMap id="PersonDeviceLogMap" type="PersonDeviceLog">
+        <id property="id" column="id_" />
+        <result property="createBy" column="create_by" />
+        <result property="createTime" column="create_time" />
+        <result property="updateBy" column="update_by" />
+        <result property="updateTime" column="update_time" />
+        <result property="delFlag" column="del_flag" />
+        <result property="deviceNo" column="device_no" />
+        <result property="personId" column="person_id" />
+        <result property="temperature" column="temperature_" />
+        <result property="matchStatus" column="match_status" />
+        <result property="matchMsg" column="match_msg" />
+        <result property="matchFaceId" column="match_face_id" />
+        <result property="faceImage" column="face_image" />
+        <result property="recordTime" column="record_time" />
+    </resultMap>
+    <insert id="insert" parameterType="PersonDeviceLog">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
+		insert into base_person_device_log
+	    (id_,create_by,create_time,update_by,update_time,del_flag,device_no,person_id,temperature_,match_status,match_msg,match_face_id,face_image,record_time)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{delFlag,jdbcType= NUMERIC }
+,#{deviceNo,jdbcType=VARCHAR}
+,#{personId,jdbcType=VARCHAR}
+,#{temperature,jdbcType=NUMERIC}
+,#{matchStatus,jdbcType=INTEGER}
+,#{matchMsg,jdbcType=VARCHAR}
+,#{matchFaceId,jdbcType= INTEGER}
+,#{faceImage,jdbcType=VARCHAR}
+,#{recordTime,jdbcType=TIMESTAMP}
+		)
+	]]>
+    </insert>
+
+</mapper>

+ 1 - 1
lapi/pom.xml

@@ -9,7 +9,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>lapi</artifactId>
-    <packaging>com.jpsoft.smart.lapi</packaging>
+    <packaging>jar</packaging>
     <properties>
         <netty-all.version>4.1.6.Final</netty-all.version>
     </properties>

+ 1 - 0
lapi/src/main/java/com/jpsoft/smart/LapiApplication.java

@@ -3,6 +3,7 @@ package com.jpsoft.smart;
 import com.jpsoft.smart.lapi.handler.HeartReportHandler;
 import com.jpsoft.smart.lapi.handler.ParseRequestHandler;
 import com.jpsoft.smart.lapi.handler.PersonVerificationHandler;
+import com.jpsoft.smart.lapi.handler.TextDecodeHandler;
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;

+ 30 - 8
lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java

@@ -7,6 +7,7 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -24,17 +25,26 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
 
     @Override
     protected void channelRead0(ChannelHandlerContext channelHandlerContext, PersonVerification personVerification) throws Exception {
-        log.warn(personVerification.toString());
+     //   log.warn(personVerification.toString());
         JSONObject jsonObject = personVerification.getJsonObject();
 
-        log.warn("DeviceCode"+jsonObject.getStr("DeviceCode"));
-        log.warn(jsonObject.toString());
+    //    log.warn("DeviceCode"+jsonObject.getStr("DeviceCode"));
+     //   log.warn(jsonObject.toString());
       //  JSONObject faceJson = jsonObject.get("FaceInfoList");
-        log.warn("FaceInfoList" +jsonObject.getStr("FaceInfoList"));
+     //   log.warn("FaceInfoList" +jsonObject.getStr("FaceInfoList"));
 
 
         JSONObject faceJson = new JSONObject(jsonObject.getStr("FaceInfoList").substring(1,jsonObject.getStr("FaceInfoList").length()-1));
-        log.warn(faceJson.getStr("FaceImage"));
+      //  log.warn(faceJson.getStr("FaceImage"));
+
+        long timestamp = faceJson.getLong("Timestamp");
+
+        Date date = new Date(timestamp);
+
+     //   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+
+
 
         //设备序列号
         String deviceNo = jsonObject.getStr("DeviceCode");
@@ -45,14 +55,26 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
         //人员抓拍信息
         JSONObject faceImageJson = faceJson.getJSONObject("FaceImage");
 
+        //log.warn("jsonObject========"+jsonObject);
+      //  log.warn("LibMatInfoList:----"+ jsonObject.getStr("LibMatInfoList"));
         //匹配状态信息
-        JSONObject libMatInfoListJson = new JSONObject(jsonObject.getStr("LibMatInfoList").substring(1,jsonObject.getStr("LibMatInfoList").length()-1));
+        JSONObject libMatInfoListJson = new JSONObject();
+        if (StringUtils.isNotBlank(jsonObject.getStr("LibMatInfoList").substring(1,jsonObject.getStr("LibMatInfoList").length()-1))){
+             libMatInfoListJson = new JSONObject(jsonObject.getStr("LibMatInfoList").substring(1,jsonObject.getStr("LibMatInfoList").length()-1));
+        }
+
 
         //匹配人员信息
-        JSONObject matchPersonInfo = libMatInfoListJson.getJSONObject("MatchPersonInfo");
+        JSONObject matchPersonInfo = new JSONObject();
+        if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchPersonInfo"))){
+            matchPersonInfo = libMatInfoListJson.getJSONObject("MatchPersonInfo");
+        }
+       // log.warn("MatchPersonInfo==="+libMatInfoListJson.getStr("MatchPersonInfo"));
+
 
+      //  log.warn("准备写入");
 
-        personDeviceLogService.deviceInsertLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo);
+        personDeviceLogService.deviceInsertLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo,date);
 
 
 

+ 61 - 17
web/src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java

@@ -35,12 +35,12 @@ public class CompanyInfoController {
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
-    public MessageResult<CompanyInfo> create(){
-        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+    public MessageResult<CompanyInfoDTO> create(){
+        MessageResult<CompanyInfoDTO> msgResult = new MessageResult<>();
 
-        CompanyInfo companyInfo = new CompanyInfo();
+        CompanyInfoDTO companyInfoDTO = new CompanyInfoDTO();
 
-        msgResult.setData(companyInfo);
+        msgResult.setData(companyInfoDTO);
         msgResult.setResult(true);
 
         return msgResult;
@@ -48,20 +48,37 @@ public class CompanyInfoController {
     
     @ApiOperation(value="添加信息")
     @PostMapping("add")
-    public MessageResult<CompanyInfo> add(@RequestBody CompanyInfo companyInfo,@RequestAttribute String subject){
-        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+    public MessageResult<Map> add(@RequestBody CompanyInfoDTO companyInfoDTO,@RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+        Map<String,Object> map = new HashMap<>();
 
         try {
+            CompanyInfo companyInfo = new CompanyInfo();
+            PojoUtils.map(companyInfoDTO, companyInfo);
             companyInfo.setId(UUID.randomUUID().toString());
             companyInfo.setDelFlag(false);
             companyInfo.setCreateBy(subject);
             companyInfo.setCreateTime(new Date());
-            
-            int affectCount = companyInfoService.insert(companyInfo);
+            companyInfoService.insert(companyInfo);
+            map.put("companyInfo",companyInfo);
+
+            CompanyPosition companyPosition = new CompanyPosition();
+            companyPosition.setId(UUID.randomUUID().toString());
+            companyPosition.setCompanyId(companyInfo.getId());
+            companyPosition.setPosition1Name(companyInfoDTO.getPosition1Name());
+            companyPosition.setPosition2Name(companyInfoDTO.getPosition2Name());
+            companyPosition.setPosition3Name(companyInfoDTO.getPosition3Name());
+            companyPosition.setPosition4Name(companyInfoDTO.getPosition4Name());
+            companyPosition.setPosition5Name(companyInfoDTO.getPosition5Name());
+            companyPosition.setDelFlag(false);
+            companyPosition.setCreateBy(subject);
+            companyPosition.setCreateTime(new Date());
+            int affectCount = companyPositionService.insert(companyPosition);
+            map.put("companyPosition",companyPosition);
 
             if (affectCount > 0) {
                 msgResult.setResult(true);
-                msgResult.setData(companyInfo);
+                msgResult.setData(map);
             } else {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库添加失败");
@@ -79,15 +96,17 @@ public class CompanyInfoController {
 
     @ApiOperation(value="获取信息")
     @GetMapping("edit/{id}")
-    public MessageResult<CompanyInfo> edit(@PathVariable("id") String id){
-        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+    public MessageResult<CompanyInfoDTO> edit(@PathVariable("id") String id){
+        MessageResult<CompanyInfoDTO> msgResult = new MessageResult<>();
 
         try {
             CompanyInfo companyInfo = companyInfoService.get(id);
+            CompanyInfoDTO companyInfoDTO = new CompanyInfoDTO();
 
             if (companyInfo != null) {
+                PojoUtils.map(companyInfo, companyInfoDTO);
                 msgResult.setResult(true);
-                msgResult.setData(companyInfo);
+                msgResult.setData(companyInfoDTO);
             } else {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库不存在该记录!");
@@ -105,18 +124,43 @@ public class CompanyInfoController {
 
     @ApiOperation(value="更新")
     @PostMapping("update")
-    public MessageResult<CompanyInfo> update(@RequestBody CompanyInfo companyInfo,@RequestAttribute String subject){
-        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+    public MessageResult<Map> update(@RequestBody CompanyInfoDTO companyInfoDTO,@RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+        Map<String,Object> map = new HashMap<>();
 
         try {
+            int affectCount = 0;
+            CompanyInfo companyInfo = new CompanyInfo();
+            PojoUtils.map(companyInfoDTO, companyInfo);
             companyInfo.setUpdateBy(subject);
             companyInfo.setUpdateTime(new Date());
-            
-            int affectCount = companyInfoService.update(companyInfo);
+            companyInfoService.update(companyInfo);
+            map.put("companyInfo",companyInfo);
+            affectCount++;
+
+            CompanyPosition companyPosition = new CompanyPosition();
+            Map<String,Object> searchParams1 = new HashMap<>();
+            searchParams1.put("companyId",companyInfo.getId());
+            List<Sort> sortList1 = new ArrayList<>();
+            sortList1.add(new Sort("id_","asc"));
+            Page<CompanyPosition> page1 = companyPositionService.pageSearch(searchParams1,1,1,false,sortList1);
+            if(page1.size() > 0) {
+                companyPosition = page1.get(0);
+                companyPosition.setPosition1Name(companyInfoDTO.getPosition1Name());
+                companyPosition.setPosition2Name(companyInfoDTO.getPosition2Name());
+                companyPosition.setPosition3Name(companyInfoDTO.getPosition3Name());
+                companyPosition.setPosition4Name(companyInfoDTO.getPosition4Name());
+                companyPosition.setPosition5Name(companyInfoDTO.getPosition5Name());
+                companyPosition.setUpdateBy(subject);
+                companyPosition.setUpdateTime(new Date());
+                companyPositionService.update(companyPosition);
+                affectCount++;
+            }
+            map.put("companyPosition",companyPosition);
 
             if (affectCount > 0) {
                 msgResult.setResult(true);
-                msgResult.setData(companyInfo);
+                msgResult.setData(map);
             } else {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库更新失败");

+ 1 - 1
web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java

@@ -22,7 +22,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 @RestController
-@RequestMapping("/deviceInfo")
+@RequestMapping("/base/deviceInfo")
 @Api(description = "设备信息")
 public class DeviceInfoController {
     private Logger logger = LoggerFactory.getLogger(getClass());

+ 51 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -653,4 +653,55 @@ public class PersonInfoController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="导出人员")
+    @PostMapping("exportXls")
+    public MessageResult<String> exportXls(HttpServletRequest request, HttpServletResponse response){
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            //创建hssfWorkbook
+            HSSFWorkbook workbook = new HSSFWorkbook();
+
+            //创建工作簿
+            HSSFSheet sheet = workbook.createSheet();
+
+            //创建标题
+            HSSFRow row = sheet.createRow(0);
+            HSSFCell cell = row.createCell(0);
+            cell.setCellValue("商品信息汇总");
+
+
+            //todo 将wb保存到oss
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+
+            //todo 返回导入失败报表下载链接
+            msgResult.setData(downloadUrl);
+
+            //将exal输出到哪个文件夹中
+//            ByteArrayOutputStream out = new ByteArrayOutputStream();
+//            workbook.write(out);
+//            workbook.close();
+//
+//            String fileName = new String("导出数据".getBytes("UTF-8"), "iso-8859-1");
+//            response.setContentType("application/x-msdownload");
+//            response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".xls");
+//            response.getOutputStream().write(out.toByteArray());
+//            response.getOutputStream().flush();
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 0 - 90
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoExportController.java

@@ -1,90 +0,0 @@
-package com.jpsoft.smart.modules.base.controller;
-
-import com.github.pagehelper.Page;
-import com.jpsoft.smart.config.OSSConfig;
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
-import com.jpsoft.smart.modules.base.service.PersonInfoService;
-import com.jpsoft.smart.modules.common.dto.MessageResult;
-import com.jpsoft.smart.modules.common.dto.Sort;
-import com.jpsoft.smart.modules.common.utils.CheckIdCard;
-import com.jpsoft.smart.modules.common.utils.OSSUtil;
-import com.jpsoft.smart.modules.common.utils.POIUtils;
-import com.jpsoft.smart.modules.common.utils.PojoUtils;
-import com.jpsoft.smart.modules.sys.entity.User;
-import com.jpsoft.smart.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.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Sheet;
-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 javax.servlet.http.HttpServletResponse;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.*;
-
-@RestController
-@RequestMapping("/base/personInfo")
-@Api(description = "personInfo")
-public class PersonInfoExportController {
-    private Logger logger = LoggerFactory.getLogger(getClass());
-
-    @Autowired
-    private OSSConfig ossConfig;
-    @Autowired
-    private PersonInfoService personInfoService;
-    @Autowired
-    private UserService userService;
-
-    @ApiOperation(value="导出人员")
-    @PostMapping("exportXls")
-    public MessageResult<String> exportXls(HttpServletRequest request, HttpServletResponse response){
-        MessageResult<String> msgResult = new MessageResult<>();
-
-        try {
-            //创建hssfWorkbook
-            HSSFWorkbook workbook = new HSSFWorkbook();
-
-            //创建工作簿
-            HSSFSheet sheet = workbook.createSheet();
-
-            //创建标题
-            HSSFRow row = sheet.createRow(0);
-            HSSFCell cell = row.createCell(0);
-            cell.setCellValue("商品信息汇总");
-
-
-            //将exal输出到哪个文件夹中
-            //FileOutputStream fileOutputStream = new FileOutputStream(new File("C:\\Users\\D.K\\Desktop\\test.xls"));
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-            workbook.write(out);
-            workbook.close();
-
-            String fileName = new String("导出数据".getBytes("UTF-8"), "iso-8859-1");
-            response.setContentType("application/x-msdownload");
-            response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".xls");
-            response.getOutputStream().write(out.toByteArray());
-            response.getOutputStream().flush();
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
-
-            msgResult.setResult(false);
-            msgResult.setMessage(ex.getMessage());
-        }
-
-        return msgResult;
-    }
-}