diff --git a/mailbox-outer-admin/pom.xml b/mailbox-outer-admin/pom.xml
index e460f29..dee3af6 100644
--- a/mailbox-outer-admin/pom.xml
+++ b/mailbox-outer-admin/pom.xml
@@ -64,6 +64,12 @@
mailbox-common
+
+ com.alibaba
+ easyexcel
+ 3.3.2
+
+
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java
index c0006a8..01fc8db 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java
@@ -1,16 +1,23 @@
package com.biutag.outeradmin.controller;
-import com.biutag.outeradmin.entity.Holiday;
+import com.alibaba.fastjson2.JSON;
import com.biutag.outeradmin.dto.HolidayDTO;
+import com.biutag.outeradmin.dto.HolidayRefresh;
+import com.biutag.outeradmin.dto.HolidayYear;
+import com.biutag.outeradmin.entity.Holiday;
import com.biutag.outeradmin.mapper.HolidayMapper;
import com.biutag.outeradmin.service.HolidayService;
+import com.biutag.outeradmin.util.HolidayUtil;
import com.biutag.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -22,39 +29,33 @@ public class HolidayController {
private final HolidayService holidayService;
private final HolidayMapper holidayMapper;
-// @RequestMapping("/getholiday")
-// @ApiOperation("查询节假日")
-// public AjaxResult getlist(@RequestParam("search") String search) throws Exception {
-//
-// //判断年份
-// LocalDateTime currentDate = LocalDateTime.now();
-// int currentyear = currentDate.getYear();
-// if (Integer.parseInt(search) != currentyear) {
-// return AjaxResult.success();
-// }
-// Map> map = holidayService.showholiday();
-// return AjaxResult.success(map);
-//
-// }
-//
-//
-// @PostMapping("/saveholiday")
-// @ApiOperation("节假日")
-// public AjaxResult setlist(@RequestBody String search) throws Exception {
-// LocalDateTime currentDate = LocalDateTime.now();
-// int currentyear = currentDate.getYear();
-// if (Integer.parseInt(search) != currentyear) {
-// return AjaxResult.success();
-// }
-// holidayService.saveholiday(search);
-// return AjaxResult.success();
-//
-// }
+ @PostMapping("/refresh-holiday")
+ @ApiOperation("同步节假日信息")
+ public HolidayRefresh setlist(@RequestBody String year) throws Exception {
+ HolidayYear getYear = JSON.parseObject(year, HolidayYear.class);
+ HolidayRefresh holidayRefresh = new HolidayRefresh();
+ LocalDateTime currentDate = LocalDateTime.now();
+
+ String currentYear = Integer.toString(currentDate.getYear());
+// String currentYear = "2025";
+ if (getYear.getYear().equals(currentYear)) {
+ System.out.println("年份相同");
+ holidayRefresh.setMessage("success");
+ } else {
+ holidayMapper.delete(null);
+ List holidays = HolidayUtil.getAllHolidayByYear(getYear.getYear());
+ holidayService.saveBatch(holidays);
+ holidayRefresh.setMessage("success");
+ System.out.println("年份不同,重写数据库");
+ }
+ holidayRefresh.setHolidayList(getlist());
+ return holidayRefresh;
+ }
@RequestMapping("/show-holiday")
@ApiOperation("进入页面显示节假日")
- public List getlist() throws Exception {
+ public List getlist() {
List holidayList = holidayService.list();
List result = new ArrayList<>();
for (Holiday holiday : holidayList) {
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
index 76f2e55..c4e7d56 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
@@ -4,18 +4,18 @@ import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.biutag.outeradmin.dto.MailFormData;
-import com.biutag.outeradmin.dto.MailFormPage;
-import com.biutag.outeradmin.dto.MailPageInfo;
-import com.biutag.outeradmin.dto.PageSet;
+import com.biutag.outeradmin.dto.*;
import com.biutag.outeradmin.entity.*;
import com.biutag.outeradmin.mapper.MailMapper;
import com.biutag.outeradmin.service.MailService;
import com.biutag.outeradmin.util.DesensitizedUtil;
+import com.biutag.outeradmin.util.ExcelUtil;
import com.biutag.util.StringUtils;
+import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
+import java.io.IOException;
import java.util.List;
@RequiredArgsConstructor
@@ -121,6 +121,33 @@ public class MailController {
MailID mailID = JSON.parseObject(id, MailID.class);
//TODO 这里根据ID查询数据库,记得删掉
System.out.println(mailID.getID());
- return JSON.toJSONString(mailService.getById(mailID.getID()));
+ Mail mail = mailService.getById(mailID.getID());
+ mail.setContactIdCard(DesensitizedUtil.encryptIDCard(mail.getContactIdCard()));
+ mail.setContactPhone(DesensitizedUtil.encryptPhone(mail.getContactPhone()));
+ return JSON.toJSONString(mail);
+ }
+
+ @RequestMapping("/exportexcel")
+ public void exportexcel(HttpServletResponse response, @RequestBody String form) throws IOException {
+ MailFormPage formPage = JSON.parseObject(form, MailFormPage.class);
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ if(formPage != null && formPage.getFormData()!= null && formPage.getPageData()!= null){
+ MailFormData formData = formPage.getFormData();
+ queryWrapper.lambda().like(StringUtils.isNotEmpty(formData.getContactName()), Mail::getContactName, formData.getContactName())
+ .like(StringUtils.isNotEmpty(formData.getContactPhone()), Mail::getContactPhone, formData.getContactPhone())
+ .like(StringUtils.isNotEmpty(formData.getContactIdCard()), Mail::getContactIdCard, formData.getContactIdCard())
+ .like(StringUtils.isNotEmpty(formData.getId()), Mail::getId, formData.getId())
+ .like(StringUtils.isNotEmpty(formData.getContent()), Mail::getContent, formData.getContent());
+ if (CollectionUtils.isNotEmpty(formData.getDate()) && formData.getDate().size() == 2) {
+ queryWrapper.lambda().between(Mail::getCreateTime, formData.getDate().get(0), formData.getDate().get(1));
+ }
+ }
+
+ List mailPage = mailMapper.selectList( queryWrapper);
+ for (Mail mail : mailPage) {
+ mail.setContactIdCard(DesensitizedUtil.encryptIDCard(mail.getContactIdCard()));
+ mail.setContactPhone(DesensitizedUtil.encryptPhone(mail.getContactPhone()));
+ }
+ ExcelUtil.exportExcel(response, mailPage);
}
}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java
deleted file mode 100644
index 6fc5644..0000000
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.biutag.outeradmin.domain;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import java.io.Serializable;
-/**
- * 管理员
- */
-@Data
-@TableName("holiday")
-@NoArgsConstructor
-@AllArgsConstructor
-public class Holiday implements Serializable {
- @TableId(type = IdType.AUTO)
- private Integer id;
- private String date;
- private String holiday_flag;
- private String detail;
-}
\ No newline at end of file
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayRefresh.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayRefresh.java
new file mode 100644
index 0000000..0674b1d
--- /dev/null
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayRefresh.java
@@ -0,0 +1,10 @@
+package com.biutag.outeradmin.dto;
+
+import lombok.Data;
+
+import java.util.List;
+@Data
+public class HolidayRefresh {
+ private List holidayList;
+ private String message;
+}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayYear.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayYear.java
new file mode 100644
index 0000000..501d721
--- /dev/null
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/HolidayYear.java
@@ -0,0 +1,8 @@
+package com.biutag.outeradmin.dto;
+
+import lombok.Data;
+
+@Data
+public class HolidayYear {
+ private String year;
+}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailID.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailID.java
similarity index 66%
rename from mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailID.java
rename to mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailID.java
index 3b99519..287365c 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailID.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/dto/MailID.java
@@ -1,4 +1,4 @@
-package com.biutag.outeradmin.entity;
+package com.biutag.outeradmin.dto;
import lombok.Data;
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/model/vo/HolidayVo.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/model/vo/HolidayVo.java
deleted file mode 100644
index 723d0c7..0000000
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/model/vo/HolidayVo.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.biutag.outeradmin.model.vo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class HolidayVo {
- private String workingday;//日期
-
- private String content;//描述
-}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/ExcelUtil.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/ExcelUtil.java
new file mode 100644
index 0000000..d03b99d
--- /dev/null
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/ExcelUtil.java
@@ -0,0 +1,76 @@
+package com.biutag.outeradmin.util;
+
+
+
+
+import com.alibaba.excel.EasyExcel;
+
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
+import com.alibaba.excel.write.metadata.fill.FillWrapper;
+import com.biutag.outeradmin.entity.Mail;
+import jakarta.servlet.http.HttpServletResponse;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+public class ExcelUtil {
+ public static void exportExcel(HttpServletResponse response,List mailPage) throws IOException {
+ // 模板文件
+// String templateFile = "/excelmodel.xlsx";
+ Resource resource = new ClassPathResource("excelmodel.xlsx");
+ InputStream is = resource.getInputStream();
+// long date = new Date().getTime();
+ Calendar calendar = Calendar.getInstance();
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ System.out.println(formatter.format(calendar.getTime()));
+ String name = formatter.format(calendar.getTime())+".xlsx";
+ String fileName = new String(name.getBytes());
+ response.setContentType("application/octet-stream");
+ response.setCharacterEncoding("utf8");
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName);
+ // 根据模板文件生成目标文件
+ ExcelWriter excelWriter = EasyExcel
+ .write(response.getOutputStream(), Mail.class)
+ .withTemplate(is)
+ // 单独设置单元格格式
+// .registerWriteHandler(new CellStyleHandler())
+ .build();
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ // 每次都会重新生成新的一行,而不是使用下面的空行
+ FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
+ // 第一种占位符替换
+// Map map = new HashMap();
+// map.put("reportDate", reportDate);
+// excelWriter.fill(map, writeSheet);
+ // 第二种占位符替换,这里定义了 hisData
+ System.out.println(mailPage);
+ excelWriter.fill(new FillWrapper("mailPage",mailPage),fillConfig, writeSheet);
+ excelWriter.finish();
+ }
+
+//
+// private static List mailData(){
+// List resList = new ArrayList<>();
+// MailDto mailData = MailDto.builder()
+// .contactName("today")
+// .contactIdCard("34.211")
+// .contactPhone("1.222")
+// .caseNumber("34.211")
+// .createTime(new Date())
+// .build();
+// resList.add(mailData);
+// return resList;
+// }
+
+
+
+}
diff --git a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java
index 3a23b83..397b6e6 100644
--- a/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java
+++ b/mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java
@@ -1,8 +1,6 @@
package com.biutag.outeradmin.util;
-
-import com.biutag.outeradmin.domain.Holiday;
-import com.biutag.outeradmin.model.vo.HolidayVo;
+import com.biutag.outeradmin.entity.Holiday;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
@@ -60,17 +58,17 @@ public class HolidayUtil {
Holiday holiday = new Holiday();
DayOfWeek week = endDate.getDayOfWeek();
if(week == DayOfWeek.SATURDAY ) {
- holiday.setHoliday_flag("Y");
+ holiday.setHolidayFlag("Y");
holiday.setDate(endDate.format(formatter));
holiday.setDetail("周六");
allDateDayList.add(holiday);
}else if(week == DayOfWeek.SUNDAY){
- holiday.setHoliday_flag("Y");
+ holiday.setHolidayFlag("Y");
holiday.setDate(endDate.format(formatter));
holiday.setDetail("周日");
allDateDayList.add(holiday);
}else{
- holiday.setHoliday_flag("N");
+ holiday.setHolidayFlag("N");
holiday.setDate(endDate.format(formatter));
allDateDayList.add(holiday);
}
@@ -94,10 +92,10 @@ public class HolidayUtil {
holiday.setDate(dateTime);
if(value1.get("name").toString().contains("补班")){
holiday.setDetail("正常上班");
- holiday.setHoliday_flag("N");
+ holiday.setHolidayFlag("N");
}else {
holiday.setDetail(value1.get("name").toString());
- holiday.setHoliday_flag("Y");
+ holiday.setHolidayFlag("Y");
}
for(int i = 0;i> HolidayHandle(List list){
- Map> map = new HashMap>();
- for(Holiday holiday : list){
- HolidayVo holidayVo = new HolidayVo();
-
- if (holiday.getDetail()==null){
- continue;
- }else if(holiday.getDetail().contains("初")||holiday.getDetail().contains("元旦")||holiday.getDetail().contains("节")||holiday.getDetail().contains("周")){
- holidayVo.setContent(holiday.getDetail());
- }else if(holiday.getDetail().contains("正常上班")){
- holidayVo.setContent(holiday.getDetail());
- }
- String mouth = holiday.getDate().substring(5,7);
- holidayVo.setWorkingday(holiday.getDate().substring(8,10));
-
- if (map.containsKey("mouth"+mouth)){
- List listofmap = map.get("mouth"+mouth);
- listofmap.add(holidayVo);
- }else {
- List listHolidayVo = new ArrayList<>();
- listHolidayVo.add(holidayVo);
- map.put("mouth"+mouth,listHolidayVo);
- }
- System.out.println(holidayVo);
- }
- return map;
- }
+// public static Map> HolidayHandle(List list){
+// Map> map = new HashMap>();
+// for(Holiday holiday : list){
+// HolidayVo holidayVo = new HolidayVo();
+//
+// if (holiday.getDetail()==null){
+// continue;
+// }else if(holiday.getDetail().contains("初")||holiday.getDetail().contains("元旦")||holiday.getDetail().contains("节")||holiday.getDetail().contains("周")){
+// holidayVo.setContent(holiday.getDetail());
+// }else if(holiday.getDetail().contains("正常上班")){
+// holidayVo.setContent(holiday.getDetail());
+// }
+// String mouth = holiday.getDate().substring(5,7);
+// holidayVo.setWorkingday(holiday.getDate().substring(8,10));
+//
+// if (map.containsKey("mouth"+mouth)){
+// List listofmap = map.get("mouth"+mouth);
+// listofmap.add(holidayVo);
+// }else {
+// List listHolidayVo = new ArrayList<>();
+// listHolidayVo.add(holidayVo);
+// map.put("mouth"+mouth,listHolidayVo);
+// }
+// System.out.println(holidayVo);
+// }
+// return map;
+// }
diff --git a/mailbox-outer-admin/src/main/resources/excelmodel.xlsx b/mailbox-outer-admin/src/main/resources/excelmodel.xlsx
new file mode 100644
index 0000000..9e4f9fa
Binary files /dev/null and b/mailbox-outer-admin/src/main/resources/excelmodel.xlsx differ