Commit afdeef55 authored by hongguangwu's avatar hongguangwu

个税申报——本期申报

parent 2ae2b6d9
......@@ -19,7 +19,10 @@ package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsCurrentReport;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsCurrentReportService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TStatisticsCurrentReportSearchVo;
......@@ -82,6 +85,25 @@ public class TStatisticsCurrentReportController {
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('salary_tstatisticscurrentreport-export')")
public void export(HttpServletResponse response, @RequestBody TStatisticsCurrentReportSearchVo searchVo) {
if (Common.isEmpty(searchVo.getDeclareMonth())) {
String nowMonth = DateUtil.addMonth(0); //本月
searchVo.setDeclareMonth(nowMonth);
}
tStatisticsCurrentReportService.listExport(response, searchVo);
}
/**
* @param
* @Description: 生成本期申报
* @Author: hgw
* @Date: 2022-8-19 17:03:20
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Inner
@Operation(description = "生成本期申报")
@PostMapping("/inner/doStatisticsCurrentReport")
public R<String> doStatisticsCurrentReport() {
return tStatisticsCurrentReportService.doStatisticsCurrentReportAuto();
}
}
......@@ -99,4 +99,19 @@ public class TStatisticsTaxSalaryController {
public void export(HttpServletResponse response, @RequestBody TStatisticsTaxSalarySearchVo searchVo) {
tStatisticsTaxSalaryService.listExport(response, searchVo);
}
/**
* @param settleMonth 结算月
* @Description: 手动刷新-年度报账+工资薪金+本期申报
* @Author: hgw
* @Date: 2022/2/22 16:23
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(description = "手动刷新-年度报账+工资薪金+本期申报(结算月:settleMonth必填)hasPermission('salary_tstatisticstaxsalary_refresh')")
@PostMapping("/doRefreshStatisticsTaxAll")
@PreAuthorize("@pms.hasPermission('salary_tstatisticstaxsalary_refresh')")
public R<String> doRefreshStatisticsTaxAll(@RequestParam String settleMonth) {
return tStatisticsTaxSalaryService.doRefreshStatisticsTaxAll(settleMonth);
}
}
......@@ -37,4 +37,9 @@ public interface TSalaryAccount2022Mapper extends BaseMapper<TSalaryAccount2022>
* @return
*/
IPage<TSalaryAccount2022> getTSalaryAccount2022Page(Page<TSalaryAccount2022> page, @Param("tSalaryAccount2022") TSalaryAccount2022 tSalaryAccount2022);
int deleteSalaryAccountYearByMonth(@Param("tableName") String tableName, @Param("lastMonth") String lastMonth);
int insertIntoSalaryAccountYear(@Param("tableName") String tableName, @Param("lastMonth") String lastMonth);
}
......@@ -37,4 +37,17 @@ public interface TStatisticsCurrentReportMapper extends BaseMapper<TStatisticsCu
* @return
*/
IPage<TStatisticsCurrentReport> getTStatisticsCurrentReportPage(Page<TStatisticsCurrentReport> page, @Param("tStatisticsCurrentReport") TStatisticsCurrentReport tStatisticsCurrentReport);
int insertStatisticsCurrentReport(@Param("nowMonth") String nowMonth
, @Param("lastMonth") String lastMonth, @Param("nowYear") String nowYear);
/**
* @param yearMonth
* @Description: 删除-按申报月份
* @Author: hgw
* @Date: 2020/6/16 15:19
* @return: int
**/
int deleteByYearMonth(@Param("yearMonth") String yearMonth);
}
......@@ -37,4 +37,16 @@ public interface TStatisticsTaxSalaryMapper extends BaseMapper<TStatisticsTaxSal
* @return
*/
IPage<TStatisticsTaxSalary> getTStatisticsTaxSalaryPage(Page<TStatisticsTaxSalary> page, @Param("tStatisticsTaxSalary") TStatisticsTaxSalary tStatisticsTaxSalary);
int insertStatisticsTaxSalaryByTableName(@Param("tableName") String tableName
, @Param("nowMonth") String nowMonth, @Param("lastYear") String lastYear);
/**
* @param yearMonth
* @Description: 删除-按申报月份
* @Author: hgw
* @Date: 2020/6/16 15:19
* @return: int
**/
int deleteByYearMonth(@Param("yearMonth") String yearMonth);
}
......@@ -37,4 +37,12 @@ public interface TStatisticsTaxSalaryRuleMapper extends BaseMapper<TStatisticsTa
* @return
*/
IPage<TStatisticsTaxSalaryRule> getTStatisticsTaxSalaryRulePage(Page<TStatisticsTaxSalaryRule> page, @Param("tStatisticsTaxSalaryRule") TStatisticsTaxSalaryRule tStatisticsTaxSalaryRule);
/**
* 单个查询
*
* @return
*/
TStatisticsTaxSalaryRule getTStatisticsTaxSalaryRule(@Param("yearMonthDay") String yearMonthDay);
}
......@@ -18,6 +18,7 @@
package com.yifu.cloud.plus.v1.yifu.salary.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount2022;
/**
......@@ -27,4 +28,12 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount2022;
* @date 2022-08-05 11:40:15
*/
public interface TSalaryAccount2022Service extends IService<TSalaryAccount2022> {
/**
* @param settleMonth
* @Description: 根据结算月手动刷新
* @Author: hgw
* @Date: 2022/2/23 10:02
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
R<String> doRefreshSalaryAccountByMonth(String tableName, String settleMonth);
}
......@@ -43,9 +43,47 @@ public interface TStatisticsCurrentReportService extends IService<TStatisticsCur
*/
IPage<TStatisticsCurrentReport> getTStatisticsCurrentReportPage(Page<TStatisticsCurrentReport> page, TStatisticsCurrentReportSearchVo tStatisticsCurrentReport);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
/**
* @Description: 导出
* @Author: hgw
* @Date: 2022/8/19 17:04
* @return: void
**/
void listExport(HttpServletResponse response, TStatisticsCurrentReportSearchVo searchVo);
void listExport(HttpServletResponse response, TStatisticsCurrentReportSearchVo searchVo);
/**
* @param
* @Description: 生成-本期申报
* @Author: hgw
* @Date: 2020-6-15 18:02:35
* @return: com.yifu.cloud.v1.common.core.util.R
**/
R<String> doStatisticsCurrentReport(int monthNums);
List<TStatisticsCurrentReport> noPageDiy(TStatisticsCurrentReportSearchVo searchVo);
/**
* @param
* @Description: 自动生成
* @Author: hgw
* @Date: 2022/2/21 17:53
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
R<String> doStatisticsCurrentReportAuto();
/**
* @param yearMonth
* @Description: 删除-按申报月份
* @Author: hgw
* @Date: 2020/6/16 15:17
* @return: int
**/
int deleteByYearMonth(String yearMonth);
/**
* @param settleMonth
* @Description: 按结算月刷新本期申报
* @Author: hgw
* @Date: 2022/2/23 15:10
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
R<String> doRefreshStatisticsCurrentReport(String settleMonth);
}
......@@ -27,4 +27,9 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsTaxSalaryRule;
* @date 2022-08-05 11:40:14
*/
public interface TStatisticsTaxSalaryRuleService extends IService<TStatisticsTaxSalaryRule> {
/**
* 查询
* @return
*/
TStatisticsTaxSalaryRule getTStatisticsTaxSalaryRule(String yearMonthDay);
}
......@@ -20,14 +20,11 @@ package com.yifu.cloud.plus.v1.yifu.salary.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsTaxSalary;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TStatisticsTaxSalarySearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
* 统计-工资薪金
......@@ -43,9 +40,15 @@ public interface TStatisticsTaxSalaryService extends IService<TStatisticsTaxSala
*/
IPage<TStatisticsTaxSalary> getTStatisticsTaxSalaryPage(Page<TStatisticsTaxSalary> page, TStatisticsTaxSalarySearchVo tStatisticsTaxSalary);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TStatisticsTaxSalarySearchVo searchVo);
List<TStatisticsTaxSalary> noPageDiy(TStatisticsTaxSalarySearchVo searchVo);
/**
* @param settleMonth 结算月
* @Description: 手动刷新-年度报账+工资薪金+本期申报
* @Author: hgw
* @Date: 2022/2/22 16:22
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
R<String> doRefreshStatisticsTaxAll(String settleMonth);
}
package com.yifu.cloud.plus.v1.yifu.salary.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsTaxSalary;
/**
* 统计-工资薪金-给定时任务调用
*
* @author hgw
* @date 2020-05-27 10:46:05
*/
public interface TStatisticsTaxSalaryTwoService extends IService<TStatisticsTaxSalary> {
/**
* @param tableName
* @param settleMonth
* @Description: 生成工资薪金
* @Author: hgw
* @Date: 2022/2/25 10:30
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
R<String> doStatisticsTaxSalary(String tableName, String settleMonth);
}
......@@ -17,6 +17,8 @@
package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount2022;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryAccount2022Mapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryAccount2022Service;
......@@ -33,4 +35,28 @@ import org.springframework.stereotype.Service;
@Service
public class TSalaryAccount2022ServiceImpl extends ServiceImpl<TSalaryAccount2022Mapper, TSalaryAccount2022> implements TSalaryAccount2022Service {
/**
* @param
* @Description: 生成工资报账主表2020
* @Author: hgw
* @Date: 2020/12/31 17:55
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public R<String> doRefreshSalaryAccountByMonth(String tableName, String settleMonth) {
if (Common.isEmpty(tableName)) {
tableName = "t_salary_account_" + settleMonth.substring(0, 4);
}
int firstDelete = baseMapper.deleteSalaryAccountYearByMonth(tableName, settleMonth);
if (firstDelete != -1) {
int firstCreate = baseMapper.insertIntoSalaryAccountYear(tableName, settleMonth);
if (firstCreate != -1) {
return R.ok("已生成【年度报账】!");
} else {
return R.failed("生成【年度报账】失败!");
}
} else {
return R.failed("删除【年度报账】失败!");
}
}
}
......@@ -132,8 +132,7 @@ public class TStatisticsCurrentReportServiceImpl extends ServiceImpl<TStatistics
}
}
@Override
public List<TStatisticsCurrentReport> noPageDiy(TStatisticsCurrentReportSearchVo searchVo) {
private List<TStatisticsCurrentReport> noPageDiy(TStatisticsCurrentReportSearchVo searchVo) {
LambdaQueryWrapper<TStatisticsCurrentReport> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
......@@ -160,83 +159,67 @@ public class TStatisticsCurrentReportServiceImpl extends ServiceImpl<TStatistics
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TStatisticsCurrentReportVo> util1 = new ExcelUtil<>(TStatisticsCurrentReportVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TStatisticsCurrentReportVo.class, new ReadListener<TStatisticsCurrentReportVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TStatisticsCurrentReportVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TStatisticsCurrentReportVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
public R<String> doStatisticsCurrentReportAuto() {
String firstMonth = DateUtil.addMonth(0); //本月
int firstDelete = baseMapper.deleteByYearMonth(firstMonth);
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTStatisticsCurrentReport(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
String secondMonth = DateUtil.addMonth(-1); //上月
int secondDelete = baseMapper.deleteByYearMonth(secondMonth);
if (firstDelete != -2 && secondDelete != -2) {
this.doStatisticsCurrentReport(0);
this.doStatisticsCurrentReport(-1);
return R.ok("已生成!");
} else {
return R.failed("删除失败!");
}
return R.ok(errorMessageList);
}
private void importTStatisticsCurrentReport(List<TStatisticsCurrentReportVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TStatisticsCurrentReportVo excel = excelVOList.get(i);
// 数据合法情况 TODO
@Override
public R<String> doStatisticsCurrentReport(int monthNums) {
String nowMonth = DateUtil.addMonth(monthNums); //本月
String nowYear = nowMonth.substring(0, 4); //年份
//关联减少的——回盘数据月份
String lastMonth = DateUtil.addMonth(monthNums - 1); //上上月(例:当前202007:工资薪金为1~6月数据,回盘数据应为5月)
baseMapper.insertStatisticsCurrentReport(nowMonth, lastMonth, nowYear);
return R.ok("已生成!");
}
@Override
public int deleteByYearMonth(String yearMonth) {
return baseMapper.deleteByYearMonth(yearMonth);
}
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
@Override
public R<String> doRefreshStatisticsCurrentReport(String settleMonth) {
int firstDelete = baseMapper.deleteByYearMonth(settleMonth);
if (firstDelete != -2) {
baseMapper.insertStatisticsCurrentReport(settleMonth, this.getMonthCur(settleMonth), settleMonth.substring(0, 4));
return R.ok("已生成完毕!");
} else {
return R.failed("删除本期申报失败!");
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TStatisticsCurrentReportVo excel) {
TStatisticsCurrentReport insert = new TStatisticsCurrentReport();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
* @param settleMonth
* @Description: 根据年月,获取上个月
* @Author: hgw
* @Date: 2022/3/4 17:05
* @return: java.lang.String
**/
private String getMonthCur(String settleMonth) {
String years = settleMonth.substring(0, 4);
String mons = settleMonth.substring(4, 6);
int lastMons = Integer.parseInt(mons) - 1;
String lastYearMonth;
if (lastMons == 0) {
lastYearMonth = (Integer.parseInt(years) - 1) + "12";
} else if (lastMons < 10) {
lastYearMonth = years + "0" + lastMons;
} else {
lastYearMonth = years + lastMons;
}
return lastYearMonth;
}
}
......@@ -32,4 +32,13 @@ import org.springframework.stereotype.Service;
@Log4j2
@Service
public class TStatisticsTaxSalaryRuleServiceImpl extends ServiceImpl<TStatisticsTaxSalaryRuleMapper, TStatisticsTaxSalaryRule> implements TStatisticsTaxSalaryRuleService {
/**
* 查询
*
* @return
*/
@Override
public TStatisticsTaxSalaryRule getTStatisticsTaxSalaryRule(String yearMonthDay) {
return baseMapper.getTStatisticsTaxSalaryRule(yearMonthDay);
}
}
......@@ -31,12 +31,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsTaxSalary;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsTaxSalaryRule;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TStatisticsTaxSalaryMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsTaxSalaryRuleService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsTaxSalaryService;
import com.yifu.cloud.plus.v1.yifu.salary.util.DoStatisticsTask;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TStatisticsTaxSalarySearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TStatisticsTaxSalaryVo;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
......@@ -44,6 +51,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -55,7 +63,14 @@ import java.util.List;
*/
@Log4j2
@Service
@AllArgsConstructor
public class TStatisticsTaxSalaryServiceImpl extends ServiceImpl<TStatisticsTaxSalaryMapper, TStatisticsTaxSalary> implements TStatisticsTaxSalaryService {
private final TStatisticsTaxSalaryRuleService tStatisticsTaxSalaryRuleService;
@Lazy
private final DoStatisticsTask doStatisticsTask;
/**
* 统计-工资薪金简单分页查询
*
......@@ -74,7 +89,7 @@ public class TStatisticsTaxSalaryServiceImpl extends ServiceImpl<TStatisticsTaxS
*/
@Override
public void listExport(HttpServletResponse response, TStatisticsTaxSalarySearchVo searchVo) {
String fileName = "不良记录批量导出" + DateUtil.getThisTime() + ".xlsx";
String fileName = "工资薪金批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TStatisticsTaxSalary> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
......@@ -85,7 +100,6 @@ public class TStatisticsTaxSalaryServiceImpl extends ServiceImpl<TStatisticsTaxS
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, TStatisticsTaxSalary.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
......@@ -132,8 +146,7 @@ public class TStatisticsTaxSalaryServiceImpl extends ServiceImpl<TStatisticsTaxS
}
}
@Override
public List<TStatisticsTaxSalary> noPageDiy(TStatisticsTaxSalarySearchVo searchVo) {
private List<TStatisticsTaxSalary> noPageDiy(TStatisticsTaxSalarySearchVo searchVo) {
LambdaQueryWrapper<TStatisticsTaxSalary> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
......@@ -159,84 +172,45 @@ public class TStatisticsTaxSalaryServiceImpl extends ServiceImpl<TStatisticsTaxS
return wrapper;
}
/**
* @param settleMonth 结算月
* @Description: 手动刷新-年度报账+工资薪金+本期申报
* @Author: hgw
* @Date: 2022/8/19 17:18
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TStatisticsTaxSalaryVo> util1 = new ExcelUtil<>(TStatisticsTaxSalaryVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TStatisticsTaxSalaryVo.class, new ReadListener<TStatisticsTaxSalaryVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TStatisticsTaxSalaryVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TStatisticsTaxSalaryVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
public R<String> doRefreshStatisticsTaxAll(String settleMonth) {
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTStatisticsTaxSalary(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("获取登录信息失败!请重新登录!");
}
return R.ok(errorMessageList);
}
private void importTStatisticsTaxSalary(List<TStatisticsTaxSalaryVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TStatisticsTaxSalaryVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
// 查询操作记录
String yearMonthDay = DateUtil.getCurrentDateString("yyyyMMdd");
TStatisticsTaxSalaryRule rules = tStatisticsTaxSalaryRuleService.getTStatisticsTaxSalaryRule(yearMonthDay);
if (rules != null) {
if (rules.getCanRefreshNums() == 0) {
return R.failed("当日刷新次数已达上限,请联系管理员,处理TStatisticsTaxSalaryRule表!");
} else if (rules.getCreateTime().isAfter(LocalDateTime.now().plusMinutes(-5L))) {
return R.failed(rules.getCreateTime() + "才刷新的,5分钟后可以刷新!");
}
rules.setCreateTime(LocalDateTime.now());
rules.setCanRefreshNums(rules.getCanRefreshNums() - 1);
tStatisticsTaxSalaryRuleService.updateById(rules);
} else {
rules = new TStatisticsTaxSalaryRule();
rules.setCanRefreshNums(10);
rules.setCreateTime(LocalDateTime.now());
rules.setCreateBy(String.valueOf(user.getId()));
rules.setSettleMonth(settleMonth);
rules.setYearMonthDay(yearMonthDay);
tStatisticsTaxSalaryRuleService.save(rules);
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TStatisticsTaxSalaryVo excel) {
TStatisticsTaxSalary insert = new TStatisticsTaxSalary();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
// 异步执行
doStatisticsTask.doRefreshCore(settleMonth);
return R.ok("正在生成中,请稍后查看!");
}
}
package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsTaxSalary;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TStatisticsTaxSalaryMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsTaxSalaryTwoService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 统计-工资薪金
*
* @author hgw
* @date 2020-05-27 10:46:05
*/
@AllArgsConstructor
@Slf4j
@Service("tStatisticsTaxSalaryTwoService")
public class TStatisticsTaxSalaryTwoServiceImpl extends ServiceImpl<TStatisticsTaxSalaryMapper, TStatisticsTaxSalary> implements TStatisticsTaxSalaryTwoService {
/**
* @param tableName
* @param settleMonth
* @Description: 刷新工资薪金
* @Author: hgw
* @Date: 2022/2/23 15:12
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public R<String> doStatisticsTaxSalary(String tableName, String settleMonth) {
int deletes = baseMapper.deleteByYearMonth(settleMonth);
if (deletes != -1) {
String settleYear = settleMonth.substring(0, 4);
baseMapper.insertStatisticsTaxSalaryByTableName(tableName, settleMonth, settleYear);
return R.ok("刷新工资薪金成功!");
}
return R.failed("刷新工资薪金失败!");
}
}
package com.yifu.cloud.plus.v1.yifu.salary.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryAccount2022Service;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsCurrentReportService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsTaxSalaryTwoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* 主要执行统计时长较长的方法
*
* @author hgw
* @Date 2022-2-25 10:32:37
* @Description 多线程的执行demo
*/
@Slf4j
@Component
public class DoStatisticsTask {
@Autowired
private TStatisticsTaxSalaryTwoService tStatisticsTaxSalaryTwoService;
@Autowired
private TSalaryAccount2022Service tSalaryAccount2020Service;
@Autowired
private TStatisticsCurrentReportService tStatisticsCurrentReportService;
/**
* @param settleMonth
* @Description: 核心刷新-年度报账、工资薪金、本期申报
* @Author: hgw
* @Date: 2022-2-25 10:29:28
* @return: void
**/
@Async
public void doRefreshCore(String settleMonth) {
String tableName = "t_salary_account_" + settleMonth.substring(0, 4);
// 刷新对应结算月的 年度报账
R<String> accountR = tSalaryAccount2020Service.doRefreshSalaryAccountByMonth(tableName, settleMonth);
if (accountR != null && accountR.getCode() == CommonConstants.SUCCESS) {
// 刷新对应结算月的 工资薪金
R<String> taxR = tStatisticsTaxSalaryTwoService.doStatisticsTaxSalary(tableName, settleMonth);
if (taxR.getCode() == CommonConstants.SUCCESS) {
// 刷新对应结算月的 本期申报
tStatisticsCurrentReportService.doRefreshStatisticsCurrentReport(settleMonth);
} else {
log.error(taxR.getMsg());
}
} else {
log.error(accountR == null ? "刷新对应结算月的 年度报账-失败!" : accountR.getMsg());
}
}
}
......@@ -484,14 +484,14 @@ public class SalaryAccountUtil implements Serializable {
}
emp = newEmp;
} else {
error = "第" + (i + 2) + "行:薪酬人员档案中,该客户下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!!";
error = "第" + (i + 2) + "行:薪酬人员查询处中,该客户下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
}
if (emp != null) {
if (Common.isEmpty(emp.getEmpName())) {
error = "第" + (i + 2) + "行:薪酬人员档案-员工姓名-为空,请去薪酬人员档案更新!";
error = "第" + (i + 2) + "行:薪酬人员查询处-员工姓名-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else if (Common.isEmpty(empName)) {
......@@ -499,16 +499,16 @@ public class SalaryAccountUtil implements Serializable {
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else if (!empName.equals(emp.getEmpName())) {
error = "第" + (i + 2) + "行:员工-姓名与身份证-不匹配,请确认薪酬人员档案信息!";
error = "第" + (i + 2) + "行:员工-姓名与身份证-不匹配,请确认薪酬人员查询处信息!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
if (Common.isEmpty(emp.getEmpPhone())) {
error = "第" + (i + 2) + "行:薪酬人员档案-手机号码-为空,请去档案更新!";
error = "第" + (i + 2) + "行:薪酬人员查询处-手机号码-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else if (!ValidityUtil.validateEmpPhone(emp.getEmpPhone())) {
error = "第" + (i + 2) + "行:薪酬人员档案-手机号码格式错误,请去档案更新:" + emp.getEmpPhone();
error = "第" + (i + 2) + "行:薪酬人员查询处-手机号码格式错误,请去薪酬人员查询处更新:" + emp.getEmpPhone();
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -529,7 +529,7 @@ public class SalaryAccountUtil implements Serializable {
emp.setTaxMonth(entity.getTaxMonth());
tSalaryEmployeeService.updateById(emp);
} else {
error = "第" + (i + 2) + "行:薪酬人员档案-计税月份-为空,请在工资模板填写-计税月份-列的内容!";
error = "第" + (i + 2) + "行:薪酬人员查询处-计税月份-为空,请在工资模板填写-计税月份-列的内容!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -552,12 +552,12 @@ public class SalaryAccountUtil implements Serializable {
entity.setEmpPhone(emp.getEmpPhone());
if (SalaryConstants.SALARY_STYLE_BANK.equals(salaryStyle) && salaryGiveTimeFlag) {
if (Common.isEmpty(emp.getBankName())) {
error = "第" + (i + 2) + "行:员工:" + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行-为空,请去档案更新!";
error = "第" + (i + 2) + "行:员工:" + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
if (Common.isEmpty(emp.getBankNo())) {
error = "第" + (i + 2) + "行:员工:" + emp.getEmpIdcard() + "-发放方式为银行发放,但是-银行卡号-为空,请去档案更新!";
error = "第" + (i + 2) + "行:员工:" + emp.getEmpIdcard() + "-发放方式为银行发放,但是-银行卡号-为空,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -579,14 +579,14 @@ public class SalaryAccountUtil implements Serializable {
if (emp.getTaxMonth().length() > CommonConstants.dingleDigitIntArray[6]) {
entity.setTaxMonth(emp.getTaxMonth().substring(0, 6));
} else if (emp.getTaxMonth().length() < CommonConstants.dingleDigitIntArray[6]) {
error = "第" + (i + 2) + "行:薪酬人员档案-计税月份-长度小于6:" + entity.getTaxMonth() + ",请去档案更新!在工资模板修改无效!";
error = "第" + (i + 2) + "行:薪酬人员查询处-计税月份-长度小于6:" + entity.getTaxMonth() + ",请去薪酬人员查询处更新!在工资模板修改无效!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
} else {
entity.setTaxMonth(emp.getTaxMonth());
}
if (DateUtil.compareYearMonth(entity.getTaxMonth(), nowMonth)) {
error = "第" + (i + 2) + "行:薪酬人员档案-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
error = "第" + (i + 2) + "行:薪酬人员查询处-计税月份-大于当前年月或错误,请调整:" + entity.getTaxMonth();
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......@@ -598,7 +598,7 @@ public class SalaryAccountUtil implements Serializable {
saiList.add(sai);
}
} else {
error = "第" + (i + 2) + "行:薪酬人员档案中,该客户下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!";
error = "第" + (i + 2) + "行:薪酬人员查询处中,该客户下无此员工,请添加<是否新员工(默认否)>列,并录入身份证号、开户行总行、开户行省、开户行市、银行卡号、计税月份、手机号码!";
errorList.add(new ErrorMessage((i + 2), error));
continue;
}
......
......@@ -201,4 +201,64 @@
<include refid="tSalaryAccount2022_where"/>
</where>
</select>
<delete id="deleteSalaryAccountYearByMonth" >
delete from ${tableName} where SETTLEMENT_MONTH = #{lastMonth};
</delete>
<!-- 插入2021表 -->
<insert id="insertIntoSalaryAccountYear">
insert into ${tableName} (
select
a.id,a.INVOICE_TITLE,a.EMP_ID,a.EMP_NAME,a.EMP_IDCARD,
a.SETTLE_DEPART_ID,a.SETTLE_DEPART_NO,a.SETTLE_DEPART_NAME,a.SETTLEMENT_MONTH,a.TAX_MONTH,
ifnull(sum(relaySalary.SALARY_MONEY),0) REAL_SALARY,
ifnull(max(costReduction.SALARY_MONEY),0) cost_reduction,
ifnull(max(specialDeduMoney.SALARY_MONEY),0) SPECIAL_DEDU_MONEY,
ifnull(max(sumChildEduMoney.SALARY_MONEY),0) child_eduInfo_money,
ifnull(max(sumHousingLoanMoney.SALARY_MONEY),0) housing_loan_Interest_expense_money,
ifnull(max(sumHousingRentMoney.SALARY_MONEY),0) housing_rentalInfo_money,
ifnull(max(sumContinuingEducationMoney.SALARY_MONEY),0) continuing_education_expense_money,
ifnull(max(sumSupportElderlyMoney.SALARY_MONEY),0) support_elderly_expense_money,
ifnull(sum(personalSocial.SALARY_MONEY),0) PERSONAL_SOCIAL,
ifnull(sum(personalFund.SALARY_MONEY),0) PERSONAL_FUND,
ifnull(sum(withholidingPersonSocial.SALARY_MONEY),0) withholiding_person_social,
ifnull(sum(withholidingPersonFund.SALARY_MONEY),0) withholiding_person_fund,
ifnull(sum(enterpriseAnnuity.SALARY_MONEY),0) enterprise_annuity,
ifnull(sum(salaryTax.SALARY_MONEY),0) salary_tax,
ifnull(sum(actualSalarySum.SALARY_MONEY),0) actual_salary_sum,
ifnull(sum(if(annualBonusTax.SALARY_MONEY > 0,annualBonus.SALARY_MONEY,0)),0) annual_bonus,
ifnull(sum(annualBonusTax.SALARY_MONEY),0) annual_bonus_tax,
ifnull(sum(exemptionPersionTax.SALARY_MONEY),0) exemption_persion_tax,
i.id unit_id,i.CUSTOMER_CODE unit_no,i.CUSTOMER_NAME unit_name,
ifnull(max(sumBabyMoney.SALARY_MONEY),0) sum_baby_money
from t_salary_account a
left join t_salary_standard s on s.id = a.SALARY_FORM_ID
left join hrms.t_settle_domain d on d.id = a.SETTLE_DEPART_ID
left join hrms.t_customer_info i on i.id = d.CUSTOMER_ID
left join t_salary_account_item relaySalary on relaySalary.SALARY_ACCOUNT_ID = a.id and relaySalary.JAVA_FIED_NAME='relaySalary'
left join t_salary_account_item exemptionPersionTax on exemptionPersionTax.SALARY_ACCOUNT_ID = a.id and exemptionPersionTax.JAVA_FIED_NAME='exemptionPersionTax'
left join t_salary_account_item costReduction on costReduction.SALARY_ACCOUNT_ID = a.id and costReduction.JAVA_FIED_NAME='costReduction'
left join t_salary_account_item sumChildEduMoney on sumChildEduMoney.SALARY_ACCOUNT_ID = a.id and sumChildEduMoney.JAVA_FIED_NAME='sumChildEduMoney'
left join t_salary_account_item sumHousingLoanMoney on sumHousingLoanMoney.SALARY_ACCOUNT_ID = a.id and sumHousingLoanMoney.JAVA_FIED_NAME='sumHousingLoanMoney'
left join t_salary_account_item sumHousingRentMoney on sumHousingRentMoney.SALARY_ACCOUNT_ID = a.id and sumHousingRentMoney.JAVA_FIED_NAME='sumHousingRentMoney'
left join t_salary_account_item sumSupportElderlyMoney on sumSupportElderlyMoney.SALARY_ACCOUNT_ID = a.id and sumSupportElderlyMoney.JAVA_FIED_NAME='sumSupportElderlyMoney'
left join t_salary_account_item sumContinuingEducationMoney on sumContinuingEducationMoney.SALARY_ACCOUNT_ID = a.id and sumContinuingEducationMoney.JAVA_FIED_NAME='sumContinuingEducationMoney'
left join t_salary_account_item sumBabyMoney on sumBabyMoney.SALARY_ACCOUNT_ID = a.id and sumBabyMoney.JAVA_FIED_NAME='sumBabyMoney'
left join t_salary_account_item personalSocial on personalSocial.SALARY_ACCOUNT_ID = a.id and personalSocial.JAVA_FIED_NAME='personalSocial'
left join t_salary_account_item personalFund on personalFund.SALARY_ACCOUNT_ID = a.id and personalFund.JAVA_FIED_NAME='personalFund'
left join t_salary_account_item withholidingPersonSocial on withholidingPersonSocial.SALARY_ACCOUNT_ID = a.id and withholidingPersonSocial.JAVA_FIED_NAME='withholidingPersonSocial'
left join t_salary_account_item withholidingPersonFund on withholidingPersonFund.SALARY_ACCOUNT_ID = a.id and withholidingPersonFund.JAVA_FIED_NAME='withholidingPersonFund'
left join t_salary_account_item actualSalarySum on actualSalarySum.SALARY_ACCOUNT_ID = a.id and actualSalarySum.JAVA_FIED_NAME='actualSalarySum'
left join t_salary_account_item salaryTax on salaryTax.SALARY_ACCOUNT_ID = a.id and salaryTax.JAVA_FIED_NAME='salaryTax'
left join t_salary_account_item specialDeduMoney on specialDeduMoney.SALARY_ACCOUNT_ID = a.id and specialDeduMoney.JAVA_FIED_NAME='specialDeduMoney'
left join t_salary_account_item enterpriseAnnuity on enterpriseAnnuity.SALARY_ACCOUNT_ID = a.id and enterpriseAnnuity.JAVA_FIED_NAME='enterpriseAnnuity'
left join t_salary_account_item annualBonusTax on annualBonusTax.SALARY_ACCOUNT_ID = a.id and annualBonusTax.JAVA_FIED_NAME='annualBonusTax'
left join t_salary_account_item annualBonus on annualBonus.SALARY_ACCOUNT_ID = a.id and annualBonus.JAVA_FIED_NAME='annualBonus'
where
a.SETTLEMENT_MONTH = #{lastMonth} and a.DELETE_FLAG = 0 and a.SALARY_TYPE != '7' and a.SALARY_TYPE != '3'
and s.DELETE_FLAG = 0
GROUP BY a.EMP_IDCARD,a.INVOICE_TITLE,a.SETTLEMENT_MONTH)
</insert>
</mapper>
......@@ -196,4 +196,65 @@
<include refid="tStatisticsCurrentReport_where"/>
</where>
</select>
<!-- 本期申报 -->
<insert id="insertStatisticsCurrentReport">
insert into t_statistics_current_report (
select
concat(s.id,#{nowMonth}) id,
s.INVOICE_TITLE,
s.SETTLE_DEPART_ID,
s.SETTLE_DEPART_NO,
s.SETTLE_DEPART_NAME,
s.DECLARE_MONTH,
s.EMP_ID,
if(s.EMP_NAME REGEXP '[0-9]',REPLACE(s.EMP_NAME,right(s.EMP_NAME,4),''),s.EMP_NAME) EMP_NAME,
s.EMP_IDCARD,
s.cost_reduction,
s.child_eduInfo_money,
s.housing_rentalInfo_money,
s.housing_loan_Interest_expense_money,
s.support_elderly_expense_money,
s.continuing_education_expense_money,
s.REAL_SALARY - ifnull(m.all_income,0) REAL_SALARY,
s.PERSONAL_PENSION_MONEY - ifnull(m.PERSONAL_PENSION_MONEY,0) PERSONAL_PENSION_MONEY,
s.PERSONAL_MEDICAL_MONEY - ifnull(m.PERSONAL_MEDICAL_MONEY,0) PERSONAL_MEDICAL_MONEY,
s.PERSONAL_UNEMPLOYMENT_MONEY - ifnull(m.PERSONAL_UNEMPLOYMENT_MONEY,0) PERSONAL_UNEMPLOYMENT_MONEY,
s.PERSONAL_SOCIAL,
s.PERSONAL_FUND - ifnull(m.PERSONAL_PROVIDENT_FEE,0) PERSONAL_PROVIDENT_FEE,
s.enterprise_annuity - ifnull(m.enterprise_annuity,0) enterprise_annuity,
s.taxable,
s.tax_fee,
s.QUICK_DEDUCATION,
s.salary_tax - ifnull(m.all_tax_prepaid,0) - ifnull(m.all_tax_payable,0) salary_tax,
s.UNIT_ID,
s.UNIT_NO,
s.UNIT_NAME,
s.SPECIAL_DEDU_MONEY,
s.sum_baby_money
from t_statistics_tax_salary s
left join
(
select m.INVOICE_TITLE,m.EMP_IDCARD,
sum(ifnull(m.PERSONAL_PENSION_MONEY,0)) PERSONAL_PENSION_MONEY,
sum(ifnull(m.PERSONAL_MEDICAL_MONEY,0)) PERSONAL_MEDICAL_MONEY,
sum(ifnull(m.PERSONAL_UNEMPLOYMENT_MONEY,0)) PERSONAL_UNEMPLOYMENT_MONEY,
sum(ifnull(m.PERSONAL_PROVIDENT_FEE,0)) PERSONAL_PROVIDENT_FEE,
sum(ifnull(m.enterprise_annuity,0)) enterprise_annuity,
sum(if(m.declare_MONTH = #{lastMonth},all_income,0)) all_income,
sum(if(m.declare_MONTH = #{lastMonth},all_tax_prepaid,0)) all_tax_prepaid,
sum(if(m.declare_MONTH = #{lastMonth},all_tax_payable,0)) all_tax_payable
from t_statistics_current_report_market m
where m.declare_MONTH <![CDATA[<=]]> #{lastMonth} and m.declare_MONTH like '${nowYear}%'
GROUP BY m.EMP_IDCARD,m.INVOICE_TITLE
) m on m.EMP_IDCARD=s.EMP_IDCARD and m.INVOICE_TITLE = s.INVOICE_TITLE
where s.DECLARE_MONTH = #{nowMonth}
)
</insert>
<!-- 删除-按申报月份 -->
<delete id="deleteByYearMonth">
DELETE FROM t_statistics_current_report WHERE DECLARE_MONTH = #{yearMonth}
</delete>
</mapper>
......@@ -196,4 +196,66 @@
<include refid="tStatisticsTaxSalary_where"/>
</where>
</select>
<insert id="insertStatisticsTaxSalaryByTableName">
insert into t_statistics_tax_salary (
select
a.id,a.INVOICE_TITLE,a.SETTLE_DEPART_ID,a.SETTLE_DEPART_NO,a.SETTLE_DEPART_NAME
,a.DECLARE_MONTH,a.EMP_ID,a.EMP_NAME,a.EMP_IDCARD,a.cost_reduction
,a.child_eduInfo_money,a.housing_rentalInfo_money,a.housing_loan_Interest_expense_money
,a.support_elderly_expense_money,a.continuing_education_expense_money
,a.REAL_SALARY,a.PERSONAL_PENSION_MONEY,a.PERSONAL_MEDICAL_MONEY,a.PERSONAL_UNEMPLOYMENT_MONEY
,a.PERSONAL_SOCIAL,a.PERSONAL_FUND,a.enterprise_annuity,a.taxable,ifnull(c.WITHHOLDING_RATE,0) tax_fee
,ifnull(c.QUICK_DEDUCATION,0) QUICK_DEDUCATION,a.salary_tax,a.unit_id,a.unit_no,a.unit_name,a.SPECIAL_DEDU_MONEY
,a.sum_baby_money
from (
SELECT
concat(a.id,#{nowMonth}) id,
#{nowMonth} DECLARE_MONTH,
a.INVOICE_TITLE,
a.EMP_ID,
a.EMP_NAME,
a.EMP_IDCARD,
a.SETTLE_DEPART_ID,
a.SETTLE_DEPART_NO,
a.SETTLE_DEPART_NAME,
sum(a.REAL_SALARY) - sum(a.exemption_persion_tax) - sum(if(a.annual_bonus_tax > 0,a.annual_bonus,0)) REAL_SALARY,
max(a.cost_reduction) cost_reduction,
max(a.SPECIAL_DEDU_MONEY) SPECIAL_DEDU_MONEY,
max(a.child_eduInfo_money) child_eduInfo_money,
max(a.housing_loan_Interest_expense_money) housing_loan_Interest_expense_money,
max(a.housing_rentalInfo_money) housing_rentalInfo_money,
max(a.continuing_education_expense_money) continuing_education_expense_money,
max(a.support_elderly_expense_money) support_elderly_expense_money,
max(a.sum_baby_money) sum_baby_money,
sum(a.PERSONAL_SOCIAL) + sum(a.withholiding_person_social) PERSONAL_SOCIAL,
round(((sum(a.PERSONAL_SOCIAL) + sum(a.withholiding_person_social)) * 0.75),2) PERSONAL_PENSION_MONEY,
round(((sum(a.PERSONAL_SOCIAL) + sum(a.withholiding_person_social)) * 0.2),2) PERSONAL_MEDICAL_MONEY,
round(((sum(a.PERSONAL_SOCIAL) + sum(a.withholiding_person_social)) * 0.05),2) PERSONAL_UNEMPLOYMENT_MONEY,
sum(a.PERSONAL_FUND) + sum(a.withholiding_person_fund) PERSONAL_FUND,
sum(a.REAL_SALARY) - sum(a.exemption_persion_tax)
- max(a.SPECIAL_DEDU_MONEY)
- sum(a.PERSONAL_SOCIAL) - sum(a.withholiding_person_social)
- sum(a.PERSONAL_FUND) - sum(a.withholiding_person_fund)
- max(a.cost_reduction)
- sum(a.enterprise_annuity)
- sum(if(a.annual_bonus_tax > 0,a.annual_bonus,0)) taxable,
sum(a.salary_tax) salary_tax,
sum(a.enterprise_annuity) enterprise_annuity,
a.unit_id,
a.unit_no,
a.unit_name
FROM ${tableName} a
where a.SETTLEMENT_MONTH <![CDATA[ <= ]]> #{nowMonth} and a.SETTLEMENT_MONTH like concat(#{lastYear},'%')
GROUP BY a.EMP_IDCARD,a.INVOICE_TITLE ORDER BY a.settle_depart_id asc
) a
left join t_salary_tax_config c on c.MIN_INCOME <![CDATA[ < ]]> a.taxable and c.MAX_INCOME >= a.taxable and c.TYPE=0
)
</insert>
<!-- 删除-按申报月份 -->
<delete id="deleteByYearMonth">
DELETE FROM t_statistics_tax_salary WHERE DECLARE_MONTH = #{yearMonth}
</delete>
</mapper>
......@@ -71,4 +71,14 @@
<include refid="tStatisticsTaxSalaryRule_where"/>
</where>
</select>
<!--list-->
<select id="getTStatisticsTaxSalaryRule" resultMap="tStatisticsTaxSalaryRuleMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_statistics_tax_salary_rule a
where a.year_month_day = #{yearMonthDay}
limit 1
</select>
</mapper>
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