ly 1 год назад
Родитель
Сommit
813921ca07

+ 31 - 6
pom.xml

@@ -16,7 +16,7 @@
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.6.8</version>
-        <relativePath />
+        <relativePath/>
     </parent>
 
     <properties>
@@ -149,7 +149,32 @@
             <artifactId>core</artifactId>
             <version>3.5.1</version>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.0.5</version>
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <groupId>javax.servlet</groupId>-->
+<!--                    <artifactId>servlet-api</artifactId>-->
+<!--                </exclusion>-->
+<!--                <exclusion>-->
+<!--                    <groupId>org.apache.poi</groupId>-->
+<!--                    <artifactId>poi</artifactId>-->
+<!--                </exclusion>-->
+<!--                <exclusion>-->
+<!--                    <groupId>org.apache.poi</groupId>-->
+<!--                    <artifactId>poi-ooxml</artifactId>-->
+<!--                </exclusion>-->
+<!--                <exclusion>-->
+<!--                    <groupId>org.apache.poi</groupId>-->
+<!--                    <artifactId>poi-ooxml-schemas</artifactId>-->
+<!--                </exclusion>-->
+
+<!--            </exclusions>-->
+
 
+        </dependency>
         <!-- 分布式锁 -->
         <dependency>
             <groupId>org.redisson</groupId>
@@ -170,11 +195,11 @@
         </dependency>
          -->
 
-<!--        <dependency>-->
-<!--            <groupId>cn.hutool</groupId>-->
-<!--            <artifactId>hutool-all</artifactId>-->
-<!--            <version>${hutool.version}</version>-->
-<!--        </dependency>-->
+        <!--        <dependency>-->
+        <!--            <groupId>cn.hutool</groupId>-->
+        <!--            <artifactId>hutool-all</artifactId>-->
+        <!--            <version>${hutool.version}</version>-->
+        <!--        </dependency>-->
 
         <!-- mybaits-plus  -->
         <dependency>

+ 124 - 17
src/main/java/cn/ezhizao/project/business/housingFund/controller/BizHousingFundDeclareController.java

@@ -15,29 +15,41 @@ import cn.ezhizao.project.business.housingFund.domain.BizHousingFundConfirmDetai
 import cn.ezhizao.project.business.housingFund.domain.BizHousingFundConfirmDetailEmployee;
 import cn.ezhizao.project.business.housingFund.domain.BizHousingFundDeclare;
 import cn.ezhizao.project.business.housingFund.domain.BizHousingFundDeclareDetail;
+import cn.ezhizao.project.business.housingFund.domain.vo.EmployeeExcel;
+import cn.ezhizao.project.business.housingFund.domain.vo.HousingFundEmployeeVo;
 import cn.ezhizao.project.business.housingFund.service.IBizHousingFundConfirmDetailEmployeeService;
 import cn.ezhizao.project.business.housingFund.service.IBizHousingFundConfirmDetailService;
 import cn.ezhizao.project.business.housingFund.service.IBizHousingFundDeclareDetailService;
 import cn.ezhizao.project.business.housingFund.service.IBizHousingFundDeclareService;
-import cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityDeclare;
-import cn.ezhizao.project.business.socialSecurity.domain.BizSocialSecurityDeclareDetail;
 import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
 import cn.ezhizao.project.system.domain.SysFileStorage;
 import cn.ezhizao.project.system.domain.SysUser;
 import cn.ezhizao.project.system.mapper.SysUserMapper;
 import cn.ezhizao.project.system.service.ISysFileStorageService;
+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 io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.ResourceLoader;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
 import java.time.LocalDate;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 
@@ -67,6 +79,8 @@ public class BizHousingFundDeclareController extends BaseController {
     IBizDeductionService deductionService;
     @Resource
     IBizWorkOrderRecordService bizWorkOrderRecordService;
+    @Resource
+    ResourceLoader resourceLoader;
 
     @ApiOperation(value = "根据id查询", notes = "根据id查询")
     @GetMapping("/getById/{id}")
@@ -82,6 +96,92 @@ public class BizHousingFundDeclareController extends BaseController {
         return (housingFundDeclare.getId() == null ? housingFundDeclareService.save(housingFundDeclare) : housingFundDeclareService.updateById(housingFundDeclare)) ? success() : error();
     }
 
+    @PostMapping("/exportDetail")
+    public void exportDetail(HttpServletResponse response, HousingFundEmployeeVo vo) throws Exception {
+        OutputStream out = null;
+        BufferedOutputStream bos = null;
+        List<BizHousingFundConfirmDetailEmployee> employees = new ArrayList<>();
+        List<EmployeeExcel> employeeExcels = new ArrayList<>();
+        try {
+            ClassPathResource classPathResource = new ClassPathResource("importTemplate/公积金模板.xlsx");
+            InputStream inputStream = classPathResource.getInputStream();
+            response.setContentType("application/vnd.ms-excel");
+            response.setCharacterEncoding("utf-8");
+            String fileName = URLEncoder.encode("公积金明细导出.xls", "utf-8");
+            response.setHeader("Content-disposition", "attachment; filename=" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1"));
+
+            out = response.getOutputStream();
+            bos = new BufferedOutputStream(out);
+
+            //读取Excel
+            ExcelWriter excelWriter = EasyExcel.write(bos).withTemplate(inputStream).build();
+            WriteSheet writeSheet = EasyExcel.writerSheet().build();
+
+            FillConfig fillConfig = FillConfig.builder()
+                    // 开启填充换行
+                    .forceNewRow(true)
+                    .build();
+            // 直接写入Excel数据
+            List<EmployeeExcel> list = getList(vo, employees, employeeExcels);
+            HashMap<String, Object> map = new HashMap<>();
+            String titleName = vo.getYear() + "年" + vo.getMonth() + "月" + "公积金明细";
+            AtomicReference<BigDecimal> totat1 = new AtomicReference<>(BigDecimal.ZERO);
+            AtomicReference<BigDecimal> totat2 = new AtomicReference<>(BigDecimal.ZERO);
+            AtomicReference<BigDecimal> totat3 = new AtomicReference<>(BigDecimal.ZERO);
+            list.forEach(item -> {
+                totat1.updateAndGet(v -> v .add(item.getCompanyAmount()));
+                totat2.updateAndGet(v -> v .add(item.getOneSelfAmount()));
+                totat3.updateAndGet(v -> v .add(item.getTotalAmount()));
+            });
+            map.put("titleName", titleName);
+            map.put("totat1", totat1.get());
+            map.put("totat2", totat2.get());
+            map.put("totat3", totat3.get());
+            excelWriter.fill(list, fillConfig, writeSheet);
+            excelWriter.fill(map, fillConfig, writeSheet);
+            excelWriter.finish();
+            bos.flush();
+
+        } catch (Exception e) {
+           e.printStackTrace();
+        }finally {
+            bos.close();
+        }
+
+    }
+
+    private List<EmployeeExcel> getList(HousingFundEmployeeVo vo, List<BizHousingFundConfirmDetailEmployee> employees, List<EmployeeExcel> employeeExcels) {
+        BizHousingFundConfirmDetail housingFundConfirmDetail = housingFundConfirmDetailService
+                .query().eq("company_id", vo.getCompanyId())
+                .eq("year", vo.getYear())
+                .eq("month", vo.getMonth())
+                .eq("deleted", 0).one();
+        if (housingFundConfirmDetail != null) {
+            employees = housingFundConfirmDetailEmployeeService.query()
+                    .eq("housing_fund_confirm_detail_id", housingFundConfirmDetail.getId())
+                    .eq("deleted", 0)
+                    .ne("change_status", 2)
+                    .list();
+        }
+        if (!CollectionUtils.isEmpty(employees)) {
+            for (int i = 0; i < employees.size(); i++) {
+                BizHousingFundConfirmDetailEmployee employee = employees.get(i);
+                //去掉百分比
+                BigDecimal ratio = employee.getRatio().divide(BigDecimal.valueOf(100)).setScale(2);
+                EmployeeExcel employeeExcel = new EmployeeExcel();
+                employeeExcel.setIndex(i + 1);
+                employeeExcel.setEmployeeName(employee.getEmployeeName());
+                employeeExcel.setCardinalNumber(employee.getCardinalNumber());
+                employeeExcel.setRatio(ratio);
+                employeeExcel.setCompanyAmount(employee.getCardinalNumber().multiply(ratio).setScale(2));
+                employeeExcel.setOneSelfAmount(employee.getCardinalNumber().multiply(ratio).setScale(2));
+                employeeExcel.setTotalAmount(employeeExcel.getCompanyAmount().add(employeeExcel.getOneSelfAmount()));
+                employeeExcels.add(employeeExcel);
+            }
+        }
+        return employeeExcels;
+    }
+
     @PostMapping("/saveBatch")
     @ApiOperation(value = "批量保存", notes = "批量保存")
     @ResponseBody
@@ -108,7 +208,7 @@ public class BizHousingFundDeclareController extends BaseController {
     @GetMapping("/list")
     @ResponseBody
     public TableDataInfo getList(BizHousingFundDeclare conditions) throws NoSuchFieldException, IllegalAccessException {
-       setTenantId(conditions);
+        setTenantId(conditions);
         startPage();
         startOrderBy();
         List<BizHousingFundDeclare> list = housingFundDeclareService.getListByBean(conditions);
@@ -170,9 +270,9 @@ public class BizHousingFundDeclareController extends BaseController {
         String formattedMonth = String.format("%02d", nowMonth);
         String year = condition.getYear();
         String month = condition.getMonth();
-        String s1= year+month;
-        String s2 = nowYear+ formattedMonth;
-        if(!s1.equals(s2) && housingFundDeclareDetails.isEmpty()){
+        String s1 = year + month;
+        String s2 = nowYear + formattedMonth;
+        if (!s1.equals(s2) && housingFundDeclareDetails.isEmpty()) {
             return error("当前月未找到数据");
         }
         if (housingFundDeclareDetails.isEmpty()) {
@@ -204,31 +304,30 @@ public class BizHousingFundDeclareController extends BaseController {
     @PreAuthorize("@ss.hasPermi('business:housingFundDeclare:export')")
     @Log(title = "公积金申报任务", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, BizHousingFundDeclare conditions) throws NoSuchFieldException, IllegalAccessException
-    {
+    public void export(HttpServletResponse response, BizHousingFundDeclare conditions) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(conditions);
         startOrderBy();
         List<BizHousingFundDeclare> list = housingFundDeclareService.getListByBean(conditions);
-        for (BizHousingFundDeclare l: list){
-            l.setCurrentPeriod(conditions.getYear()+"-"+conditions.getMonth());
+        for (BizHousingFundDeclare l : list) {
+            l.setCurrentPeriod(conditions.getYear() + "-" + conditions.getMonth());
             BizHousingFundDeclareDetail detail = new BizHousingFundDeclareDetail();
             detail.setHousingFundDeclareId(l.getId());
             detail.setYear(conditions.getYear());
             detail.setMonth(conditions.getMonth());
             List<BizHousingFundDeclareDetail> details = housingFundDeclareDetailService.getListByBean(detail);
-            if(details.size() == 0){
+            if (details.size() == 0) {
                 l.setStatusText("未开始");
                 l.setMakeOut("未填写");
-            }else{
-                detail=details.get(0);
+            } else {
+                detail = details.get(0);
                 List<BizWorkOrderRecord> records = bizWorkOrderRecordService.query().eq("work_order_id", l.getWorkOrderId()).eq("year", conditions.getYear()).eq("month", conditions.getMonth()).eq("from_id", 0).list();
-                if(records.size()>0){
+                if (records.size() > 0) {
                     SysUser sysUser = sysUserMapper.selectUserById(records.get(0).getRecorderId());
-                    l.setServiceName(sysUser==null?"":sysUser.getNickName());
-                }else{
+                    l.setServiceName(sysUser == null ? "" : sysUser.getNickName());
+                } else {
                     l.setServiceName("");
                 }
-                switch (detail.getStatus()){
+                switch (detail.getStatus()) {
                     case 0:
                         l.setStatusText("未开始");
                         l.setMakeOut("未填写");
@@ -315,6 +414,7 @@ public class BizHousingFundDeclareController extends BaseController {
         }
 
     }
+
     @ApiOperation("获取公积金人员信息")
     @PostMapping("/getMembersNoDelete")
     @ResponseBody
@@ -325,12 +425,19 @@ public class BizHousingFundDeclareController extends BaseController {
                     .eq("housing_fund_confirm_detail_id", housingFundConfirmDetail.getId())
                     .ne("change_status", 2)
                     .list();
+
+            for (BizHousingFundConfirmDetailEmployee employee : employees) {
+                employee.setCompanyAmount(employee.getRatio().divide(BigDecimal.valueOf(100)).multiply(employee.getCardinalNumber()));
+                employee.setOneSelfAmount(employee.getRatio().divide(BigDecimal.valueOf(100)).multiply(employee.getCardinalNumber()));
+                employee.setTotalAmount(employee.getCompanyAmount().add(employee.getOneSelfAmount()));
+            }
             return success(employees);
         } else {
             return success(new ArrayList<>());
         }
 
     }
+
     private Boolean checkDeduction(BizHousingFundDeclareDetail detail) {
         BizHousingFundDeclare main = housingFundDeclareService.getById(detail.getHousingFundDeclareId());
         if (detail.getAmount() != null && detail.getAmount().compareTo(BigDecimal.ZERO) > 0 && detail.getStatus().equals(3)) {

+ 6 - 0
src/main/java/cn/ezhizao/project/business/housingFund/domain/BizHousingFundConfirmDetailEmployee.java

@@ -61,6 +61,12 @@ public class BizHousingFundConfirmDetailEmployee extends BaseEntity implements S
     @ApiModelProperty(value = "备注")
     private String remark;
 
+    @TableField(exist = false)
+    private BigDecimal companyAmount;
+    @TableField(exist = false)
+    private BigDecimal oneSelfAmount;
+    @TableField(exist = false)
+    private BigDecimal totalAmount;
     public void setRemark(String remark)
     {
         this.remark = remark;

+ 16 - 0
src/main/java/cn/ezhizao/project/business/housingFund/domain/vo/EmployeeExcel.java

@@ -0,0 +1,16 @@
+package cn.ezhizao.project.business.housingFund.domain.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class EmployeeExcel {
+    private Integer index;
+    private String employeeName;
+    private BigDecimal cardinalNumber;
+    private BigDecimal ratio;
+    private BigDecimal companyAmount;
+    private BigDecimal oneSelfAmount;
+    private BigDecimal totalAmount;
+}

+ 15 - 0
src/main/java/cn/ezhizao/project/business/housingFund/domain/vo/HousingFundEmployeeVo.java

@@ -0,0 +1,15 @@
+package cn.ezhizao.project.business.housingFund.domain.vo;
+
+
+import lombok.Data;
+
+@Data
+public class HousingFundEmployeeVo {
+
+    private String companyId;
+
+    private String year;
+
+    private String month;
+
+}

+ 5 - 2
src/main/java/cn/ezhizao/project/business/socialSecurity/controller/SocialSecurityConfirmController.java

@@ -115,9 +115,12 @@ public class SocialSecurityConfirmController extends BaseController {
         if (socialSecurityConfirmDetails.isEmpty()) {
             // 获取上个月的工资人员信息
             // 先获取之前的一个月是否已填报,然后获取填报后的工资人员信息
-            BizSocialSecurityConfirmDetail detail = socialSecurityConfirmDetailService.query().eq("social_security_confirm_id", condition.getSocialSecurityConfirmId()).lt("concat(year,month)", condition.getYear() + condition.getMonth()).orderByDesc("concat(year, month)").last("limit 1").one();
+            BizSocialSecurityConfirmDetail detail = socialSecurityConfirmDetailService.query()
+                    .eq("social_security_confirm_id", condition.getSocialSecurityConfirmId()).lt("concat(year,month)", condition.getYear() + condition.getMonth()).orderByDesc("concat(year, month)").last("limit 1").one();
             if (detail != null) {
-                List<BizSocialSecurityConfirmDetailEmployee> employees = socialSecurityConfirmDetailEmployeeService.query().eq("social_security_confirm_detail_id", detail.getId()).list();
+                List<BizSocialSecurityConfirmDetailEmployee> employees = socialSecurityConfirmDetailEmployeeService.query()
+                        .eq("social_security_confirm_detail_id", detail.getId())
+                        .ne("change_status",2).list();
                 employees.forEach(l -> l.setId(null));
                 condition.setDetails(employees);
             } else {

+ 3 - 0
src/main/java/cn/ezhizao/project/business/workOrder/domain/BizWorkOrder.java

@@ -264,4 +264,7 @@ public class BizWorkOrder extends BaseEntity {
 
     @TableField(exist = false)
     private Integer recordStatus;
+
+    @TableField(exist = false)
+    private String accountName;
 }

BIN
src/main/resources/importTemplate/公积金模板.xlsx


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

@@ -32,7 +32,7 @@
         t3.name as task_type_name,
         t4.name as task_type_detail_name, t5.nick_name as
         service_name,t6.alter_type,t6.address_style,t6.fiction_address_id,t6.province as inputProvince,t6.city as
-        inputCity,t6.district as inputDistrict
+        inputCity,t6.district as inputDistrict,t10.account_name
         FROM biz_work_order t1
         left join biz_company t2 on t2.id = t1.company_id
         left join biz_task_type t3 on t3.id = t1.task_type_id
@@ -41,6 +41,8 @@
         LEFT JOIN biz_archive_input_detail t6 ON t6.id = t1.contract_detail_id
         left join biz_work_order_record t7 on t7.work_order_id = t1.id
         left join sys_user t8 on t7.handler_id = t8.user_id
+        left join biz_entrust t9 on t9.work_order_id = t1.id and t9.deleted = 0
+        left join biz_tenant t10 on t10.id = t9.to_tenant_id
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
             <if test="id != null ">AND t1.id = #{id}</if>