xiao547607 5 years ago
parent
commit
bd72d00daa

+ 57 - 48
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java

@@ -193,6 +193,7 @@ public class PersonDeviceLogController {
 
             HSSFWorkbook workbook = new HSSFWorkbook();
             HSSFSheet sheet = workbook.createSheet();
+
             //表头
             HSSFRow rowTitle = sheet.createRow(0);
             HSSFCell cellTitle1 = rowTitle.createCell(0);
@@ -216,7 +217,7 @@ public class PersonDeviceLogController {
             //CompanyInfo companyInfo = companyInfoService.get(companyId);
             List<CompanyPosition> companyPositionList = companyPositionService.findByCompanyId(companyId);
             CompanyPosition companyPosition = null;
-            if(companyPositionList.size() > 0){
+            if (companyPositionList.size() > 0) {
                 companyPosition = companyPositionList.get(0);
                 HSSFCell cellTitle8 = rowTitle.createCell(7);
                 cellTitle8.setCellValue(companyPosition.getPosition1Name());
@@ -230,88 +231,84 @@ public class PersonDeviceLogController {
                 cellTitle12.setCellValue(companyPosition.getPosition5Name());
             }
 
-
-
             //表内容
-            Map<String,Object> searchParams = new HashMap<>();
+            Map<String, Object> searchParams = new HashMap<>();
 
             List<Sort> sortList = new ArrayList<>();
-            sortList.add(new Sort("a.record_time","desc"));
+            sortList.add(new Sort("a.record_time", "desc"));
 
             //为公司管理员
-            boolean is_admin = userService.hasRole(subject,"ADMIN");
-            if(is_admin){
+            boolean is_admin = userService.hasRole(subject, "ADMIN");
+            if (is_admin) {
                 List<DeviceInfo> deviceInfoList = deviceInfoService.findByCompanyId(companyId);
                 List<String> deviceIdList = new ArrayList<String>();
-                if(deviceInfoList.size() > 0) {
+                if (deviceInfoList.size() > 0) {
                     for (DeviceInfo deviceInfo : deviceInfoList) {
                         deviceIdList.add(deviceInfo.getId());
                     }
-                }else{
+                } else {
                     deviceIdList.add("-1");
                 }
 
-                searchParams.put("deviceIdList",deviceIdList);
+                searchParams.put("deviceIdList", deviceIdList);
             }
 
-            if(StringUtil.isNotEmpty(deviceNo)){
-                searchParams.put("deviceNo","%"+deviceNo+"%");
+            if (StringUtil.isNotEmpty(deviceNo)) {
+                searchParams.put("deviceNo", "%" + deviceNo + "%");
             }
-            if(StringUtil.isNotEmpty(aliasName)){
-                searchParams.put("aliasName","%"+aliasName+"%");
+            if (StringUtil.isNotEmpty(aliasName)) {
+                searchParams.put("aliasName", "%" + aliasName + "%");
             }
-            if(StringUtil.isNotEmpty(personName)){
-                searchParams.put("personName","%"+personName+"%");
+            if (StringUtil.isNotEmpty(personName)) {
+                searchParams.put("personName", "%" + personName + "%");
             }
 
-            if(StringUtil.isNotEmpty(timeRanges)){
+            if (StringUtil.isNotEmpty(timeRanges)) {
                 String[] timeRangeArray = timeRanges.split(",");
                 String beginTime = "";
                 String endTime = "";
-                if(timeRangeArray.length==1){
+                if (timeRangeArray.length == 1) {
                     beginTime = timeRangeArray[0];
-                }
-                else if(timeRangeArray.length==2){
+                } else if (timeRangeArray.length == 2) {
                     beginTime = timeRangeArray[0];
                     endTime = timeRangeArray[1];
                 }
 
-                searchParams.put("beginTime",beginTime);
-                searchParams.put("endTime",endTime);
+                searchParams.put("beginTime", beginTime);
+                searchParams.put("endTime", endTime);
             }
 
-            if(StringUtil.isNotEmpty(temperatureRanges)){
+            if (StringUtil.isNotEmpty(temperatureRanges)) {
                 String[] temperatureRangeArray = temperatureRanges.split(",");
 
                 String minTemperature = "";
                 String maxTemperature = "";
-                if(temperatureRangeArray.length==1){
+                if (temperatureRangeArray.length == 1) {
                     minTemperature = temperatureRangeArray[0];
-                }
-                else if(temperatureRangeArray.length==2){
+                } else if (temperatureRangeArray.length == 2) {
                     minTemperature = temperatureRangeArray[0];
                     maxTemperature = temperatureRangeArray[1];
                 }
 
-                searchParams.put("minTemperature",minTemperature);
-                searchParams.put("maxTemperature",maxTemperature);
+                searchParams.put("minTemperature", minTemperature);
+                searchParams.put("maxTemperature", maxTemperature);
             }
 
-            Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams,1,10000,false,sortList);
+            Page<PersonDeviceLog> page = personDeviceLogService.pageSearch(searchParams, 1, 10000, false, sortList);
 
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
-            for(int i=0; i<page.size(); i++){
+            for (int i = 0; i < page.size(); i++) {
 
                 PersonDeviceLog personDeviceLog = page.get(i);
 
-                HSSFRow rowContent = sheet.createRow(i+1);
+                HSSFRow rowContent = sheet.createRow(i + 1);
 
                 HSSFCell cellContent1 = rowContent.createCell(0);
-                cellContent1.setCellValue(i+1);
+                cellContent1.setCellValue(i + 1);
 
-                String recordTime ="";
-                if(personDeviceLog.getRecordTime()!=null){
+                String recordTime = "";
+                if (personDeviceLog.getRecordTime() != null) {
                     recordTime = sdf.format(personDeviceLog.getRecordTime());
                 }
 
@@ -319,10 +316,9 @@ public class PersonDeviceLogController {
                 cellContent2.setCellValue(recordTime);
 
                 String name = "";
-                if(personDeviceLog.getPerson()!=null){
+                if (personDeviceLog.getPerson() != null) {
                     name = personDeviceLog.getPerson().getName();
-                }
-                else{
+                } else {
                     name = "匿名用户";
                 }
                 HSSFCell cellContent3 = rowContent.createCell(2);
@@ -338,20 +334,33 @@ public class PersonDeviceLogController {
 
                 //五级位置
                 //判断 如果公司没有五级位置 就不做展示
-                if(companyPositionList.size() > 0) {
+                if (companyPositionList.size() > 0) {
                     PersonInfo person = personDeviceLog.getPerson();
-                    HSSFCell cellContent8 = rowContent.createCell(7);
-                    cellContent8.setCellValue(person.getPosition1());
-                    HSSFCell cellContent9 = rowContent.createCell(8);
-                    cellContent9.setCellValue(person.getPosition2());
-                    HSSFCell cellContent10 = rowContent.createCell(9);
-                    cellContent10.setCellValue(person.getPosition3());
-                    HSSFCell cellContent11 = rowContent.createCell(10);
-                    cellContent11.setCellValue(person.getPosition4());
-                    HSSFCell cellContent12 = rowContent.createCell(11);
-                    cellContent12.setCellValue(person.getPosition5());
+                    if(person != null){
+                        HSSFCell cellContent8 = rowContent.createCell(7);
+                        if (person.getPosition1() != null) {
+                            cellContent8.setCellValue(person.getPosition1());
+                        }
+                        HSSFCell cellContent9 = rowContent.createCell(8);
+                        if (person.getPosition1() != null) {
+                            cellContent9.setCellValue(person.getPosition2());
+                        }
+                        HSSFCell cellContent10 = rowContent.createCell(9);
+                        if (person.getPosition1() != null) {
+                            cellContent10.setCellValue(person.getPosition3());
+                        }
+                        HSSFCell cellContent11 = rowContent.createCell(10);
+                        if (person.getPosition1() != null) {
+                            cellContent11.setCellValue(person.getPosition4());
+                        }
+                        HSSFCell cellContent12 = rowContent.createCell(11);
+                        if (person.getPosition1() != null) {
+                            cellContent12.setCellValue(person.getPosition5());
+                        }
+                    }
                 }
 
+
                 sheet.autoSizeColumn(i);
             }
 

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

@@ -908,7 +908,6 @@ public class PersonInfoController {
         try {
             HSSFWorkbook workbook = new HSSFWorkbook();
             HSSFSheet sheet = workbook.createSheet();
-            sheet.setColumnWidth(0, 10000);
             //表头
             HSSFRow rowTitle = sheet.createRow(0);
             HSSFCell cellTitle1 = rowTitle.createCell(0);