Commit 7e631b2b authored by fangxinjiang's avatar fangxinjiang

excel to image -fxj

parent e459a804
......@@ -145,4 +145,12 @@ public class SocialHandleSearchVo extends TDispatchInfo {
@ExcelProperty("医生大反馈" )
@ExcelIgnore
private String ysdRemark;
/**
* 社保ID
*/
@TableField(exist = false)
@Schema(description ="社保ID")
@ExcelIgnore
private String socialId;
}
......@@ -50,6 +50,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
......@@ -886,4 +887,21 @@ public class TDispatchInfoController {
searchVo.setCreateBy(user.getId());
tDispatchInfoService.doexportFundInfoOne(response,searchVo);
}
/**
* @Author fxj
* @Description 导出花名册
* @Date 14:02 2024/12/10
* @Param
* @return
**/
@PostMapping("/doExportRoster")
@Operation(description = "导出花名册")
@SysLog("导出花名册")
public R<URL> doExportRoster(@RequestParam("socialId") String socialId, @RequestParam("type") String type,@RequestParam("unitCreditCode")String unitCreditCode) {
return tDispatchInfoService.doExportRoster(socialId,type,unitCreditCode);
}
}
......@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
......@@ -161,4 +162,5 @@ public interface TDispatchInfoService extends IService<TDispatchInfo> {
**/
List<SocialHandleExportVo> getRecordRosterList(SocialHandleSearchVo searchVo, String idStr);
R<URL> doExportRoster(String socialId, String type,String unitCreditCode);
}
......@@ -63,6 +63,8 @@ import com.yifu.cloud.plus.v1.yifu.social.entity.*;
import com.yifu.cloud.plus.v1.yifu.social.mapper.*;
import com.yifu.cloud.plus.v1.yifu.social.service.*;
import com.yifu.cloud.plus.v1.yifu.social.util.DoSocialTask;
import com.yifu.cloud.plus.v1.yifu.social.util.ExcelMergeImage;
import com.yifu.cloud.plus.v1.yifu.social.util.ExcelToImage;
import com.yifu.cloud.plus.v1.yifu.social.util.ServiceUtil;
import com.yifu.cloud.plus.v1.yifu.social.vo.*;
import lombok.RequiredArgsConstructor;
......@@ -81,9 +83,12 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneId;
......@@ -137,6 +142,12 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
private DoSocialTask socialTask;
private final TDispatchSocialFundInfoService infoService;
@Autowired
private ExcelMergeImage excelMergeImage;
@Autowired
private ExcelToImage excelToImage;
@Autowired
private OSSUtil ossUtil;
/**
* 派单信息记录表简单分页查询
......@@ -7508,5 +7519,370 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
return list;
}
/**
* @Author fxj
* @Description
* @Date 15:58 2024/12/10
* @Param socialId:社保明细ID type: 1 社保增 2社保减 3 医保增 4 医保减
* @return
**/
@Override
public R<URL> doExportRoster(String socialId, String type,String unitCreditCode) {
SocialHandleSearchVo searchVo = new SocialHandleSearchVo();
if (Common.isEmpty(socialId) || Common.isEmpty(type) || Common.isEmpty(unitCreditCode)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TSocialInfo socialInfo = socialMapper.selectById(socialId);
if (Common.isEmpty(socialInfo)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
searchVo.setSocialHouseholdName(socialInfo.getSocialHouseholdName());
//searchVo.setDisMonth(DateUtil.getThisMonth());
searchVo.setDisMonth("202410");
searchVo.setAuditStatus(CommonConstants.ZERO_STRING);
//searchVo.setSocialHandleStatus(CommonConstants.ZERO_STRING);
searchVo.setUnitCreditCode(unitCreditCode);
searchVo.setSocialId(socialId);
//社保增减
if (CommonConstants.ONE_STRING.equals(type) || CommonConstants.TWO_STRING.equals(type)){
return doExportRosterSocial(searchVo,type);
}
//医保增减
if (CommonConstants.THREE_STRING.equals(type) || CommonConstants.FOUR_STRING.equals(type)){
return doExportRosterMedical(searchVo,type);
}
return null;
}
/**
* @Author fxj
* @Description 医保增加花名册
* @Date 16:29 2024/12/10
* @Param
* @return
**/
public R<URL> doExportRosterMedical(SocialHandleSearchVo searchVo,String type){
String fileName = DispatchConstants.SOCIAL_MEDICAL_EXPORT + searchVo.getSocialHouseholdName() + "_" + DateUtil.getThisMonth() + CommonConstants.XLSX;
//获取要导出的列表
List<TDispatchSocialExportVo> list = new ArrayList<>();
try (FileOutputStream out = new FileOutputStream(fileName)){
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out).build();
WriteSheet writeSheet;
WriteTable writeTable0;
WriteTable writeTable1;
WriteTable writeTable2;
WriteTable writeTable3;
WriteTable writeTable4;
TDispatchSocialExportVo vo;
List<Integer> columnIndexes = Arrays.asList(0,12);
CustomCellStyleStrategy customCellStyleStrategy = new CustomCellStyleStrategy(columnIndexes);
CustomCellStyleOneStrategy customCellStyleStrategyOne = new CustomCellStyleOneStrategy(columnIndexes);
CustomCellStyleTwoStrategy customCellStyleStrategyTwo = new CustomCellStyleTwoStrategy(columnIndexes);
CustomCellStyleThreeStrategy customCellStyleStrategyThree = new CustomCellStyleThreeStrategy(columnIndexes);
writeTable0 = EasyExcel.writerTable(0).
head(headOne()).
registerWriteHandler(customCellStyleStrategy).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)40,(short)20)).
build();
writeTable1 = EasyExcel.writerTable(1).
head(headTwo(searchVo.getSocialHouseholdName(),searchVo.getUnitCreditCode())).
registerWriteHandler(customCellStyleStrategyOne).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)25,(short)20)).
build();
writeTable2 = EasyExcel.writerTable(2).
head(headThree()).
registerWriteHandler(customCellStyleStrategyThree).
registerWriteHandler(new CustomCellWriteWidthConfig()).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)25,(short)20))
.build();
writeTable3 = EasyExcel.writerTable(3).
head(headFour()).
registerWriteHandler(customCellStyleStrategyTwo).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)50,(short)20))
.build();
writeTable4 = EasyExcel.writerTable(4).
head(headFive()).
registerWriteHandler(customCellStyleStrategyTwo).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)25,(short)20))
.build();
//派增的数据--医保增员
if (CommonConstants.THREE_STRING.equals(type)){
searchVo.setType(CommonConstants.ZERO_STRING);
long count = getSocialDisRecordCount(searchVo);
if (count > CommonConstants.ZERO_INT){
list = getSocialDisRecord(searchVo);
if (Common.isNotNull(list)) {
//判断list的大小是否大于10
if (list.size() < 10) {
int size = 10 - list.size();
int num = list.size() + 1;
for (int i =1;i<= size;i++) {
vo = new TDispatchSocialExportVo();
vo.setNum(num);
num ++;
list.add(vo);
}
}
writeSheet = EasyExcel.writerSheet("增员").build();
// 第一次写入会创建头
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
// 第二次写如也会创建头,然后在第一次的后面写入数据
excelWriter.write(list, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable4);
}
} else {
writeSheet = EasyExcel.writerSheet("增员").build();
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
// 第二次写如也会创建头,然后在第一次的后面写入数据
int num = 1;
for (int i =1;i<= 10;i++) {
vo = new TDispatchSocialExportVo();
vo.setNum(num);
num ++;
list.add(vo);
}
excelWriter.write(list, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable4);
}
}else if (CommonConstants.FOUR_STRING.equals(type)){
//派减的数据--医保减员
searchVo.setType(CommonConstants.ONE_STRING);
long count1 = getSocialDisRecordCount(searchVo);
if (count1 > CommonConstants.ZERO_INT){
list = baseMapper.getSocialReduceDisRecord(searchVo);
if (Common.isNotNull(list)) {
//判断list的大小是否大于10
if (list.size() < 10) {
int size = 10 - list.size();
int num = list.size() + 1;
for (int i =1;i<= size;i++) {
vo = new TDispatchSocialExportVo();
vo.setNum(num);
num ++;
list.add(vo);
}
}
writeSheet = EasyExcel.writerSheet("减员").build();
// 第一次写入会创建头
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
// 第二次写如也会创建头,然后在第一次的后面写入数据
excelWriter.write(list, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable4);
}
} else {
writeSheet = EasyExcel.writerSheet("减员").build();
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
// 第二次写如也会创建头,然后在第一次的后面写入数据
int num = 1;
list = new ArrayList<>();
for (int i =1;i<= 10;i++) {
vo = new TDispatchSocialExportVo();
vo.setNum(num);
num ++;
list.add(vo);
}
excelWriter.write(list, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable4);
}
}
if (excelWriter!= null) {
excelWriter.finish();
}
}catch (Exception e){
log.error("执行异常" ,e);
}
return null;
}
/**
* @Author fxj
* @Description 社保增减花名册
* @Date 16:28 2024/12/10
* @Param
* @return
**/
public R<URL> doExportRosterSocial(SocialHandleSearchVo searchVo,String type){
String fileName = DispatchConstants.SOCIAL_MEDICAL_EXPORT + searchVo.getSocialHouseholdName() + "_" + DateUtil.getThisMonth() + CommonConstants.XLS;
String projectRoot = System.getProperty("user.dir");
String filePath = projectRoot+"//"+fileName;
//获取要导出的列表
List<TDispatchSocialPersionExportVo> list = new ArrayList<>();
try {
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(filePath).build();
WriteSheet writeSheet;
WriteTable writeTable0;
WriteTable writeTable1;
WriteTable writeTable2;
WriteTable writeTable3;
WriteTable writeTable4;
TDispatchSocialPersionExportVo vo;
TDispatchSocialPersionReduceExportVo reduceVo;
if (CommonConstants.ONE_STRING.equals(type)){
//派增的数据--社保
searchVo.setType(CommonConstants.ZERO_STRING);
long count = getSocialPersionDisCount(searchVo);
List<Integer> columnIndexes = Arrays.asList(0,17);
CustomCellStyleStrategy customCellStyleStrategy = new CustomCellStyleStrategy(columnIndexes);
CustomCellStyleOneStrategy customCellStyleStrategyOne = new CustomCellStyleOneStrategy(columnIndexes);
CustomCellStyleTwoStrategy customCellStyleStrategyTwo = new CustomCellStyleTwoStrategy(columnIndexes);
CustomCellStyleThreeStrategy customCellStyleStrategyThree = new CustomCellStyleThreeStrategy(columnIndexes);
writeTable0 = EasyExcel.writerTable(0).
head(persionHeadOne()).
registerWriteHandler(customCellStyleStrategy).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)40,(short)20)).
build();
writeTable1 = EasyExcel.writerTable(1).
head(persionHeadTwo(searchVo.getSocialHouseholdName(),searchVo.getCustomerNo())).
registerWriteHandler(customCellStyleStrategyOne).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)20,(short)20)).
build();
writeTable2 = EasyExcel.writerTable(2).
head(persionHead()).
registerWriteHandler(customCellStyleStrategyThree).
registerWriteHandler(new CustomCellWriteWidthOneConfig()).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)30,(short)20))
.build();
writeTable3 = EasyExcel.writerTable(3).
head(persionHeadThree()).
registerWriteHandler(customCellStyleStrategyTwo).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)150,(short)20))
.build();
writeTable4 = EasyExcel.writerTable(4).
head(persionHead1()).
registerWriteHandler(customCellStyleStrategyTwo).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)20,(short)20))
.build();
if (count > CommonConstants.ZERO_INT){
list = getSocialPersionDisRecord(searchVo);
if (Common.isNotNull(list)) {
//判断list的大小是否大于10
if (list.size() < 10) {
int size = 10 - list.size();
int num = list.size() + 1;
for (int i =1;i<= size;i++) {
vo = new TDispatchSocialPersionExportVo();
vo.setNum(num);
num ++;
list.add(vo);
}
}
writeSheet = EasyExcel.writerSheet("增员").build();
// 第一次写入会创建头
// 第二次写如也会创建头,然后在第一次的后面写入数据
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
excelWriter.write(list, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable4);
}
} else {
writeSheet = EasyExcel.writerSheet("增员").build();
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
int num = 1;
for (int i =1;i<= 10;i++) {
vo = new TDispatchSocialPersionExportVo();
vo.setNum(num);
num ++;
list.add(vo);
}
excelWriter.write(list, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable4);
}
}else if (CommonConstants.ONE_STRING.equals(type)){
//派减的数据--社保
searchVo.setType(CommonConstants.ONE_STRING);
long count1 = getSocialPersionReduceDisCount(searchVo);
//获取要导出的列表
List<TDispatchSocialPersionReduceExportVo> listReduce = new ArrayList<>();
List<Integer> columnIndex = Arrays.asList(0,24);
CustomCellStyleStrategy customCellStyleStrategy1 = new CustomCellStyleStrategy(columnIndex);
CustomCellStyleOneStrategy customCellStyleStrategy2 = new CustomCellStyleOneStrategy(columnIndex);
CustomCellStyleTwoStrategy customCellStyleStrategy3 = new CustomCellStyleTwoStrategy(columnIndex);
CustomCellStyleThreeStrategy customCellStyleStrategy4 = new CustomCellStyleThreeStrategy(columnIndex);
writeTable0 = EasyExcel.writerTable(0).
head(persionReduceHeadOne()).
registerWriteHandler(customCellStyleStrategy1).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)40,(short)20)).
build();
writeTable1 = EasyExcel.writerTable(1).
head(persionReduceHeadTwo(searchVo.getSocialHouseholdName(),searchVo.getCustomerNo())).
registerWriteHandler(customCellStyleStrategy2).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)20,(short)20)).
build();
writeTable2 = EasyExcel.writerTable(2).
head(persionReduceHead()).
registerWriteHandler(customCellStyleStrategy4).
registerWriteHandler(new CustomCellWriteWidthTwoConfig()).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)50,(short)20))
.build();
writeTable3 = EasyExcel.writerTable(3).
head(persionReduceHead1()).
registerWriteHandler(customCellStyleStrategy3).
registerWriteHandler(new SimpleRowHeightStyleStrategy((short)40,(short)20))
.build();
if (count1 > CommonConstants.ZERO_INT){
listReduce = getSocialPersionReduceDisRecord(searchVo);
if (Common.isNotNull(listReduce)) {
//判断list的大小是否大于10
if (listReduce.size() < 10) {
int size = 10 - listReduce.size();
int num = listReduce.size() + 1;
for (int i =1;i<= size;i++) {
reduceVo = new TDispatchSocialPersionReduceExportVo();
reduceVo.setNum(num);
num ++;
listReduce.add(reduceVo);
}
}
writeSheet = EasyExcel.writerSheet("减员").build();
// 第一次写入会创建头
// 第二次写如也会创建头,然后在第一次的后面写入数据
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
excelWriter.write(listReduce, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
}
} else {
writeSheet = EasyExcel.writerSheet("减员").build();
excelWriter.write(new ArrayList<>(), writeSheet, writeTable0);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
int num = 1;
for (int i =1;i<= 10;i++) {
reduceVo = new TDispatchSocialPersionReduceExportVo();
reduceVo.setNum(num);
num ++;
listReduce.add(reduceVo);
}
excelWriter.write(listReduce, writeSheet, writeTable2);
excelWriter.write(new ArrayList<>(), writeSheet, writeTable3);
}
}
if (excelWriter!= null) {
excelWriter.finish();
}
//读取文件 生成电子章
}catch (Exception e){
log.error("执行异常" ,e);
}
return null;
}
}
......@@ -4,6 +4,7 @@ import org.apache.commons.compress.utils.IOUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import java.awt.Color;
......@@ -17,6 +18,7 @@ import java.io.*;
* @Description
* @Version 1.0
*/
@Component
public class ExcelMergeImage {
public static void main(String[] args) throws IOException {
String excelFilePath = "E:\\test\\11\\1.xls";
......@@ -91,7 +93,7 @@ public class ExcelMergeImage {
* @Param
* @return
**/
public static FileOutputStream addPictureToExcel(FileInputStream fis,
public FileOutputStream addPictureToExcel(FileInputStream fis,
InputStream imageIs,
FileOutputStream fileOut,
int SheetNum){
......
......@@ -20,13 +20,10 @@ import java.net.URL;
* @Description excel 转换为 图片 并上传阿里云 (上传后自动删除生成的图片文件)
* @Version 1.0
*/
@RequiredArgsConstructor
@Component
public class ExcelToImage {
@Autowired
private static OSSUtil ossUtil;
public R<URL> excelToImg(InputStream inputStream ){
public R<URL> excelToImg(InputStream inputStream ,OSSUtil ossUtil){
String projectRoot = System.getProperty("user.dir");
//加载Excel工作表
Workbook wb = new Workbook();
......
......@@ -1577,6 +1577,7 @@
SELECT count(1) from (
SELECT 1
FROM t_dispatch_info a
left join t_social_info s on s.id=a.SOCIAL_ID
<where>
<include refid="where_getSocialDisRecord"/>
</where>
......@@ -2258,6 +2259,11 @@
<sql id="where_getSocialDisRecord">
a.DELETE_FLAG = 0
AND a.social_id is not null
<if test='tDispatchInfo.socialId != null and tDispatchInfo.socialId.trim() == "0" '>
AND a.social_id = #{tDispatchInfo.socialId}
</if>
<!-- dispatch-status 未提交1待审核2审核通过3审核不通过4办理完成5待SSC审核 -->
<if test='tDispatchInfo.auditStatus != null and tDispatchInfo.auditStatus.trim() == "0" '>
AND a.STATUS in ('2','4')
......@@ -2354,6 +2360,9 @@
<sql id="where_getSocialPersionDisRecord">
a.DELETE_FLAG = 0
AND a.social_id is not null
<if test='tDispatchInfo.socialId != null and tDispatchInfo.socialId.trim() == "0" '>
AND a.social_id = #{tDispatchInfo.socialId}
</if>
<!-- dispatch-status 未提交1待审核2审核通过3审核不通过4办理完成5待SSC审核 -->
<if test='tDispatchInfo.auditStatus != null and tDispatchInfo.auditStatus.trim() == "0"'>
AND a.STATUS in ('2','4')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment