Compare commits

...

5 Commits

  1. BIN
      lib/javax.annotation.jar
  2. BIN
      lib/javax.ejb.jar
  3. BIN
      lib/javax.jms.jar
  4. BIN
      lib/javax.persistence.jar
  5. BIN
      lib/javax.resource.jar
  6. BIN
      lib/javax.servlet.jar
  7. BIN
      lib/javax.servlet.jsp.jar
  8. BIN
      lib/javax.servlet.jsp.jstl.jar
  9. BIN
      lib/javax.transaction.jar
  10. 12
      mailbox-common/pom.xml
  11. 7
      mailbox-outer-admin/pom.xml
  12. 19
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/config/MyBatisPlusConfig.java
  13. 65
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java
  14. 129
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java
  15. 29
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java
  16. 74
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/MailDto.java
  17. 16
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/FormData.java
  18. 10
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/FormPage.java
  19. 75
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Mail.java
  20. 8
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailID.java
  21. 11
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailPageInfo.java
  22. 10
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/PageSet.java
  23. 11
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java
  24. 9
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/MailMapper.java
  25. 14
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/model/vo/HolidayVo.java
  26. 15
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java
  27. 10
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/MailService.java
  28. 41
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java
  29. 23
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/DesensitizedUtil.java
  30. 76
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/ExcelUtil.java
  31. 163
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java
  32. BIN
      mailbox-outer-admin/src/main/resources/excelmodel.xlsx

BIN
lib/javax.annotation.jar

Binary file not shown.

BIN
lib/javax.ejb.jar

Binary file not shown.

BIN
lib/javax.jms.jar

Binary file not shown.

BIN
lib/javax.persistence.jar

Binary file not shown.

BIN
lib/javax.resource.jar

Binary file not shown.

BIN
lib/javax.servlet.jar

Binary file not shown.

BIN
lib/javax.servlet.jsp.jar

Binary file not shown.

BIN
lib/javax.servlet.jsp.jstl.jar

Binary file not shown.

BIN
lib/javax.transaction.jar

Binary file not shown.

12
mailbox-common/pom.xml

@ -3,6 +3,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<parent> <parent>
<groupId>com.biutag</groupId> <groupId>com.biutag</groupId>
<artifactId>mailbox-boot</artifactId> <artifactId>mailbox-boot</artifactId>

7
mailbox-outer-admin/pom.xml

@ -3,6 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.biutag</groupId> <groupId>com.biutag</groupId>
<artifactId>mailbox-boot</artifactId> <artifactId>mailbox-boot</artifactId>
@ -63,6 +65,11 @@
<groupId>${groupId}</groupId> <groupId>${groupId}</groupId>
<artifactId>mailbox-common</artifactId> <artifactId>mailbox-common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies> </dependencies>

19
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/config/MyBatisPlusConfig.java

@ -0,0 +1,19 @@
package com.biutag.outeradmin.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@MapperScan("com.biutag.outeradmin.mapper")
public class MyBatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
return interceptor;
}
}

65
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/HolidayController.java

@ -0,0 +1,65 @@
package com.biutag.outeradmin.controller;
import com.biutag.core.AjaxResult;
import com.biutag.outeradmin.model.vo.HolidayVo;
import com.biutag.outeradmin.service.HolidayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@RequiredArgsConstructor
@RestController
@Api(tags = "节假日接口")
@RequestMapping("/outer/holiday")
public class HolidayController {
@Resource
private HolidayService holidayService;
@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<String,List<HolidayVo>> 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();
}
@RequestMapping("/showholiday")
@ApiOperation("进入页面显示节假日")
public AjaxResult getlist() throws Exception {
Map<String,List<HolidayVo>> map = holidayService.showholiday();
return AjaxResult.success(map);
}
}

129
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/controller/MailController.java

@ -0,0 +1,129 @@
package com.biutag.outeradmin.controller;
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.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
@RequestMapping("/mailbox")
@RestController
public class MailController {
private final MailService mailService;
private final MailMapper mailMapper;
/**
* 查询所有信件
*
* @return 信件列表json
*/
@RequestMapping("/list")
public MailPageInfo list(@RequestBody String req) {
PageSet pageSet = JSON.parseObject(req, PageSet.class);
Page<Mail> page = new Page<>(pageSet.getCurrentPage(), pageSet.getPageSize());
List<Mail> mailPage = mailMapper.selectPage(page, null).getRecords();
for (Mail mail : mailPage) {
mail.setContactIdCard(DesensitizedUtil.encryptIDCard(mail.getContactIdCard()));
mail.setContactPhone(DesensitizedUtil.encryptPhone(mail.getContactPhone()));
}
pageSet.setTotalSize((int) page.getTotal());
MailPageInfo result = new MailPageInfo();
result.setMails(mailPage);
result.setPageSet(pageSet);
return result;
}
/**
* 查询指定信件
*
* @param form 前端信件表单数据
* @return 指定信件json
*/
@RequestMapping("/list-submit")
public MailPageInfo siftList(@RequestBody String form) {
//todo 这里根据表单数据查询数据库,记得删掉
System.out.println(form);
FormPage formPage = JSON.parseObject(form, FormPage.class);
QueryWrapper<Mail> queryWrapper = new QueryWrapper<>();
if(formPage != null && formPage.getFormData()!= null && formPage.getPageData()!= null){
FormData 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));
}
}
PageSet pageSet = formPage.getPageData();
Page<Mail> page = new Page<>(pageSet.getCurrentPage(), pageSet.getPageSize());
List<Mail> mailPage = mailMapper.selectPage(page, queryWrapper).getRecords();
for (Mail mail : mailPage) {
mail.setContactIdCard(DesensitizedUtil.encryptIDCard(mail.getContactIdCard()));
mail.setContactPhone(DesensitizedUtil.encryptPhone(mail.getContactPhone()));
}
pageSet.setTotalSize((int) page.getTotal());
MailPageInfo result = new MailPageInfo();
result.setMails(mailPage);
result.setPageSet(pageSet);
return result;
}
/**
* 查询指定信件详情
*
* @param id 信件ID
* @return 指定信件详情json
*/
@RequestMapping("/detail")
public String detail(@RequestBody String id) {
MailID mailID = JSON.parseObject(id, MailID.class);
//TODO 这里根据ID查询数据库,记得删掉
System.out.println(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 {
FormPage formPage = JSON.parseObject(form, FormPage.class);
QueryWrapper<Mail> queryWrapper = new QueryWrapper<>();
if(formPage != null && formPage.getFormData()!= null && formPage.getPageData()!= null){
FormData 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<Mail> mailPage = mailMapper.selectList( queryWrapper);
for (Mail mail : mailPage) {
mail.setContactIdCard(DesensitizedUtil.encryptIDCard(mail.getContactIdCard()));
mail.setContactPhone(DesensitizedUtil.encryptPhone(mail.getContactPhone()));
}
ExcelUtil.exportExcel(response, mailPage);
}
}

29
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/Holiday.java

@ -0,0 +1,29 @@
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;
}

74
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/domain/MailDto.java

@ -0,0 +1,74 @@
package com.biutag.outeradmin.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MailDto {
/**
* 联系人姓名
*/
private String contactName;
/**
* 联系人性别
*/
private String contactSex;
/**
* 联系人身份证号码
*/
private String contactIdCard;
/**
* 联系人手机号码
*/
private String contactPhone;
/**
* 案件编号
*/
private String caseNumber;
/**
* 内容
*/
private String content;
/**
* 附件
*/
private String attachments;
/**
* 用户ID
*/
private Integer userId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
// /**
// * 评价
// */
// private String evaluate;
/**
* 是否满意
*/
private String satisfaction;
}

16
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/FormData.java

@ -0,0 +1,16 @@
package com.biutag.outeradmin.entity;
import lombok.Data;
import java.util.List;
@Data
public class FormData {
private List<String> date;
private String contactName;
private String contactPhone;
private String contactIdCard;
private String id;
private String content;
private String evaluate;
}

10
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/FormPage.java

@ -0,0 +1,10 @@
package com.biutag.outeradmin.entity;
import lombok.Data;
@Data
public class FormPage {
private FormData formData;
private PageSet pageData;
}

75
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/Mail.java

@ -0,0 +1,75 @@
package com.biutag.outeradmin.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("mail")
public class Mail {
@TableId
private String id;
/**
* 联系人姓名
*/
private String contactName;
/**
* 联系人性别
*/
private String contactSex;
/**
* 联系人身份证号码
*/
private String contactIdCard;
/**
* 联系人手机号码
*/
private String contactPhone;
/**
* 案件编号
*/
private String caseNumber;
/**
* 内容
*/
private String content;
/**
* 附件
*/
private String attachments;
/**
* 用户ID
*/
private Integer userId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
// /**
// * 评价
// */
// private String evaluate;
/**
* 是否满意
*/
private String satisfaction;
}

8
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailID.java

@ -0,0 +1,8 @@
package com.biutag.outeradmin.entity;
import lombok.Data;
@Data
public class MailID {
private String ID;
}

11
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/MailPageInfo.java

@ -0,0 +1,11 @@
package com.biutag.outeradmin.entity;
import lombok.Data;
import java.util.List;
@Data
public class MailPageInfo {
private List<Mail> mails;
private PageSet pageSet;
}

10
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/entity/PageSet.java

@ -0,0 +1,10 @@
package com.biutag.outeradmin.entity;
import lombok.Data;
@Data
public class PageSet {
private int currentPage;
private int pageSize;
private int totalSize;
}

11
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/HolidayMapper.java

@ -0,0 +1,11 @@
package com.biutag.outeradmin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.entity.user.User;
import com.biutag.outeradmin.domain.Holiday;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HolidayMapper extends BaseMapper<Holiday> {
}

9
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/mapper/MailMapper.java

@ -0,0 +1,9 @@
package com.biutag.outeradmin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.outeradmin.entity.Mail;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MailMapper extends BaseMapper<Mail> {
}

14
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/model/vo/HolidayVo.java

@ -0,0 +1,14 @@
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;//描述
}

15
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/HolidayService.java

@ -0,0 +1,15 @@
package com.biutag.outeradmin.service;
import com.biutag.outeradmin.domain.Holiday;
import com.biutag.outeradmin.model.vo.HolidayVo;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public interface HolidayService {
List<Holiday> getholiday(String search) throws IOException;
void saveholiday(String search) throws IOException;
Map<String,List<HolidayVo>> showholiday();
}

10
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/MailService.java

@ -0,0 +1,10 @@
package com.biutag.outeradmin.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.outeradmin.entity.Mail;
import com.biutag.outeradmin.mapper.MailMapper;
import org.springframework.stereotype.Service;
@Service
public class MailService extends ServiceImpl<MailMapper, Mail> {
}

41
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/service/impl/HolidayServiceImpl.java

@ -0,0 +1,41 @@
package com.biutag.outeradmin.service.impl;
import com.biutag.outeradmin.domain.Holiday;
import com.biutag.outeradmin.mapper.HolidayMapper;
import com.biutag.outeradmin.model.vo.HolidayVo;
import com.biutag.outeradmin.service.HolidayService;
import com.biutag.outeradmin.util.HolidayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@Service
public class HolidayServiceImpl implements HolidayService {
@Autowired
private HolidayMapper holidayMapper;
@Override
public List<Holiday> getholiday(String search) throws IOException {
return HolidayUtil.getAllHolidayByYear(search);
}
public Map<String,List<HolidayVo>> showholiday() {
List<Holiday> list = holidayMapper.selectList(null);
return HolidayUtil.HolidayHandle(list);
}
@Override
public void saveholiday(String search) throws IOException {
holidayMapper.delete(null);
List<Holiday> list = HolidayUtil.getAllHolidayByYear(search);
for(Holiday holiday :list){
holidayMapper.insert(holiday);
}
}
}

23
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/DesensitizedUtil.java

@ -0,0 +1,23 @@
package com.biutag.outeradmin.util;
import com.biutag.util.StringUtils;
public class DesensitizedUtil {
public static String encryptIDCard(String idCard) {
if (StringUtils.isNotBlank(idCard)) {
if (idCard.length() == 15) {
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{4})", "$1******$2");
}
if (idCard.length() == 18) {
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{4})", "$1*********$2");
}
}
return idCard;
}
public static String encryptPhone(String phone) {
if (StringUtils.isNotBlank(phone)) {
phone = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
}
return phone;
}
}

76
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<Mail> 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<String, Object> map = new HashMap<String, Object>();
// 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<MailDto> mailData(){
// List<MailDto> 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;
// }
}

163
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/util/HolidayUtil.java

@ -0,0 +1,163 @@
package com.biutag.outeradmin.util;
import com.biutag.outeradmin.domain.Holiday;
import com.biutag.outeradmin.model.vo.HolidayVo;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class HolidayUtil {
/**
* 发送get请求
*/
private static String get(String url){
StringBuilder inputLine = new StringBuilder();
String read;
try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
urlConnection.setReadTimeout(30 * 1000);
urlConnection.setConnectTimeout(30 * 1000);
urlConnection.setRequestProperty("Charset", "UTF-8");
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), StandardCharsets.UTF_8));
while ((read = in.readLine()) != null) {
inputLine.append(read);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return inputLine.toString();
}
public static List<Holiday> getAllHolidayByYear(String year) throws IOException {
List<Holiday> allDateDayList = new ArrayList<>();
// SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
// ArrayList<HolidayVo> holidayVoList = new ArrayList<>();
// HashMap<String, HolidayVo> hashMap = new HashMap<>();
//查询全年日历包含周末
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
List<String> allDateList = new ArrayList<>();
LocalDate startDate = LocalDate.of(Integer.parseInt(year.trim()), 1, 1);
LocalDate endDate = startDate;
while (Integer.parseInt(year) == endDate.getYear()) {
Holiday holiday = new Holiday();
DayOfWeek week = endDate.getDayOfWeek();
if(week == DayOfWeek.SATURDAY ) {
holiday.setHoliday_flag("Y");
holiday.setDate(endDate.format(formatter));
holiday.setDetail("周六");
allDateDayList.add(holiday);
}else if(week == DayOfWeek.SUNDAY){
holiday.setHoliday_flag("Y");
holiday.setDate(endDate.format(formatter));
holiday.setDetail("周日");
allDateDayList.add(holiday);
}else{
holiday.setHoliday_flag("N");
holiday.setDate(endDate.format(formatter));
allDateDayList.add(holiday);
}
endDate = endDate.plusDays(1L);
}
//查询全年节假日、调休
String holidayJson = HolidayUtil.get("https://timor.tech/api/holiday/year/"+year + "/");
ObjectMapper mapper = new ObjectMapper();
Map holidayMap = mapper.readValue(holidayJson,Map.class);
LinkedHashMap holidayList = (LinkedHashMap)holidayMap.get("holiday");
// if(holidayList == null){
//
// }
holidayList.forEach((key,value) -> {
Holiday holiday = new Holiday();
Map value1 = (Map) value;
String dateTime = value1.get("date").toString();
holiday.setDate(dateTime);
if(value1.get("name").toString().contains("补班")){
holiday.setDetail("正常上班");
holiday.setHoliday_flag("N");
}else {
holiday.setDetail(value1.get("name").toString());
holiday.setHoliday_flag("Y");
}
for(int i = 0;i<allDateDayList.size();i++){
if (allDateDayList.get(i).getDate().equals(holiday.getDate())){
String detail = holiday.getDetail();
StringBuilder sb = new StringBuilder();
for (int j = 0; j < detail.length(); j++) {
char c = detail.charAt(j);
if (sb.indexOf(String.valueOf(c)) == -1) {
sb.append(c);
}
}
String result = sb.toString();
allDateDayList.remove(allDateDayList.get(i));
holiday.setDetail(result);
allDateDayList.add(holiday);
}
}
});
Collections.sort(allDateDayList, (o1, o2) -> {
Integer i = o1.getDate().compareTo(o2.getDate());
return i;
});
for(Holiday holiday : allDateDayList){
System.out.println(holiday);
}
return allDateDayList;
}
public static Map<String,List<HolidayVo>> HolidayHandle(List<Holiday> list){
Map<String,List<HolidayVo>> map = new HashMap<String,List<HolidayVo>>();
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<HolidayVo> listofmap = map.get("mouth"+mouth);
listofmap.add(holidayVo);
}else {
List<HolidayVo> listHolidayVo = new ArrayList<>();
listHolidayVo.add(holidayVo);
map.put("mouth"+mouth,listHolidayVo);
}
System.out.println(holidayVo);
}
return map;
}
}

BIN
mailbox-outer-admin/src/main/resources/excelmodel.xlsx

Binary file not shown.
Loading…
Cancel
Save