Prechádzať zdrojové kódy

看板人员画像图表新增一个其他人员
光伏概览(右侧模块配置)中光伏盈利,改为节约金额+补贴金额+并网收入,数字随机

ZhangManMan 2 rokov pred
rodič
commit
8a2cb6d4dd

+ 17 - 0
src/main/java/com/sky/ioc/controller/notice/NoticeController.java

@@ -4,6 +4,7 @@ import com.sky.ioc.entity.domain.notice.Notice;
 import com.sky.ioc.entity.params.IocParam;
 import com.sky.ioc.entity.params.notice.NoticeParam;
 import com.sky.ioc.service.notice.NoticeService;
+import com.sky.ioc.tool.ExcelUtils;
 import com.sky.ioc.tool.ReturnMsg;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -11,7 +12,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @Api(tags ="通知")
 @Slf4j
@@ -46,4 +51,16 @@ public class NoticeController {
     public ReturnMsg getNotice(@RequestParam Integer id){
         return noticeService.getNotice(id);
     }
+
+    @ApiOperation("导出文件数据")
+    @GetMapping("/exportFile")
+    public void exportFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        List<Map<String,Object>> lists = noticeService.exportData(null);
+        List<String> columnKey = new ArrayList<>();
+        List<String> columnName = new ArrayList<>();
+        columnKey.add("title");
+        columnName.add("标题");
+        ExcelUtils.exportExcel("通知",columnName,columnKey,lists,request,response);
+       // return  "";
+    }
 }

+ 4 - 1
src/main/java/com/sky/ioc/mapper/notice/NoticeMapper.java

@@ -24,7 +24,10 @@ public interface NoticeMapper extends BaseMapper<Notice> {
             "<if test='noticeParam!=null and noticeParam.status != null '>" +
             " and status=#{noticeParam.status} " +
             "</if>"+
-            " order by time desc limit #{noticeParam.pageSize} offset #{noticeParam.pageStart}" +
+            " order by time desc " +
+            "<if test='noticeParam!=null and noticeParam.pageSize != null and noticeParam.pageStart != null '>" +
+            " limit #{noticeParam.pageSize} offset #{noticeParam.pageStart} " +
+            "</if>"+
             "</script>")
     List<Map<String,Object>> listPage(@Param("noticeParam")NoticeParam noticeParam);
 

+ 0 - 19
src/main/java/com/sky/ioc/service/assets/impl/AssetServiceImpl.java

@@ -47,26 +47,7 @@ public class AssetServiceImpl implements AssetService {
         String[] param = {"investment1","investment2","investment3","investment4","rateReturn"};
         String[] labKey = {"1季度","2季度","3季度","4季度"};
         ThreadLocalRandom random = ThreadLocalRandom.current();
-        //List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
         List<Label> list = new ArrayList<>();
-       /* for (int i = 0; i < labKey.length; i++) {
-            Label label = new Label();
-            JSONObject jsonObject = new JSONObject();
-            int i1 = random.nextInt(500, 620);
-            int i2 = random.nextInt(500, 620);
-            int i3 = random.nextInt(500, 620);
-            int i4 = random.nextInt(500, 620);
-            int i5 = random.nextInt(10, 90);
-            jsonObject.put(param[0],i1);
-            jsonObject.put(param[1],i2);
-            jsonObject.put(param[2],i3);
-            jsonObject.put(param[3],i4);
-            jsonObject.put(param[4],i5);
-            label.setJsonObject(jsonObject);
-            label.setLabel(labKey[i]);
-            list.add(label);
-        }*/
-
         Label label = new Label();
         JSONObject jsonObject = new JSONObject();
         jsonObject.put(param[0],767);

+ 2 - 1
src/main/java/com/sky/ioc/service/carbon/impl/CarbonServiceImpl.java

@@ -570,8 +570,9 @@ public class CarbonServiceImpl implements CarbonService {
     @Override
     public ReturnMsg getPhotovoltaicProfit() {
         List<Cake> list = new ArrayList<>();
-        list.add(new Cake("amountSubsidy"));
+        list.add(new Cake("subsidy"));
         list.add(new Cake("saving"));
+        list.add(new Cake("earning"));
         return ReturnMsg.ok(list);
     }
 

+ 3 - 1
src/main/java/com/sky/ioc/service/notice/NoticeService.java

@@ -4,16 +4,18 @@ import com.sky.ioc.entity.params.notice.NoticeParam;
 import com.sky.ioc.tool.ReturnMsg;
 
 import java.util.List;
+import java.util.Map;
 
 public interface NoticeService {
 
 
     ReturnMsg listPage(NoticeParam noticeParam);
 
-
     ReturnMsg readNotice(List<Integer> ids);
 
     ReturnMsg delNotice(List<Integer> ids);
 
     ReturnMsg getNotice(Integer id);
+
+    List<Map<String,Object>> exportData(NoticeParam noticeParam);
 }

+ 10 - 0
src/main/java/com/sky/ioc/service/notice/impl/NoticeServiceImpl.java

@@ -61,4 +61,14 @@ public class NoticeServiceImpl implements NoticeService {
 
         return ReturnMsg.ok(notice);
     }
+
+    @Override
+    public List<Map<String, Object>> exportData(NoticeParam noticeParam) {
+        List<Map<String,Object>> lists = noticeMapper.listPage(noticeParam);
+        for(Map<String,Object> map:lists){
+            Integer type = Integer.parseInt(String.valueOf( map.get("type")));
+            map.put("type",NoticeTypeEnums.getValue(type));
+        }
+        return  lists;
+    }
 }

+ 3 - 1
src/main/java/com/sky/ioc/service/personnel/impl/PersonnelServiceImpl.java

@@ -60,7 +60,7 @@ public class PersonnelServiceImpl implements PersonnelService {
     //查询智能看板统计画像的统计人员信息报表
     @Override
     public ReturnMsg getPersonnelInfoList() {
-        String[] param = {"ownEmployees","outsourcingStaff","visitors"};
+        String[] param = {"ownEmployees","outsourcingStaff","visitors","others"};
         List<String> lists = DateUtil.getBetweenDays("2023/03/01", "2023/03/31");
         String[] labKey = lists.toArray(new String[0]);
         List<Label> list = new ArrayList<>();
@@ -71,9 +71,11 @@ public class PersonnelServiceImpl implements PersonnelService {
             int ownEmployees = random.nextInt(500, 900);
             int outsourcingStaff = random.nextInt(0, ownEmployees);
             int visitors = random.nextInt(0, 50);
+            int others = random.nextInt(0, 50);
             jsonObject.put(param[0],ownEmployees);
             jsonObject.put(param[1],outsourcingStaff);
             jsonObject.put(param[2],visitors);
+            jsonObject.put(param[3],others);
             label.setJsonObject(jsonObject);
             label.setLabel(labKey[i]);
             list.add(label);

+ 76 - 0
src/main/java/com/sky/ioc/tool/ExcelUtils.java

@@ -0,0 +1,76 @@
+package com.sky.ioc.tool;
+
+import org.apache.coyote.Response;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.servlet.resource.HttpResource;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Excel 工具类
+ * */
+public class ExcelUtils {
+
+    /**
+     * 导出excel文件数据
+     * @param sheetName
+     * @param column
+     * @param data
+     * @param request
+     * @param response
+     */
+    public static void exportExcel(String sheetName,List<String> columnName, List<String> columnKey, List<Map<String,Object>> data,
+                                     HttpServletRequest request, HttpServletResponse response) {
+        //创建工作薄
+        HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
+        //创建sheet
+        HSSFSheet sheet = hssfWorkbook.createSheet(sheetName);
+        // 表头
+        HSSFRow headRow = sheet.createRow(0);
+        for (int i = 0; i < columnName.size(); i++){//填充表头数据
+            headRow.createCell(i).setCellValue(columnName.get(i));
+        }
+
+        for (int i = 0; i < data.size(); i++) {//填充表格数据
+            HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            for (int x = 0; x < columnKey.size(); x++) {
+                dataRow.createCell(x).setCellValue(data.get(i).get(columnKey.get(x))==null?"":data.get(i).get(columnKey.get(x)).toString());
+            }
+        }
+        response.setContentType("application/vnd.ms-excel");
+        try {
+            //获取浏览器名称
+            String agent=request.getHeader("user-agent");
+            String filename=sheetName+".xls";
+            //不同浏览器需要对文件名做特殊处理
+            if (agent.contains("Firefox")) { // 火狐浏览器
+                Base64.Encoder encoder = Base64.getEncoder();
+                filename = "=?UTF-8?B?" +
+                        encoder.encodeToString(filename.getBytes("utf-8"))
+                     //   + new BASE64Encoder().encode(filename.getBytes("utf-8"))
+                        + "?=";
+                filename = filename.replaceAll("\r\n", "");
+            } else { // IE及其他浏览器
+                filename = URLEncoder.encode(filename, "utf-8");
+                filename = filename.replace("+"," ");
+            }
+            //推送浏览器
+            response.setHeader("Content-Disposition", "attachment;filename=" + filename);//UTF-8
+            ServletOutputStream out = response.getOutputStream();
+            hssfWorkbook.write(out);
+            out.close();
+            hssfWorkbook.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}