ezhizao_zx 1 年間 前
コミット
befa3ca16c
29 ファイル変更841 行追加31 行削除
  1. 88 0
      src/main/java/cn/ezhizao/common/utils/PdfUtil.java
  2. 161 3
      src/main/java/cn/ezhizao/project/business/housingFund/controller/BizHousingFundConfirmController.java
  3. 1 0
      src/main/java/cn/ezhizao/project/business/housingFund/controller/BizHousingFundDeclareController.java
  4. 2 2
      src/main/java/cn/ezhizao/project/business/keepAccounts/controller/BizFinancialKeepAccountController.java
  5. 1 0
      src/main/java/cn/ezhizao/project/business/keepAccounts/domain/BizFinancialKeepAccount.java
  6. 2 2
      src/main/java/cn/ezhizao/project/business/receiveTicket/controller/BizFinancialReceiveTicketController.java
  7. 3 0
      src/main/java/cn/ezhizao/project/business/receiveTicket/domain/BizFinancialReceiveTicket.java
  8. 1 1
      src/main/java/cn/ezhizao/project/business/reportTax/domain/BizFinancialReportTaxDetailNonZero.java
  9. 84 7
      src/main/java/cn/ezhizao/project/business/salary/controller/BizFinancialSalaryController.java
  10. 2 2
      src/main/java/cn/ezhizao/project/business/salary/controller/BizFinancialSalaryZeroController.java
  11. 2 0
      src/main/java/cn/ezhizao/project/business/salary/domain/BizFinancialSalary.java
  12. 42 0
      src/main/java/cn/ezhizao/project/business/salary/domain/BizFinancialSalaryDetail.java
  13. 5 0
      src/main/java/cn/ezhizao/project/business/salary/domain/BizFinancialSalaryDetailEmployee.java
  14. 165 3
      src/main/java/cn/ezhizao/project/business/socialSecurity/controller/SocialSecurityConfirmController.java
  15. 1 1
      src/main/java/cn/ezhizao/project/business/socialSecurity/controller/SocialSecurityDeclareController.java
  16. 1 1
      src/main/java/cn/ezhizao/project/business/socialSecurity/domain/BizSocialSecurityConfirm.java
  17. 1 0
      src/main/resources/mybatis/business/BizFinancialKeepAccountMapper.xml
  18. 6 2
      src/main/resources/mybatis/business/BizFinancialReceiveTicketMapper.xml
  19. 1 1
      src/main/resources/mybatis/business/BizFinancialReportTaxMapper.xml
  20. 1 1
      src/main/resources/mybatis/business/BizFinancialReportTaxNonZeroMapper.xml
  21. 2 1
      src/main/resources/mybatis/business/BizFinancialSalaryMapper.xml
  22. 3 2
      src/main/resources/mybatis/business/BizHousingFundConfirmMapper.xml
  23. 6 1
      src/main/resources/mybatis/business/BizProductionCompanyMapper.xml
  24. 5 1
      src/main/resources/mybatis/business/BizSocialSecurityConfirmMapper.xml
  25. 3 0
      src/main/resources/mybatis/business/BizSocialSecurityDeclareMapper.xml
  26. 1 0
      src/main/resources/mybatis/business/BizWorkOrderMapper.xml
  27. 71 0
      src/main/resources/templates/housingFundTemplate.html
  28. 109 0
      src/main/resources/templates/salaryTemplate.html
  29. 71 0
      src/main/resources/templates/socialSecurityTemplate.html

+ 88 - 0
src/main/java/cn/ezhizao/common/utils/PdfUtil.java

@@ -0,0 +1,88 @@
+package cn.ezhizao.common.utils;
+
+import com.itextpdf.html2pdf.ConverterProperties;
+import com.itextpdf.html2pdf.HtmlConverter;
+import com.itextpdf.kernel.geom.PageSize;
+import com.itextpdf.kernel.pdf.PdfDocument;
+import com.itextpdf.kernel.pdf.PdfWriter;
+import com.itextpdf.layout.font.FontProvider;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.*;
+import java.util.Map;
+
+public class PdfUtil {
+    @Autowired
+    private Configuration configuration;
+    /**
+     * 获取模板内容
+     * @param templateDirectory 模板文件夹
+     * @param templateName      模板文件名
+     * @param paramMap          模板参数
+     * @return
+     * @throws Exception
+     */
+    public static String getTemplateContent(String templateDirectory, String templateName, Map<String, Object> paramMap) throws Exception {
+        Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
+        try {
+            configuration.setDirectoryForTemplateLoading(new File(templateDirectory));
+        } catch (Exception e) {
+            System.out.println("-- exception --");
+        }
+
+        Writer out = new StringWriter();
+        Template template = configuration.getTemplate(templateName,"UTF-8");
+        template.process(paramMap, out);
+        out.flush();
+        out.close();
+        return out.toString();
+    }
+    /**
+     * HTML 转 PDF
+     * @param content html内容
+     * @param outPath           输出pdf路径
+     * @return 是否创建成功
+     */
+    public static boolean html2Pdf(String content, String outPath) {
+        try {
+            ConverterProperties converterProperties = new ConverterProperties();
+            converterProperties.setCharset("UTF-8");
+            FontProvider fontProvider = new FontProvider();
+            fontProvider.addSystemFonts();
+            converterProperties.setFontProvider(fontProvider);
+            HtmlConverter.convertToPdf(content, new FileOutputStream(outPath), converterProperties);
+        } catch (Exception e) {
+            System.out.println("生成模板内容失败,{}"+e);
+            return false;
+        }
+        return true;
+    }
+    /**
+     * HTML 转 PDF
+     * @param content html内容
+     * @return PDF字节数组
+     */
+    public static byte[] html2Pdf(String content) {
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        try {
+            ConverterProperties converterProperties = new ConverterProperties();
+            converterProperties.setCharset("UTF-8");
+            FontProvider fontProvider = new FontProvider();
+            fontProvider.addSystemFonts();
+            converterProperties.setFontProvider(fontProvider);
+            //设置pdf纸张
+            PdfWriter writer = new PdfWriter(outputStream);
+            PdfDocument pdf = new PdfDocument(writer);
+            pdf.setTagged();
+            //设置纸张的大小,并且设置默认的pdf大小
+            PageSize pageSize = PageSize.A3.rotate();
+            pdf.setDefaultPageSize(pageSize);
+            HtmlConverter.convertToPdf(content,pdf,converterProperties);
+        } catch (Exception e) {
+            System.out.print("生成 PDF 失败,{}"+e);
+        }
+        return outputStream.toByteArray();
+    }
+}

+ 161 - 3
src/main/java/cn/ezhizao/project/business/housingFund/controller/BizHousingFundConfirmController.java

@@ -1,5 +1,6 @@
 package cn.ezhizao.project.business.housingFund.controller;
 
+import cn.ezhizao.common.utils.PdfUtil;
 import cn.ezhizao.common.utils.SecurityUtils;
 import cn.ezhizao.framework.web.controller.BaseController;
 import cn.ezhizao.framework.web.domain.AjaxResult;
@@ -8,16 +9,38 @@ import cn.ezhizao.project.business.company.domain.BizCompany;
 import cn.ezhizao.project.business.company.service.IBizCompanyService;
 import cn.ezhizao.project.business.housingFund.domain.*;
 import cn.ezhizao.project.business.housingFund.service.*;
+import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetail;
+import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetailEmployee;
+import cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityConfirmDetail;
+import cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityConfirmDetailEmployee;
 import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
 
 import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -45,6 +68,12 @@ public class BizHousingFundConfirmController extends BaseController {
     @Resource
     IBizWorkOrderRecordService bizWorkOrderRecordService;
 
+    /**
+     * 生成pdf
+     */
+    @Autowired
+    private FreeMarkerConfigurer freeMarkerConfigurer;
+
     @ApiOperation(value = "根据id查询", notes = "根据id查询")
     @GetMapping("/getById/{id}")
     @ResponseBody
@@ -253,18 +282,18 @@ public class BizHousingFundConfirmController extends BaseController {
         return toAjax(bool);
     }
 
-    @PreAuthorize("@ss.hasPermi('business:housingFundConfirm:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:housingFundConfirm:verify')")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult turnBackDetail(@RequestBody BizHousingFundConfirmDetail detail) {
         // 先判断是否社保申报完成,申报完成状态不能进行工资退回
         BizHousingFundDeclareDetail financialReceiveTicketDetail = housingFundDeclareDetailService.query().eq("company_id", detail.getCompanyId()).eq("year", detail.getYear()).eq("month", detail.getMonth()).one();
         if (financialReceiveTicketDetail != null && financialReceiveTicketDetail.getStatus() == 3) {
-            return error("清先进行社保申报退回操作再进行人员信息退回。");
+            return error("请先进行公积金申报退回操作再进行人员信息退回。");
         } else {
             detail.setStatus(2);
         }
-        return toAjax(housingFundConfirmDetailService.updateById(detail) && addRecord(detail.getHousingFundConfirmId(), detail.getYear(), detail.getMonth(), SecurityUtils.getUserId(), "工资退回"));
+        return toAjax(housingFundConfirmDetailService.updateById(detail) && addRecord(detail.getHousingFundConfirmId(), detail.getYear(), detail.getMonth(), SecurityUtils.getUserId(), "公积金人员退回"));
     }
 
     @PreAuthorize("@ss.hasPermi('business:housingFundConfirm:edit')")
@@ -335,4 +364,133 @@ public class BizHousingFundConfirmController extends BaseController {
                     bizWorkOrderRecordService.updateById(fromRecord);
         }
     }
+
+    @ApiOperation("导出公积金人员信息")
+    @PostMapping("/exportHousingFundConfirmExcel")
+    public void exportDetailExcel(@RequestParam Long id, HttpServletResponse response) {
+        BizHousingFundConfirmDetail housingFundConfirm = housingFundConfirmDetailService.getById(id);
+        BizCompany company;
+
+        if (null != housingFundConfirm) {
+            Map<String, Object> map = new HashMap<>();
+//            BizHousingFundConfirmDetailEmployee map = new BizHousingFundConfirmDetailEmployee();
+            map.put("housingFundConfirmDetailId", housingFundConfirm.getId());
+//            map.setHousingFundConfirmDetailId(housingFundConfirm.getId());
+            List<BizHousingFundConfirmDetailEmployee> financialSalaryDetailEmployeeList = housingFundConfirmDetailEmployeeService.getList(map);
+            housingFundConfirm.setDetails(financialSalaryDetailEmployeeList);
+            company = companyService.getById(housingFundConfirm.getCompanyId());
+        } else {
+            return;
+        }
+        ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter(true);
+        writer.merge(0, 0, 0, 4, "公积金人员信息", true);
+        writer.merge(1, 1, 0, 2, company.getName(), false);
+        writer.merge(1, 1, 3, 4, housingFundConfirm.getYear() + "年 第" + housingFundConfirm.getMonth() + "期", false);
+        writer.writeCellValue(0, 2, "员工名");
+        writer.writeCellValue(1, 2, "电话号码");
+        writer.writeCellValue(2, 2, "基数");
+        writer.writeCellValue(3, 2, "比例");
+        writer.writeCellValue(4, 2, "备注");
+
+        int row = 0;
+        for (int i = 0; i < housingFundConfirm.getDetails().size(); i++) {
+            writer.writeCellValue(0, i + 3, housingFundConfirm.getDetails().get(i).getEmployeeName());
+            writer.writeCellValue(1, i + 3, housingFundConfirm.getDetails().get(i).getPhone());
+            writer.writeCellValue(2, i + 3, housingFundConfirm.getDetails().get(i).getCardinalNumber());
+            writer.writeCellValue(3, i + 3, housingFundConfirm.getDetails().get(i).getRatio());
+            writer.writeCellValue(4, i + 3, housingFundConfirm.getDetails().get(i).getRemark());
+
+            row = i + 1;
+        }
+
+        // 默认的,未添加alias的属性也会写出,如果想只写出加了别名的字段,可以调用此方法排除之
+        writer.setOnlyAlias(true);
+        // 设置列宽行高
+        writer.setDefaultRowHeight(22);
+
+        // 设置所有列宽自适应
+        writer.autoSizeColumnAll();
+        // 设置 列宽
+        writer.setColumnWidth(0, 10);
+        writer.setColumnWidth(1, 15);
+        writer.setColumnWidth(2, 10);
+        writer.setColumnWidth(3, 10);
+        writer.setColumnWidth(4, 10);
+
+        //设置标题单元格 样式
+        Font headFont = writer.createFont();
+        // 设置字体大小,加载到样式中
+        headFont.setFontHeightInPoints((short) 11);
+        headFont.setFontName("楷体_GB2312");
+        headFont.setBold(true);
+        CellStyle headCellStyle = writer.getStyleSet().getHeadCellStyle();
+        headCellStyle.setFont(headFont);
+        headCellStyle.setAlignment(HorizontalAlignment.CENTER);
+        headCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        //设置普通单元格 样式
+        Font contentFont = writer.createFont();
+        // 设置字体大小,加载到样式中
+        contentFont.setFontHeightInPoints((short) 11);
+        contentFont.setFontName("宋体");
+        CellStyle cellstyle = writer.getStyleSet().getCellStyle();
+        cellstyle.setFont(contentFont);
+        cellstyle.setAlignment(HorizontalAlignment.CENTER);
+        cellstyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        writer.setRowHeight(1, 22);
+        // headSize 为表格 标题 和 表头所占的 行数
+        int headSize = 3;
+
+        //out为OutputStream,需要写出到的目标流 response为HttpServletResponse对象
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
+        response.setHeader("Content-Disposition", "attachment;filename=test.xlsx");
+        ServletOutputStream out = null;
+        try {
+            out = response.getOutputStream();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        writer.flush(out, true);
+        // 关闭writer,释放内存
+        writer.close();
+        //此处记得关闭输出Servlet流
+        IoUtil.close(out);
+    }
+
+    @ApiOperation("打印公积金人员信息")
+    @PostMapping("/printDetailPdf")
+    public void SocialSecurityPdf(@RequestParam Long id, HttpServletResponse response) throws IOException, TemplateException {
+        BizHousingFundConfirmDetail housingFundConfirm = housingFundConfirmDetailService.getById(id);
+        BizCompany company;
+
+        if (null != housingFundConfirm) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("housingFundConfirmDetailId", housingFundConfirm.getId());
+            List<BizHousingFundConfirmDetailEmployee> financialSalaryDetailEmployeeList = housingFundConfirmDetailEmployeeService.getList(map);
+            housingFundConfirm.setDetails(financialSalaryDetailEmployeeList);
+            company = companyService.getById(housingFundConfirm.getCompanyId());
+            housingFundConfirm.setCompanyName(company.getName());
+        } else {
+            return;
+        }
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("housingFundConfirm" , housingFundConfirm);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
+        Writer out = new StringWriter();
+        //获取模板地址
+        Template template = freeMarkerConfigurer.getConfiguration().getTemplate("housingFundTemplate.html");
+        template.process(paramMap, out);
+        out.flush();
+        out.close();
+        String templateContent = out.toString();
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/pdf");
+        String fileName ="工资表";
+        response.setHeader("Content-Disposition", "filename=" + new String(fileName.getBytes(), "iso8859-1"));
+
+        byte[] resources = PdfUtil.html2Pdf(templateContent);
+        ServletOutputStream outputStream = response.getOutputStream();
+        outputStream.write(resources);
+        outputStream.close();
+    }
 }

+ 1 - 0
src/main/java/cn/ezhizao/project/business/housingFund/controller/BizHousingFundDeclareController.java

@@ -260,6 +260,7 @@ public class BizHousingFundDeclareController extends BaseController {
 
     @ApiOperation("退回")
     @PostMapping("/turnBackDetail")
+    @PreAuthorize("@ss.hasPermi('business:housingFundDeclare:edit')")
     @Transactional(rollbackFor = Exception.class)
     @ResponseBody
     public AjaxResult deductionTurnBack(@RequestBody BizHousingFundDeclareDetail detail) {

+ 2 - 2
src/main/java/cn/ezhizao/project/business/keepAccounts/controller/BizFinancialKeepAccountController.java

@@ -240,14 +240,14 @@ public class BizFinancialKeepAccountController extends BaseController {
         return toAjax(financialKeepAccountDetailService.updateById(bizFinancialSalaryDetail) && addRecord(bizFinancialSalaryDetail.getFinancialKeepAccountId(), bizFinancialSalaryDetail.getYear(), bizFinancialSalaryDetail.getMonth(), SecurityUtils.getUserId(), "修改记账信息"));
     }
 
-    @PreAuthorize("@ss.hasPermi('business:keepAccount:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:keepAccount:edit')")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult turnBackDetail(@RequestBody BizFinancialKeepAccountDetail detail) {
         // 先判断是否记账完成,记账完成状态不能进行工资退回
 //        BizFinancialKeepAccountDetail keepAccountDetail = financialKeepAccountDetailService.query().eq("company_id", detail.getCompanyId()).eq("year", detail.getYear()).eq("month", detail.getMonth()).one();
 //        if (keepAccountDetail != null && keepAccountDetail.getStatus() == 3) {
-//            return error("先进行记账退回操作再进行工资退回。");
+//            return error("先进行记账退回操作再进行工资退回。");
 //        } else {
 //            detail.setStatus(2);
 //        }

+ 1 - 0
src/main/java/cn/ezhizao/project/business/keepAccounts/domain/BizFinancialKeepAccount.java

@@ -86,4 +86,5 @@ public class BizFinancialKeepAccount extends BaseEntity {
     //执行人
     @TableField(exist = false)
     private String serviceName;
+
 }

+ 2 - 2
src/main/java/cn/ezhizao/project/business/receiveTicket/controller/BizFinancialReceiveTicketController.java

@@ -216,14 +216,14 @@ public class BizFinancialReceiveTicketController extends BaseController
         return toAjax(bool && financialReceiveTicketDetailService.updateById(detail));
     }
 
-    @PreAuthorize("@ss.hasPermi('business:receiveTicket:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:receiveTicket:verify')")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult turnBackDetail(@RequestBody BizFinancialReceiveTicketDetail detail) {
         // 先判断是否记账完成,记账完成状态不能进行工资退回
         BizFinancialKeepAccountDetail keepAccountDetail = financialKeepAccountDetailService.query().eq("company_id", detail.getCompanyId()).eq("year", detail.getYear()).eq("month", detail.getMonth()).one();
         if (keepAccountDetail != null && keepAccountDetail.getStatus() == 3) {
-            return error("先进行记账退回操作再进行工资退回。");
+            return error("先进行记账退回操作再进行工资退回。");
         } else {
             detail.setStatus(2);
         }

+ 3 - 0
src/main/java/cn/ezhizao/project/business/receiveTicket/domain/BizFinancialReceiveTicket.java

@@ -122,4 +122,7 @@ public class BizFinancialReceiveTicket extends BaseEntity
     @TableField(exist = false)
     private String serviceName;
 
+    @TableField(exist = false)
+    private String currentDate;
+
 }

+ 1 - 1
src/main/java/cn/ezhizao/project/business/reportTax/domain/BizFinancialReportTaxDetailNonZero.java

@@ -82,7 +82,7 @@ public class BizFinancialReportTaxDetailNonZero extends BaseEntity {
     @TableField(exist = false)
     private List<Long> mainIds;
 
-    @TableField(exist = false)
+//    @TableField(exist = false)
     private Long workOrderId;
 
     @TableField(exist = false)

+ 84 - 7
src/main/java/cn/ezhizao/project/business/salary/controller/BizFinancialSalaryController.java

@@ -1,18 +1,19 @@
 package cn.ezhizao.project.business.salary.controller;
 
 import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.ezhizao.common.utils.PdfUtil;
 import cn.ezhizao.common.utils.SecurityUtils;
 import cn.ezhizao.project.business.company.domain.BizCompany;
 import cn.ezhizao.project.business.company.service.IBizCompanyService;
@@ -36,11 +37,14 @@ import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
 import io.swagger.annotations.ApiOperation;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -52,6 +56,7 @@ import cn.ezhizao.framework.web.controller.BaseController;
 import cn.ezhizao.framework.web.domain.AjaxResult;
 import cn.ezhizao.common.utils.poi.ExcelUtil;
 import cn.ezhizao.framework.web.page.TableDataInfo;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
 
 /**
  * 工资Controller
@@ -79,6 +84,12 @@ public class BizFinancialSalaryController extends BaseController {
     @Resource
     private IBizCompanyService companyService;
 
+    /**
+     * 生成pdf
+     */
+    @Autowired
+    private FreeMarkerConfigurer freeMarkerConfigurer;
+
     @Resource
     private IBizFinancialSalaryDetailEmployeeService bizFinancialSalaryDetailEmployeeService;
     @Resource
@@ -245,14 +256,14 @@ public class BizFinancialSalaryController extends BaseController {
         return toAjax(bool);
     }
 
-    @PreAuthorize("@ss.hasPermi('business:salary:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:salary:verify')")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult turnBackDetail(@RequestBody BizFinancialSalaryDetail detail) {
         // 先判断是否收票完成,收票完成状态不能进行工资退回
         BizFinancialReceiveTicketDetail financialReceiveTicketDetail = financialReceiveTicketDetailService.query().eq("company_id", detail.getCompanyId()).eq("year", detail.getYear()).eq("month", detail.getMonth()).one();
         if (financialReceiveTicketDetail != null && financialReceiveTicketDetail.getStatus() == 3) {
-            return error("先进行收票退回操作再进行工资退回。");
+            return error("先进行收票退回操作再进行工资退回。");
         } else {
             detail.setStatus(2);
         }
@@ -347,7 +358,6 @@ public class BizFinancialSalaryController extends BaseController {
 
         if (null != financialSalaryDetail) {
             BizFinancialSalaryDetailEmployee map = new BizFinancialSalaryDetailEmployee();
-//            map.put("financialSalaryDetailId", financialSalaryDetail.getId());
             map.setFinancialSalaryDetailId(financialSalaryDetail.getId());
             List<BizFinancialSalaryDetailEmployee> financialSalaryDetailEmployeeList = bizFinancialSalaryDetailEmployeeService.getList(map);
             financialSalaryDetail.setDetails(financialSalaryDetailEmployeeList);
@@ -460,4 +470,71 @@ public class BizFinancialSalaryController extends BaseController {
         //此处记得关闭输出Servlet流
         IoUtil.close(out);
     }
+
+    @ApiOperation("打印工资信息")
+    @PostMapping("/printDetailPdf")
+    public void printDetailPdf(@RequestParam Long id, HttpServletResponse response) throws IOException, TemplateException {
+        //查询工资对象
+        BizFinancialSalaryDetail financialSalaryDetail = bizFinancialSalaryDetailService.getById(id);
+        BizCompany company;
+
+        if (null != financialSalaryDetail) {
+            BizFinancialSalaryDetailEmployee map = new BizFinancialSalaryDetailEmployee();
+            map.setFinancialSalaryDetailId(financialSalaryDetail.getId());
+            //查询员工信息
+            List<BizFinancialSalaryDetailEmployee> financialSalaryDetailEmployeeList = bizFinancialSalaryDetailEmployeeService.getList(map);
+            financialSalaryDetail.setDetails(financialSalaryDetailEmployeeList);
+            //计算每一列的合计金额
+            for (BizFinancialSalaryDetailEmployee employee : financialSalaryDetailEmployeeList){
+                employee.setIndividualIncomeTax(financialSalaryDetail.getHasIndividualIncomeTax()==1?employee.getIndividualIncomeTaxConfirm() : employee.getCurrentIndividualIncomeTax());
+                financialSalaryDetail.setPlanSalary(financialSalaryDetail.getPlanSalary()==null?employee.getPlanSalary() : financialSalaryDetail.getPlanSalary().add(employee.getPlanSalary()));
+                financialSalaryDetail.setActuallySalary(financialSalaryDetail.getActuallySalary()==null?employee.getActuallySalary() : financialSalaryDetail.getActuallySalary().add(employee.getActuallySalary()));
+                financialSalaryDetail.setBonusAmount(financialSalaryDetail.getBonusAmount()==null?employee.getBonusAmount() : financialSalaryDetail.getBonusAmount().add(employee.getBonusAmount()));
+                financialSalaryDetail.setEndowmentInsurance(financialSalaryDetail.getEndowmentInsurance()==null?employee.getEndowmentInsurance() : financialSalaryDetail.getEndowmentInsurance().add(employee.getEndowmentInsurance()));
+                financialSalaryDetail.setMedicalInsurance(financialSalaryDetail.getMedicalInsurance()==null?employee.getMedicalInsurance() : financialSalaryDetail.getMedicalInsurance().add(employee.getMedicalInsurance()));
+                financialSalaryDetail.setUnemploymentBenefit(financialSalaryDetail.getUnemploymentBenefit()==null?employee.getUnemploymentBenefit() : financialSalaryDetail.getUnemploymentBenefit().add(employee.getUnemploymentBenefit()));
+                financialSalaryDetail.setSeriousIllnessInsurance(financialSalaryDetail.getSeriousIllnessInsurance()==null?employee.getSeriousIllnessInsurance() : financialSalaryDetail.getSeriousIllnessInsurance().add(employee.getSeriousIllnessInsurance()));
+                financialSalaryDetail.setHousingFund(financialSalaryDetail.getHousingFund()==null?employee.getHousingFund() : financialSalaryDetail.getHousingFund().add(employee.getHousingFund()));
+                financialSalaryDetail.setIndividualIncomeTax(financialSalaryDetail.getIndividualIncomeTax()==null?employee.getIndividualIncomeTax() : financialSalaryDetail.getIndividualIncomeTax().add(employee.getIndividualIncomeTax()));
+                financialSalaryDetail.setOtherCut(financialSalaryDetail.getOtherCut()==null?employee.getOtherCut() : financialSalaryDetail.getOtherCut().add(employee.getOtherCut()));
+            }
+            if (financialSalaryDetailEmployeeList.size()==0){
+                financialSalaryDetail.setPlanSalary(BigDecimal.valueOf(0));
+                financialSalaryDetail.setActuallySalary(BigDecimal.valueOf(0));
+                financialSalaryDetail.setBonusAmount(BigDecimal.valueOf(0));
+                financialSalaryDetail.setEndowmentInsurance(BigDecimal.valueOf(0));
+                financialSalaryDetail.setMedicalInsurance(BigDecimal.valueOf(0));
+                financialSalaryDetail.setUnemploymentBenefit(BigDecimal.valueOf(0));
+                financialSalaryDetail.setSeriousIllnessInsurance(BigDecimal.valueOf(0));
+                financialSalaryDetail.setHousingFund(BigDecimal.valueOf(0));
+                financialSalaryDetail.setIndividualIncomeTax(BigDecimal.valueOf(0));
+                financialSalaryDetail.setOtherCut(BigDecimal.valueOf(0));
+            }
+            //查询客户信息
+            company = companyService.getById(financialSalaryDetail.getCompanyId());
+            //获取客户名称
+            financialSalaryDetail.setCompanyName(company.getName());
+        } else {
+            return;
+        }
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("financialSalaryDetail" , financialSalaryDetail);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
+        Writer out = new StringWriter();
+        //获取模板地址
+        Template template = freeMarkerConfigurer.getConfiguration().getTemplate("salaryTemplate.html");
+        template.process(paramMap, out);
+        out.flush();
+        out.close();
+        String templateContent = out.toString();
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/pdf");
+        String fileName ="工资表";
+        response.setHeader("Content-Disposition", "filename=" + new String(fileName.getBytes(), "iso8859-1"));
+
+        byte[] resources = PdfUtil.html2Pdf(templateContent);
+        ServletOutputStream outputStream = response.getOutputStream();
+        outputStream.write(resources);
+        outputStream.close();
+    }
 }

+ 2 - 2
src/main/java/cn/ezhizao/project/business/salary/controller/BizFinancialSalaryZeroController.java

@@ -228,14 +228,14 @@ public class BizFinancialSalaryZeroController extends BaseController {
         return toAjax(bool);
     }
 
-    @PreAuthorize("@ss.hasPermi('business:salary:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:salaryZero:verify')")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult turnBackDetail(@RequestBody BizFinancialSalaryDetail detail) {
         // 先判断是否收票完成,收票完成状态不能进行工资退回
         BizFinancialReceiveTicketDetail financialReceiveTicketDetail = financialReceiveTicketDetailService.query().eq("company_id", detail.getCompanyId()).eq("year", detail.getYear()).eq("month", detail.getMonth()).one();
         if (financialReceiveTicketDetail != null && financialReceiveTicketDetail.getStatus() == 3) {
-            return error("先进行收票退回操作再进行工资退回。");
+            return error("先进行收票退回操作再进行工资退回。");
         } else {
             detail.setStatus(2);
         }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/salary/domain/BizFinancialSalary.java

@@ -84,4 +84,6 @@ public class BizFinancialSalary extends BaseEntity
     //执行人
     @TableField(exist = false)
     private String serviceName;
+    @TableField(exist = false)
+    private String currentDate;
 }

+ 42 - 0
src/main/java/cn/ezhizao/project/business/salary/domain/BizFinancialSalaryDetail.java

@@ -87,4 +87,46 @@ public class BizFinancialSalaryDetail extends BaseEntity
     @TableField(exist = false)
     private List<BizFinancialSalaryDetailEmployee> details;
 
+    /** 打印数据 -总金额 */
+    //应发工资
+    @TableField(exist = false)
+    private BigDecimal  planSalary;
+
+    //实发工资
+    @TableField(exist = false)
+    private BigDecimal  actuallySalary;
+
+    //奖金及其它
+    @TableField(exist = false)
+    private BigDecimal  bonusAmount;
+
+    //养老保险
+    @TableField(exist = false)
+    private BigDecimal  endowmentInsurance;
+
+    //医疗保险
+    @TableField(exist = false)
+    private BigDecimal  medicalInsurance;
+
+    //失业险
+    @TableField(exist = false)
+    private BigDecimal  unemploymentBenefit;
+
+    //大病险
+    @TableField(exist = false)
+    private BigDecimal  seriousIllnessInsurance;
+
+    //公积金
+    @TableField(exist = false)
+    private BigDecimal  housingFund;
+
+    //个税
+    @TableField(exist = false)
+    private BigDecimal  individualIncomeTax;
+
+    //其他扣款
+    @TableField(exist = false)
+    private BigDecimal  otherCut;
+
+
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/salary/domain/BizFinancialSalaryDetailEmployee.java

@@ -195,4 +195,9 @@ public class BizFinancialSalaryDetailEmployee extends BaseEntity
     @ApiModelProperty(value = "确认税款")
     private Long companyId;
 
+    /** 打印数据 */
+    //个税
+    @TableField(exist = false)
+    private BigDecimal individualIncomeTax;
+
 }

+ 165 - 3
src/main/java/cn/ezhizao/project/business/socialSecurity/controller/SocialSecurityConfirmController.java

@@ -1,23 +1,48 @@
 package cn.ezhizao.project.business.socialSecurity.controller;
 
+import cn.ezhizao.common.utils.PdfUtil;
 import cn.ezhizao.common.utils.SecurityUtils;
 import cn.ezhizao.framework.web.controller.BaseController;
 import cn.ezhizao.framework.web.domain.AjaxResult;
 import cn.ezhizao.framework.web.page.TableDataInfo;
 import cn.ezhizao.project.business.company.domain.BizCompany;
 import cn.ezhizao.project.business.company.service.IBizCompanyService;
+import cn.ezhizao.project.business.housingFund.domain.BizHousingFundConfirmDetail;
+import cn.ezhizao.project.business.housingFund.domain.BizHousingFundConfirmDetailEmployee;
+import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetail;
+import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetailEmployee;
 import cn.ezhizao.project.business.socialSecurity.domain.*;
 import cn.ezhizao.project.business.socialSecurity.service.*;
 import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
 
 import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -39,6 +64,12 @@ public class SocialSecurityConfirmController extends BaseController {
     @Resource
     IBizSocialSecurityConfirmDetailEmployeeService socialSecurityConfirmDetailEmployeeService;
 
+    /**
+     * 生成pdf
+     */
+    @Autowired
+    private FreeMarkerConfigurer freeMarkerConfigurer;
+
     @Resource
     IBizSocialSecurityDeclareService socialSecurityDeclareService;
     @Resource
@@ -317,18 +348,18 @@ public class SocialSecurityConfirmController extends BaseController {
         return toAjax(bool);
     }
 
-    @PreAuthorize("@ss.hasPermi('business:socialSecurityConfirm:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:socialSecurityConfirm:verify')")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult turnBackDetail(@RequestBody BizSocialSecurityConfirmDetail detail) {
         // 先判断是否社保申报完成,申报完成状态不能进行工资退回
         BizSocialSecurityDeclareDetail financialReceiveTicketDetail = socialSecurityDeclareDetailService.query().eq("company_id", detail.getCompanyId()).eq("year", detail.getYear()).eq("month", detail.getMonth()).one();
         if (financialReceiveTicketDetail != null && financialReceiveTicketDetail.getStatus() == 3) {
-            return error("先进行社保申报退回操作再进行人员信息退回。");
+            return error("先进行社保申报退回操作再进行人员信息退回。");
         } else {
             detail.setStatus(2);
         }
-        return toAjax(socialSecurityConfirmDetailService.updateById(detail) && addRecord(detail.getSocialSecurityConfirmId(), detail.getYear(), detail.getMonth(), SecurityUtils.getUserId(), "工资退回"));
+        return toAjax(socialSecurityConfirmDetailService.updateById(detail) && addRecord(detail.getSocialSecurityConfirmId(), detail.getYear(), detail.getMonth(), SecurityUtils.getUserId(), "社保人员退回"));
     }
 
     private boolean addRecord(Long mainId, String year, String month, Long recorderId, String description) {
@@ -375,4 +406,135 @@ public class SocialSecurityConfirmController extends BaseController {
                     bizWorkOrderRecordService.updateById(fromRecord);
         }
     }
+
+    @ApiOperation("导出公积金人员信息")
+    @PostMapping("/exportSocialSecurityExcel")
+    public void exportDetailExcel(@RequestParam Long id, HttpServletResponse response) {
+        BizSocialSecurityConfirmDetail socialSecurityConfirm = socialSecurityConfirmDetailService.getById(id);
+        BizCompany company;
+
+        if (null != socialSecurityConfirm) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("socialSecurityConfirmDetailId", socialSecurityConfirm.getId());
+            List<BizSocialSecurityConfirmDetailEmployee> socialSecurityDetailEmployeeList = socialSecurityConfirmDetailEmployeeService.getList(map);
+            socialSecurityConfirm.setDetails(socialSecurityDetailEmployeeList);
+            company = companyService.getById(socialSecurityConfirm.getCompanyId());
+        } else {
+            return;
+        }
+        ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter(true);
+        writer.merge(0, 0, 0, 4, "公积金人员信息", true);
+        writer.merge(1, 1, 0, 2, company.getName(), false);
+        writer.merge(1, 1, 3, 4, socialSecurityConfirm.getYear() + "年 第" + socialSecurityConfirm.getMonth() + "期", false);
+        writer.writeCellValue(0, 2, "员工名");
+        writer.writeCellValue(1, 2, "电话号码");
+        writer.writeCellValue(2, 2, "基数");
+        writer.writeCellValue(3, 2, "医疗基数");
+        writer.writeCellValue(4, 2, "备注");
+
+        int row = 0;
+        for (int i = 0; i < socialSecurityConfirm.getDetails().size(); i++) {
+            writer.writeCellValue(0, i + 3, socialSecurityConfirm.getDetails().get(i).getEmployeeName());
+            writer.writeCellValue(1, i + 3, socialSecurityConfirm.getDetails().get(i).getPhone());
+            writer.writeCellValue(2, i + 3, socialSecurityConfirm.getDetails().get(i).getCardinalNumber());
+            writer.writeCellValue(3, i + 3, socialSecurityConfirm.getDetails().get(i).getMedicalCardinalNumber());
+            writer.writeCellValue(4, i + 3, socialSecurityConfirm.getDetails().get(i).getRemark());
+
+            row = i + 1;
+        }
+
+        // 默认的,未添加alias的属性也会写出,如果想只写出加了别名的字段,可以调用此方法排除之
+        writer.setOnlyAlias(true);
+        // 设置列宽行高
+        writer.setDefaultRowHeight(22);
+
+        // 设置所有列宽自适应
+        writer.autoSizeColumnAll();
+        // 设置 列宽
+        writer.setColumnWidth(0, 10);
+        writer.setColumnWidth(1, 15);
+        writer.setColumnWidth(2, 10);
+        writer.setColumnWidth(3, 10);
+        writer.setColumnWidth(4, 10);
+
+        //设置标题单元格 样式
+        Font headFont = writer.createFont();
+        // 设置字体大小,加载到样式中
+        headFont.setFontHeightInPoints((short) 11);
+        headFont.setFontName("楷体_GB2312");
+        headFont.setBold(true);
+        CellStyle headCellStyle = writer.getStyleSet().getHeadCellStyle();
+        headCellStyle.setFont(headFont);
+        headCellStyle.setAlignment(HorizontalAlignment.CENTER);
+        headCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        //设置普通单元格 样式
+        Font contentFont = writer.createFont();
+        // 设置字体大小,加载到样式中
+        contentFont.setFontHeightInPoints((short) 11);
+        contentFont.setFontName("宋体");
+        CellStyle cellstyle = writer.getStyleSet().getCellStyle();
+        cellstyle.setFont(contentFont);
+        cellstyle.setAlignment(HorizontalAlignment.CENTER);
+        cellstyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        writer.setRowHeight(1, 22);
+        // headSize 为表格 标题 和 表头所占的 行数
+        int headSize = 3;
+
+        //out为OutputStream,需要写出到的目标流 response为HttpServletResponse对象
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
+        response.setHeader("Content-Disposition", "attachment;filename=test.xlsx");
+        ServletOutputStream out = null;
+        try {
+            out = response.getOutputStream();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        writer.flush(out, true);
+        // 关闭writer,释放内存
+        writer.close();
+        //此处记得关闭输出Servlet流
+        IoUtil.close(out);
+    }
+
+
+    @ApiOperation("打印工资信息")
+    @PostMapping("/SocialSecurityPdf")
+    public void SocialSecurityPdf(@RequestParam Long id, HttpServletResponse response) throws IOException, TemplateException {
+        BizSocialSecurityConfirmDetail socialSecurityConfirm = socialSecurityConfirmDetailService.getById(id);
+        BizCompany company;
+
+        if (null != socialSecurityConfirm) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("socialSecurityConfirmDetailId", socialSecurityConfirm.getId());
+            List<BizSocialSecurityConfirmDetailEmployee> socialSecurityDetailEmployeeList = socialSecurityConfirmDetailEmployeeService.getList(map);
+            socialSecurityConfirm.setDetails(socialSecurityDetailEmployeeList);
+            company = companyService.getById(socialSecurityConfirm.getCompanyId());
+            socialSecurityConfirm.setCompanyName(company.getName());
+        } else {
+            return;
+        }
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("socialSecurityConfirm" , socialSecurityConfirm);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
+        Writer out = new StringWriter();
+        //获取模板地址
+        Template template = freeMarkerConfigurer.getConfiguration().getTemplate("socialSecurityTemplate.html");
+        template.process(paramMap, out);
+        out.flush();
+        out.close();
+        String templateContent = out.toString();
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/pdf");
+        String fileName ="工资表";
+        response.setHeader("Content-Disposition", "filename=" + new String(fileName.getBytes(), "iso8859-1"));
+
+        byte[] resources = PdfUtil.html2Pdf(templateContent);
+        ServletOutputStream outputStream = response.getOutputStream();
+        outputStream.write(resources);
+        outputStream.close();
+    }
+
+
+
 }

+ 1 - 1
src/main/java/cn/ezhizao/project/business/socialSecurity/controller/SocialSecurityDeclareController.java

@@ -253,7 +253,7 @@ public class SocialSecurityDeclareController extends BaseController {
         }
     }
 
-    @PreAuthorize("@ss.hasPermi('business:socialSecurityDeclare:turnBack')")
+    @PreAuthorize("@ss.hasPermi('business:socialSecurityDeclare:edit')")
     @ApiOperation("退回")
     @PostMapping("/turnBackDetail")
     @Transactional(rollbackFor = Exception.class)

+ 1 - 1
src/main/java/cn/ezhizao/project/business/socialSecurity/domain/BizSocialSecurityConfirm.java

@@ -64,7 +64,7 @@ public class BizSocialSecurityConfirm extends BaseEntity implements Serializable
     @TableField(exist = false)
     private String keyword;
 
-    @TableField(exist = false)
+//    @TableField(exist = false)
     private Long workOrderId;
 
     //是否为自己负责(当前登陆人Id)

+ 1 - 0
src/main/resources/mybatis/business/BizFinancialKeepAccountMapper.xml

@@ -25,6 +25,7 @@
     <sql id="getListSql">
         SELECT
         t1.*, t2.name as company_name,
+        (select concat(bwor.year, '年', bwor.month, '月') from biz_work_order_record bwor where bwor.work_order_id = t1.work_order_id order by year desc, month desc limit 1) currentDate,
         t3.account_name as from_company_name, t2.tax_type
         from biz_financial_keep_account t1
         left join biz_company t2 on t2.id = t1.company_id

+ 6 - 2
src/main/resources/mybatis/business/BizFinancialReceiveTicketMapper.xml

@@ -7,13 +7,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="cn.ezhizao.project.business.receiveTicket.domain.BizFinancialReceiveTicket" id="BizFinancialReceiveTicketResult">
         <id column="id" property="id"/>
         <result column="company_id" jdbcType="BIGINT" property="companyId" />
-        <association property="serviceName" select="getServiceName" column="company_id"></association>
+        <association property="serviceName" select="getServiceName" column="company_id" />
     </resultMap>
 
     <select id="getList" parameterType="BizFinancialReceiveTicket" resultMap="BizFinancialReceiveTicketResult">
         SELECT
         t1.*, t2.name as company_name,
-        (select concat(frtd.year, '-', frtd.month) from biz_financial_receive_ticket_detail frtd where frtd.financial_receive_ticket_id = t1.id order by year desc, month desc limit 1) currentDate,
+<!--        (select concat(frtd.year, '-', frtd.month) from biz_financial_receive_ticket_detail frtd where frtd.financial_receive_ticket_id = t1.id order by year desc, month desc limit 1) currentDate,-->
+        (select concat(bwor.year, '年', bwor.month, '月') from biz_work_order_record bwor where bwor.work_order_id = t1.work_order_id order by year desc, month desc limit 1) currentDate,
         t3.account_name as from_company_name, t2.tax_type
         from biz_financial_receive_ticket t1
         left join biz_company t2 on t2.id = t1.company_id
@@ -29,6 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="isZero != null">
             AND t2.is_zero = #{isZero}
         </if>
+        <if test="companyName != null and companyName != ''">
+            AND (t2.name like concat('%', #{companyName}, '%'))
+        </if>
         <if test="keyword != null and keyword != ''">
             AND (t2.name like concat('%', #{keyword}, '%') or t2.code like concat('%', #{keyword}, '%'))
         </if>

+ 1 - 1
src/main/resources/mybatis/business/BizFinancialReportTaxMapper.xml

@@ -12,7 +12,7 @@
     <!--带条件的List查询-->
     <select id="getList" resultMap="BaseResultMap">
         <include refid="getListSql"/>
-        ORDER BY id desc
+        ORDER BY create_time desc
     </select>
 
 

+ 1 - 1
src/main/resources/mybatis/business/BizFinancialReportTaxNonZeroMapper.xml

@@ -12,7 +12,7 @@
     <!--带条件的List查询-->
     <select id="getList" resultMap="BaseResultMap">
         <include refid="getListSql"/>
-        ORDER BY id desc
+        ORDER BY create_time desc
     </select>
 
 

+ 2 - 1
src/main/resources/mybatis/business/BizFinancialSalaryMapper.xml

@@ -12,7 +12,8 @@
 
 
     <select id="getList" parameterType="BizFinancialSalary" resultMap="BizFinancialSalaryResult">
-        SELECT t1.*, t2.name as company_name,t2.tax_type, t3.account_name as from_company_name
+        SELECT t1.*, t2.name as company_name,t2.tax_type, t3.account_name as from_company_name,
+        (select concat(bwor.year, '年', bwor.month, '月') from biz_work_order_record bwor where bwor.work_order_id = t1.work_order_id order by year desc, month desc limit 1) currentDate
         FROM biz_financial_salary t1
         left join biz_company t2 on t2.id = t1.company_id
         left join biz_tenant t3 on t3.id = t1.tenant_id

+ 3 - 2
src/main/resources/mybatis/business/BizHousingFundConfirmMapper.xml

@@ -20,8 +20,9 @@
 
     <sql id="getListSql">
         SELECT t1.*, t2.name as company_name,
-        (select concat(frtd.year, '-', frtd.month) from biz_housing_fund_confirm_detail frtd where
-        frtd.housing_fund_confirm_id = t1.id order by year desc, month desc limit 1) currentDate, t2.tax_type,
+        (select concat(bwor.year, '年', bwor.month, '月') from biz_work_order_record bwor where bwor.work_order_id = t1.work_order_id order by year desc, month desc limit 1) currentDate,
+<!--        (select concat(frtd.year, '-', frtd.month) from biz_housing_fund_confirm_detail frtd where frtd.housing_fund_confirm_id = t1.id order by year desc, month desc limit 1) currentDate, -->
+        t2.tax_type,
         t3.account_name as from_company_name
         FROM biz_housing_fund_confirm t1
         left join biz_company t2 on t2.id = t1.company_id

+ 6 - 1
src/main/resources/mybatis/business/BizProductionCompanyMapper.xml

@@ -124,7 +124,12 @@
             <if test="adviserId != null  and  adviserId != ''">AND c.adviser_id = #{adviserId}</if>
             <if test="leaderName != null and  leaderName != '' ">AND s.nick_name LIKE concat('%', #{leaderName}, '%')
             </if>
-            <if test="tenantId != null ">AND c.tenant_id = #{tenantId}</if>
+            <if test="tenantId != null ">
+                AND ( c.tenant_id = #{tenantId} or
+                exists (select 1 from biz_entrust e where e.company_id = c.id and e.deleted = 0
+                and (e.to_tenant_id = #{tenantId} or e.from_tenant_id = #{tenantId}))
+                )
+            </if>
             <if test="ids != null and ids.size() > 0">
                 AND c.id IN
                 <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">

+ 5 - 1
src/main/resources/mybatis/business/BizSocialSecurityConfirmMapper.xml

@@ -21,7 +21,8 @@
 
     <sql id="getListSql">
         SELECT t1.*, t2.name as company_name,
-        (select concat(frtd.year, '-', frtd.month) from biz_social_security_confirm_detail frtd where frtd.social_security_confirm_id = t1.id order by year desc, month desc limit 1) currentDate,
+        (select concat(bwor.year, '年', bwor.month, '月') from biz_work_order_record bwor where bwor.work_order_id = t1.work_order_id order by year desc, month desc limit 1) currentDate,
+<!--        (select concat(frtd.year, '-', frtd.month) from biz_social_security_confirm_detail frtd where frtd.social_security_confirm_id = t1.id order by year desc, month desc limit 1) currentDate,-->
         t3.account_name as from_company_name, t2.tax_type
         FROM biz_social_security_confirm t1
         left join biz_company t2 on t2.id = t1.company_id
@@ -46,6 +47,9 @@
             <if test="fromCompanyName != null and fromCompanyName != ''">
                 (t3.account_name like concat('%', #{fromCompanyName}, '%')) AND
             </if>
+            <if test="companyName != null and companyName != ''">
+                (t2.name like concat('%', #{companyName}, '%')) AND
+            </if>
             <if test="keyword != null and keyword != ''">
                 (t2.name like concat('%', #{keyword}, '%') or t2.code like concat('%', #{keyword}, '%')) AND
             </if>

+ 3 - 0
src/main/resources/mybatis/business/BizSocialSecurityDeclareMapper.xml

@@ -34,6 +34,9 @@
             <if test="principal != null and principal != ''">
                  (t2.leader_id=#{principal} OR t2.adviser_id=#{principal}) AND
             </if>
+            <if test="companyName != null and companyName != ''">
+                (t2.name like concat('%', #{companyName}, '%')) AND
+            </if>
             <if test="keyword != null and keyword != ''">
                 (t2.name like concat('%', #{keyword}, '%') or t2.code like concat('%', #{keyword}, '%')) AND
             </if>

+ 1 - 0
src/main/resources/mybatis/business/BizWorkOrderMapper.xml

@@ -48,6 +48,7 @@
             <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
             <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
             <if test="isStop != null ">AND t1.is_stop = #{isStop}</if>
+            <if test="companyName != null"> AND t2.name like concat('%', #{companyName}, '%')</if>
         </trim>
     </select>
 

+ 71 - 0
src/main/resources/templates/housingFundTemplate.html

@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:style="http://www.w3.org/1999/xhtml">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <style>        @page {
+        size: A4 portrait;
+        margin: 15px;
+    }
+    body {
+        margin: 0;
+        font-family: Arial, sans-serif;
+    }
+    table {
+        width: 100%;
+        border-collapse: collapse;
+        font-size: 10px;
+    }
+    th, td {
+        text-align: center;
+        padding: 5px;
+        border: 1px solid black;
+    }
+    .border {
+        border: 1px solid black !important;
+    }
+    .header {
+        background-color: #f2f2f2;
+        /*font-weight: bold;*/
+    }
+
+    /* 用于模拟5列布局 */
+    .col-1 { width: calc(100% / 5); }
+    </style>
+</head>
+<body>
+<table>
+    <!-- 第一行 -->
+    <tr class="header border col-12" >
+        <td align="center"  style="font-weight: bold;font-size: 12px;" valign="middle"bgcolor="#c0c0c0" colspan="5">公积金人员信息</td>
+    </tr>
+
+    <!-- 第二行 -->
+    <tr class="header border">
+        <td class="col-4" colspan="3" align="left" valign="middle"> ${housingFundConfirm.companyName}</td>
+        <td class="col-4" colspan="2" align="center" valign="middle">${ housingFundConfirm.year + "年 第" + housingFundConfirm.month + "期" }</td>
+    </tr>
+
+    <!-- 第三行 -->
+    <tr class="header border">
+        <td class="col-1" align="center" valign="middle">员工姓名</td>
+        <td class="col-1" align="center" valign="middle">电话号码</td>
+        <td class="col-1" align="center" valign="middle">基数</td>
+        <td class="col-1" align="center" valign="middle">比例</td>
+        <td class="col-1" align="center" valign="middle">备注</td>
+    </tr>
+
+    <!-- 动态数据行 -->
+    <#list housingFundConfirm.details  as item>
+    <tr class="border">
+        <td class="col-1" align="center">${ item.employeeName }</td>
+        <td class="col-1" align="center">${ item.phone }</td>
+        <td class="col-1" align="center">${ item.cardinalNumber }</td>
+        <td class="col-1" align="center">${ item.ratio }</td>
+        <td class="col-1" align="center">${ item.remark }</td>
+    </tr>
+    </#list>
+
+</table>
+</body>
+</html>

+ 109 - 0
src/main/resources/templates/salaryTemplate.html

@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html lang="zh">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <style>        @page {
+        size: A4 portrait;
+        margin: 15px;
+    }
+    body {
+        margin: 0;
+        font-family: Arial, sans-serif;
+    }
+    table {
+        width: 100%;
+        border-collapse: collapse;
+        font-size: 10px;
+    }
+    th, td {
+        text-align: center;
+        padding: 5px;
+        border: 1px solid black;
+    }
+    .border {
+        border: 1px solid black !important;
+    }
+    .header {
+        background-color: #f2f2f2;
+        /*font-weight: bold;*/
+    }
+    .total-row {
+        font-weight: bold;
+        background-color: lightgray;
+        text-align: center;
+    }
+    /* 用于模拟13列布局 */
+    .col-1 { width: calc(100% / 13); }
+    </style>
+</head>
+<body>
+<table>
+    <!-- 第一行 -->
+    <tr class="header border col-12" >
+        <td align="center" valign="middle"bgcolor="#c0c0c0" colspan="13">工资单</td>
+    </tr>
+
+    <!-- 第二行 -->
+    <tr class="header border">
+        <td class="col-4" colspan="4" align="left" valign="middle"> ${financialSalaryDetail.companyName}</td>
+        <td class="col-4" colspan="4" align="center" valign="middle">${ financialSalaryDetail.year + "年 第" + financialSalaryDetail.month + "期" }</td>
+        <td class="col-4" colspan="5" align="right" valign="middle">单位:元</td>
+    </tr>
+
+    <!-- 第三行 -->
+    <tr class="header border">
+        <td class="col-1" align="center" valign="middle">员工姓名</td>
+        <td class="col-1" align="center" valign="middle">身份证号</td>
+        <td class="col-1" align="center" valign="middle">应发工资</td>
+        <td class="col-1" align="center" valign="middle">实发工资</td>
+        <td class="col-1" align="center" valign="middle">奖金及其他</td>
+        <td class="col-1" align="center" valign="middle">养老保险</td>
+        <td class="col-1" align="center" valign="middle">医疗保险</td>
+        <td class="col-1" align="center" valign="middle">失业险</td>
+        <td class="col-1" align="center" valign="middle">大病险</td>
+        <td class="col-1" align="center" valign="middle">公积金</td>
+        <td class="col-1" align="center" valign="middle">个税</td>
+        <td class="col-1" align="center" valign="middle">其他扣款</td>
+        <td class="col-1" align="center" valign="middle">备注</td>
+    </tr>
+
+    <!-- 动态数据行 -->
+    <#list financialSalaryDetail.details  as item>
+    <tr class="border">
+        <td class="col-1" align="center">${ item.employeeName }</td>
+        <td class="col-1" align="center">${ item.idCode }</td>
+        <td class="col-1" align="center">${ item.planSalary }</td>
+        <td class="col-1" align="center">${ item.actuallySalary }</td>
+        <td class="col-1" align="center">${ item.bonusAmount }</td>
+        <td class="col-1" align="center">${ item.endowmentInsurance }</td>
+        <td class="col-1" align="center">${ item.medicalInsurance }</td>
+        <td class="col-1" align="center">${ item.unemploymentBenefit }</td>
+        <td class="col-1" align="center">${ item.seriousIllnessInsurance }</td>
+        <td class="col-1" align="center">${ item.housingFund }</td>
+        <td class="col-1" align="center">${ item.individualIncomeTax }</td>
+        <td class="col-1" align="center">${ item.otherCut }</td>
+        <td class="col-1" align="center">${ item.remark }</td>
+    </tr>
+    </#list>
+<!--     合计行-->
+    <tr class="total-row border">
+        <td class="col-1" align="center" colspan="1">合计</td>
+        <td class="col-1" align="center" colspan="1"></td>
+        <!-- 这里根据实际计算结果填充 -->
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.planSalary}</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.actuallySalary }</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.bonusAmount }</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.endowmentInsurance }</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.medicalInsurance}</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.unemploymentBenefit }</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.seriousIllnessInsurance}</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.housingFund }</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.individualIncomeTax}</td>
+        <td class="col-1" align="center" colspan="1">${ financialSalaryDetail.otherCut }</td>
+        <td class="col-1" align="center" colspan="1"></td>
+        <!-- ... 类似地填充剩余单元格 -->
+    </tr>
+</table>
+</body>
+</html>

+ 71 - 0
src/main/resources/templates/socialSecurityTemplate.html

@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:style="http://www.w3.org/1999/xhtml">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <style>        @page {
+        size: A4 portrait;
+        margin: 15px;
+    }
+    body {
+        margin: 0;
+        font-family: Arial, sans-serif;
+    }
+    table {
+        width: 100%;
+        border-collapse: collapse;
+        font-size: 10px;
+    }
+    th, td {
+        text-align: center;
+        padding: 5px;
+        border: 1px solid black;
+    }
+    .border {
+        border: 1px solid black !important;
+    }
+    .header {
+        background-color: #f2f2f2;
+        /*font-weight: bold;*/
+    }
+
+    /* 用于模拟5列布局 */
+    .col-1 { width: calc(100% / 5); }
+    </style>
+</head>
+<body>
+<table>
+    <!-- 第一行 -->
+    <tr class="header border col-12" >
+        <td align="center"  style="font-weight: bold;font-size: 12px;" valign="middle"bgcolor="#c0c0c0" colspan="5">社保人员信息</td>
+    </tr>
+
+    <!-- 第二行 -->
+    <tr class="header border">
+        <td class="col-4" colspan="3" align="left" valign="middle"> ${socialSecurityConfirm.companyName}</td>
+        <td class="col-4" colspan="2" align="center" valign="middle">${ socialSecurityConfirm.year + "年 第" + socialSecurityConfirm.month + "期" }</td>
+    </tr>
+
+    <!-- 第三行 -->
+    <tr class="header border">
+        <td class="col-1" align="center" valign="middle">员工姓名</td>
+        <td class="col-1" align="center" valign="middle">电话号码</td>
+        <td class="col-1" align="center" valign="middle">基数</td>
+        <td class="col-1" align="center" valign="middle">医疗基数</td>
+        <td class="col-1" align="center" valign="middle">备注</td>
+    </tr>
+
+    <!-- 动态数据行 -->
+    <#list socialSecurityConfirm.details  as item>
+    <tr class="border">
+        <td class="col-1" align="center">${ item.employeeName }</td>
+        <td class="col-1" align="center">${ item.phone }</td>
+        <td class="col-1" align="center">${ item.cardinalNumber }</td>
+        <td class="col-1" align="center">${ item.medicalCardinalNumber }</td>
+        <td class="col-1" align="center">${ item.remark }</td>
+    </tr>
+    </#list>
+
+</table>
+</body>
+</html>