Commit e65cbef4 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/develop' into develop

parents 50bf9e2c bd70cb0b
......@@ -165,6 +165,13 @@ public class TSalaryStandard extends BaseEntity {
@ExcelAttribute(name = "最终审核时间", isDate = true)
@ExcelProperty("最终审核时间")
private Date auditTime;
/**
* 审核意见
*/
@ExcelAttribute(name = "审核意见", maxLength = 500)
@Length(max = 500, message = "审核意见不能超过500个字符")
@ExcelProperty("审核意见")
private String auditRemark;
/**
* 省
*/
......
......@@ -16,11 +16,13 @@
*/
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsCurrentReportMarket;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Set;
/**
* 统计-本期申报-回盘数据
......@@ -37,6 +39,10 @@ public class TStatisticsCurrentReportMarketSearchVo extends TStatisticsCurrentRe
@Schema(description = "选中ID,多个逗号分割")
private String ids;
@TableField(exist = false)
@Schema(description = "导出的表头的Set")
private Set<String> exportFields;
/**
* 创建时间区间 [开始时间,结束时间]
*/
......
......@@ -17,8 +17,6 @@
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema;
......@@ -38,57 +36,16 @@ import java.math.BigDecimal;
@Data
public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@NotBlank(message = "id 不能为空")
@Length(max = 32, message = "id 不能超过32 个字符")
@ExcelAttribute(name = "id", isNotEmpty = true, errorInfo = "id 不能为空", maxLength = 32)
@Schema(description = "id")
@ExcelProperty("id")
private String id;
/**
* 税务主体(封面抬头)
*/
@Length(max = 50, message = "税务主体(封面抬头) 不能超过50 个字符")
@ExcelAttribute(name = "税务主体(封面抬头)", maxLength = 50)
@Schema(description = "税务主体(封面抬头)")
@ExcelProperty("税务主体(封面抬头)")
@NotBlank(message = "封面抬头全称不能为空")
@Length(max = 50, message = "封面抬头全称 不能超过50 个字符")
@ExcelAttribute(name = "封面抬头全称", maxLength = 50, isNotEmpty = true, errorInfo = "封面抬头全称不能为空")
@Schema(description = "封面抬头全称")
@ExcelProperty("封面抬头全称")
private String invoiceTitle;
/**
* 结算部门id
*/
@Length(max = 32, message = "结算部门id 不能超过32 个字符")
@ExcelAttribute(name = "结算部门id", maxLength = 32)
@Schema(description = "结算部门id")
@ExcelProperty("结算部门id")
private String settleDepartId;
/**
* 结算部门no
*/
@Length(max = 50, message = "结算部门no 不能超过50 个字符")
@ExcelAttribute(name = "结算部门no", maxLength = 50)
@Schema(description = "结算部门no")
@ExcelProperty("结算部门no")
private String settleDepartNo;
/**
* 结算部门name
*/
@Length(max = 50, message = "结算部门name 不能超过50 个字符")
@ExcelAttribute(name = "结算部门name", maxLength = 50)
@Schema(description = "结算部门name")
@ExcelProperty("结算部门name")
private String settleDepartName;
/**
* 申报月份(YYYYMM)
*/
@NotBlank(message = "申报月份(YYYYMM) 不能为空")
@Length(max = 6, message = "申报月份(YYYYMM) 不能超过6 个字符")
@ExcelAttribute(name = "申报月份(YYYYMM)", isNotEmpty = true, errorInfo = "申报月份(YYYYMM) 不能为空", maxLength = 6)
@Schema(description = "申报月份(YYYYMM)")
@ExcelProperty("申报月份(YYYYMM)")
private String declareMonth;
/**
* 姓名
*/
......@@ -98,20 +55,20 @@ public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serial
@ExcelProperty("姓名")
private String empName;
/**
* 证类型
* 证类型
*/
@Length(max = 32, message = "证照类型 不能超过32 个字符")
@ExcelAttribute(name = "证类型", maxLength = 32)
@Schema(description = "证类型")
@ExcelProperty("证类型")
@Length(max = 32, message = "证件类型不能超过32 个字符")
@ExcelAttribute(name = "证类型", maxLength = 32)
@Schema(description = "证类型")
@ExcelProperty("证类型")
private String empIdcardType;
/**
* 身份证号
*/
@Length(max = 25, message = "身份证号 不能超过25 个字符")
@ExcelAttribute(name = "身份证号", maxLength = 25)
@Schema(description = "身份证号")
@ExcelProperty("身份证号")
@Length(max = 25, message = "证照号码 不能超过25 个字符")
@ExcelAttribute(name = "证照号码", maxLength = 25)
@Schema(description = "证照号码")
@ExcelProperty("证照号码")
private String empIdcard;
/**
* 税款所属期起
......@@ -159,103 +116,40 @@ public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serial
@ExcelProperty("本期免税收入")
private BigDecimal currentTaxFreeIncome;
/**
* 累计减除费用
* 本期基本养老保险费
*/
@ExcelAttribute(name = "累计减除费用")
@Schema(description = "累计减除费用")
@ExcelProperty("累计减除费用")
private BigDecimal costReduction;
/**
* 累计专项扣除
*/
@ExcelAttribute(name = "累计专项扣除")
@Schema(description = "累计专项扣除")
@ExcelProperty("累计专项扣除")
private BigDecimal specialDeduction;
/**
* 累计子女教育
*/
@ExcelAttribute(name = "累计子女教育")
@Schema(description = "累计子女教育")
@ExcelProperty("累计子女教育")
private BigDecimal childEduinfoMoney;
/**
* 累计住房租金
*/
@ExcelAttribute(name = "累计住房租金")
@Schema(description = "累计住房租金")
@ExcelProperty("累计住房租金")
private BigDecimal housingRentalinfoMoney;
/**
* 累计住房贷款
*/
@ExcelAttribute(name = "累计住房贷款")
@Schema(description = "累计住房贷款")
@ExcelProperty("累计住房贷款")
private BigDecimal housingLoanInterestExpenseMoney;
/**
* 累计赡养老人
*/
@ExcelAttribute(name = "累计赡养老人")
@Schema(description = "累计赡养老人")
@ExcelProperty("累计赡养老人")
private BigDecimal supportElderlyExpenseMoney;
/**
* 累计继续教育
*/
@ExcelAttribute(name = "累计继续教育")
@Schema(description = "累计继续教育")
@ExcelProperty("累计继续教育")
private BigDecimal continuingEducationExpenseMoney;
/**
* 本期基本养老
*/
@ExcelAttribute(name = "本期基本养老")
@Schema(description = "本期基本养老")
@ExcelProperty("本期基本养老")
@ExcelAttribute(name = "本期基本养老保险费")
@Schema(description = "本期基本养老保险费")
@ExcelProperty("本期基本养老保险费")
private BigDecimal personalPensionMoney;
/**
* 本期基本医疗
*/
@ExcelAttribute(name = "本期基本医疗")
@Schema(description = "本期基本医疗")
@ExcelProperty("本期基本医疗")
@ExcelAttribute(name = "本期基本医疗保险费")
@Schema(description = "本期基本医疗保险费")
@ExcelProperty("本期基本医疗保险费")
private BigDecimal personalMedicalMoney;
/**
* 本期失业
*/
@ExcelAttribute(name = "本期失业")
@Schema(description = "本期失业")
@ExcelProperty("本期失业")
@ExcelAttribute(name = "本期失业保险费")
@Schema(description = "本期失业保险费")
@ExcelProperty("本期失业保险费")
private BigDecimal personalUnemploymentMoney;
/**
* 个人大病金额
* 本期住房公积金
*/
@ExcelAttribute(name = "个人大病金额")
@Schema(description = "个人大病金额")
@ExcelProperty("个人大病金额")
private BigDecimal personalBigmailmentMoney;
/**
* 累计住房公积金
*/
@ExcelAttribute(name = "累计住房公积金")
@Schema(description = "累计住房公积金")
@ExcelProperty("累计住房公积金")
@ExcelAttribute(name = "本期住房公积金")
@Schema(description = "本期住房公积金")
@ExcelProperty("本期住房公积金")
private BigDecimal personalProvidentFee;
/**
* 累计企业年金
* 本期企业(职业)年金
*/
@ExcelAttribute(name = "累计企业年金")
@Schema(description = "累计企业年金")
@ExcelProperty("累计企业年金")
@ExcelAttribute(name = "本期企业(职业)年金")
@Schema(description = "本期企业(职业)年金")
@ExcelProperty("本期企业(职业)年金")
private BigDecimal enterpriseAnnuity;
/**
* 累计应纳税所得
*/
@ExcelAttribute(name = "累计应纳税所得")
@Schema(description = "累计应纳税所得")
@ExcelProperty("累计应纳税所得")
private BigDecimal taxable;
/**
* 本期商业健康保险费
*/
......@@ -284,6 +178,62 @@ public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serial
@Schema(description = "累计收入额")
@ExcelProperty("累计收入额")
private BigDecimal allIncome;
/**
* 累计减除费用
*/
@ExcelAttribute(name = "累计减除费用")
@Schema(description = "累计减除费用")
@ExcelProperty("累计减除费用")
private BigDecimal costReduction;
/**
* 累计专项扣除
*/
@ExcelAttribute(name = "累计专项扣除")
@Schema(description = "累计专项扣除")
@ExcelProperty("累计专项扣除")
private BigDecimal specialDeduction;
/**
* 累计子女教育支出扣除
*/
@ExcelAttribute(name = "累计子女教育支出扣除")
@Schema(description = "累计子女教育支出扣除")
@ExcelProperty("累计子女教育支出扣除")
private BigDecimal childEduinfoMoney;
/**
* 累计继续教育支出扣除
*/
@ExcelAttribute(name = "累计继续教育支出扣除")
@Schema(description = "累计继续教育支出扣除")
@ExcelProperty("累计继续教育支出扣除")
private BigDecimal continuingEducationExpenseMoney;
/**
* 累计住房贷款利息支出扣除
*/
@ExcelAttribute(name = "累计住房贷款利息支出扣除")
@Schema(description = "累计住房贷款利息支出扣除")
@ExcelProperty("累计住房贷款利息支出扣除")
private BigDecimal housingLoanInterestExpenseMoney;
/**
* 累计住房租金支出扣除
*/
@ExcelAttribute(name = "累计住房租金支出扣除")
@Schema(description = "累计住房租金支出扣除")
@ExcelProperty("累计住房租金支出扣除")
private BigDecimal housingRentalinfoMoney;
/**
* 累计赡养老人支出扣除
*/
@ExcelAttribute(name = "累计赡养老人支出扣除")
@Schema(description = "累计赡养老人支出扣除")
@ExcelProperty("累计赡养老人支出扣除")
private BigDecimal supportElderlyExpenseMoney;
/**
* 累计3岁以下婴幼儿照护
*/
@ExcelAttribute(name = "累计3岁以下婴幼儿照护")
@Schema(description = "累计3岁以下婴幼儿照护")
@ExcelProperty("累计3岁以下婴幼儿照护")
private BigDecimal sumBabyMoney;
/**
* 累计其他扣除
*/
......@@ -298,6 +248,13 @@ public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serial
@Schema(description = "累计准予扣除的捐赠")
@ExcelProperty("累计准予扣除的捐赠")
private BigDecimal allDonate;
/**
* 累计应纳税所得额
*/
@ExcelAttribute(name = "累计应纳税所得额")
@Schema(description = "累计应纳税所得额")
@ExcelProperty("累计应纳税所得额")
private BigDecimal taxable;
/**
* 税率
*/
......@@ -306,11 +263,11 @@ public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serial
@ExcelProperty("税率")
private BigDecimal taxFee;
/**
* 速算扣除
* 速算扣除
*/
@ExcelAttribute(name = "速算扣除")
@Schema(description = "速算扣除")
@ExcelProperty("速算扣除")
@ExcelAttribute(name = "速算扣除")
@Schema(description = "速算扣除")
@ExcelProperty("速算扣除")
private BigDecimal quickDeducation;
/**
* 累计应纳税额
......@@ -355,36 +312,5 @@ public class TStatisticsCurrentReportMarketVo extends RowIndex implements Serial
@Schema(description = "备注")
@ExcelProperty("备注")
private String remark;
/**
* 单位id
*/
@Length(max = 32, message = "单位id 不能超过32 个字符")
@ExcelAttribute(name = "单位id", maxLength = 32)
@Schema(description = "单位id")
@ExcelProperty("单位id")
private String unitId;
/**
* 单位no
*/
@Length(max = 50, message = "单位no 不能超过50 个字符")
@ExcelAttribute(name = "单位no", maxLength = 50)
@Schema(description = "单位no")
@ExcelProperty("单位no")
private String unitNo;
/**
* 单位name
*/
@Length(max = 50, message = "单位name 不能超过50 个字符")
@ExcelAttribute(name = "单位name", maxLength = 50)
@Schema(description = "单位name")
@ExcelProperty("单位name")
private String unitName;
/**
* 累计婴幼儿照护费用
*/
@ExcelAttribute(name = "累计婴幼儿照护费用")
@Schema(description = "累计婴幼儿照护费用")
@ExcelProperty("累计婴幼儿照护费用")
private BigDecimal sumBabyMoney;
}
......@@ -83,14 +83,32 @@ public class TStatisticsCurrentReportMarketController {
* @param id id
* @return R
*/
@Operation(summary = "通过id删除统计-本期申报-回盘数据", description = "通过id删除统计-本期申报-回盘数据:hasPermission('salary_tstatisticscurrentreportmarket_del')")
@Operation(summary = "通过id删除统计-本期申报-回盘数据", description = "通过id删除统计-本期申报-回盘数据:hasPermission('salary_report_market_del')")
@SysLog("通过id删除统计-本期申报-回盘数据")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('salary_tstatisticscurrentreportmarket_del')")
@PreAuthorize("@pms.hasPermission('salary_report_market_del')")
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tStatisticsCurrentReportMarketService.removeById(id));
}
/**
* @param yearMonth 年月
* @return R
*/
@Operation(summary = "删除-按申报月份", description = "通过id删除统计-本期申报-回盘数据:hasPermission('salary_report_market_doDeleteByDeclareMonth')")
@SysLog("删除-按申报月份")
@PostMapping("/doDeleteByDeclareMonth")
@PreAuthorize("@pms.hasPermission('salary_report_market_doDeleteByDeclareMonth')")
public R<String> doDeleteByDeclareMonth(@RequestParam String yearMonth) {
int num = tStatisticsCurrentReportMarketService.deleteByYearMonth(yearMonth);
if (num == 0) {
return R.failed("当前条件查询无数据,未删除");
} else {
return R.ok("已删除" + num + "条数据");
}
}
/**
* 统计-本期申报-回盘数据 批量导入
*
......@@ -98,24 +116,12 @@ public class TStatisticsCurrentReportMarketController {
* @date 2022-08-05 11:40:14
**/
@SneakyThrows
@Operation(description = "批量新增统计-本期申报-回盘数据 hasPermission('salary_tstatisticscurrentreportmarket-batch-import')")
@SysLog("批量新增统计-本期申报-回盘数据")
@Operation(description = "批量导入-回盘数据 hasPermission('salary_report_market-batch-import')")
@SysLog("批量导入-回盘数据")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('salary_tstatisticscurrentreportmarket-batch-import')")
@PreAuthorize("@pms.hasPermission('salary_report_market-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tStatisticsCurrentReportMarketService.importDiy(file.getInputStream());
}
/**
* 统计-本期申报-回盘数据 批量导出
*
* @author hgw
* @date 2022-08-05 11:40:14
**/
@Operation(description = "导出统计-本期申报-回盘数据 hasPermission('salary_tstatisticscurrentreportmarket-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('salary_tstatisticscurrentreportmarket-export')")
public void export(HttpServletResponse response, @RequestBody TStatisticsCurrentReportMarketSearchVo searchVo) {
tStatisticsCurrentReportMarketService.listExport(response, searchVo);
}
}
......@@ -36,5 +36,25 @@ public interface TStatisticsCurrentReportMarketMapper extends BaseMapper<TStatis
* @param tStatisticsCurrentReportMarket 统计-本期申报-回盘数据
* @return
*/
IPage<TStatisticsCurrentReportMarket> getTStatisticsCurrentReportMarketPage(Page<TStatisticsCurrentReportMarket> page, @Param("tStatisticsCurrentReportMarket") TStatisticsCurrentReportMarket tStatisticsCurrentReportMarket);
IPage<TStatisticsCurrentReportMarket> getTStatisticsCurrentReportMarketPage(Page<TStatisticsCurrentReportMarket> page
, @Param("tStatisticsCurrentReportMarket") TStatisticsCurrentReportMarket tStatisticsCurrentReportMarket);
/**
* @param yearMonth
* @Description: 删除-按申报月份
* @Author: hgw
* @Date: 2020/6/16 15:19
* @return: int
**/
int deleteByYearMonth(@Param("yearMonth") String yearMonth);
/**
* @param declareMonth
* @param declareTitle
* @Description: 查重
* @Author: hgw
* @Date: 2022/8/18 16:05
* @return: int
**/
int getCountByMonthAndTitle(@Param("declareMonth") String declareMonth, @Param("declareTitle") String declareTitle);
}
......@@ -45,7 +45,15 @@ public interface TStatisticsCurrentReportMarketService extends IService<TStatist
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TStatisticsCurrentReportMarketSearchVo searchVo);
List<TStatisticsCurrentReportMarket> noPageDiy(TStatisticsCurrentReportMarketSearchVo searchVo);
/**
* @param yearMonth 申报月份
* @Description: 删除-按申报月份
* @Author: hgw
* @Date: 2020/6/16 15:17
* @return: int
**/
int deleteByYearMonth(String yearMonth);
}
......@@ -269,7 +269,7 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
tApprovalRecord.setApprovalResult(CommonConstants.ONE_STRING);
}
if (Common.isNotNull(auditRemark)) {
tSalaryStandard.setRemark(auditRemark);
tSalaryStandard.setAuditRemark(auditRemark);
tApprovalRecord.setApprovalOpinion(auditRemark);
}
tSalaryStandard.setAuditUser(user.getId());
......@@ -280,6 +280,7 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
tApprovalRecord.setApprovalMan(user.getId());
tApprovalRecord.setApprovalManName(user.getNickname());
tApprovalRecord.setApprovalTime(DateUtil.getCurrentDateTime());
tApprovalRecord.setNodeId("审核");
approvalRecordService.save(tApprovalRecord);
}
return R.ok();
......
......@@ -18,13 +18,12 @@ package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -39,11 +38,7 @@ import com.yifu.cloud.plus.v1.yifu.salary.vo.TStatisticsCurrentReportMarketVo;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
......@@ -67,71 +62,6 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
return baseMapper.getTStatisticsCurrentReportMarketPage(page, tStatisticsCurrentReportMarket);
}
/**
* 统计-本期申报-回盘数据批量导出
*
* @return
*/
@Override
public void listExport(HttpServletResponse response, TStatisticsCurrentReportMarketSearchVo searchVo) {
String fileName = "不良记录批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TStatisticsCurrentReportMarket> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
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, TStatisticsCurrentReportMarket.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)) {
ExcelUtil<TStatisticsCurrentReportMarket> util = new ExcelUtil<>(TStatisticsCurrentReportMarket.class);
for (TStatisticsCurrentReportMarket vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("统计-本期申报-回盘数据" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) {
list.clear();
}
}
} else {
WriteSheet writeSheet = EasyExcel.writerSheet("统计-本期申报-回盘数据" + index).build();
excelWriter.write(list, writeSheet);
}
if (Common.isNotNull(list)) {
list.clear();
}
out.flush();
excelWriter.finish();
} catch (Exception e) {
log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public List<TStatisticsCurrentReportMarket> noPageDiy(TStatisticsCurrentReportMarketSearchVo searchVo) {
LambdaQueryWrapper<TStatisticsCurrentReportMarket> wrapper = buildQueryWrapper(searchVo);
......@@ -145,15 +75,6 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(TStatisticsCurrentReportMarketSearchVo searchVo) {
LambdaQueryWrapper<TStatisticsCurrentReportMarket> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TStatisticsCurrentReportMarket::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TStatisticsCurrentReportMarketSearchVo entity) {
LambdaQueryWrapper<TStatisticsCurrentReportMarket> wrapper = Wrappers.lambdaQuery();
return wrapper;
......@@ -163,7 +84,6 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TStatisticsCurrentReportMarketVo> util1 = new ExcelUtil<>(TStatisticsCurrentReportMarketVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
......@@ -173,6 +93,9 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
// 申报月份
String declareMonth;
String declareTitle;
/**
*临时存储
*/
......@@ -190,7 +113,36 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
if (Common.isEmpty(declareMonth)) {
if (Common.isNotNull(cachedDataList.get(0).getCreateStart())) {
declareMonth = DateUtil.getYearMonth(cachedDataList.get(0).getCreateStart());
}
if (Common.isEmpty(declareMonth)) {
errorMessageList.add(new ErrorMessage(CommonConstants.ZERO_INT
, "请检查‘税款所属期起’单元格格式是文本格式,且满足日期格式yyyy-MM-dd或yyyyMMdd:CreateStart="
+ cachedDataList.get(0).getCreateStart() + "|| yearMonth=" + declareMonth));
}
declareTitle = cachedDataList.get(0).getInvoiceTitle();
if (Common.isEmpty(declareTitle)) {
errorMessageList.add(new ErrorMessage(CommonConstants.ZERO_INT
, "封面抬头全称-不能为空"));
}
if (Common.isNotNull(declareMonth) && Common.isNotNull(declareTitle)) {
TStatisticsCurrentReportMarket sdsCheck = new TStatisticsCurrentReportMarket();
sdsCheck.setDeclareMonth(declareMonth);
sdsCheck.setInvoiceTitle(declareTitle);
QueryWrapper<TStatisticsCurrentReportMarket> queryWrapperSc = new QueryWrapper<>();
queryWrapperSc.setEntity(sdsCheck);
int count = baseMapper.getCountByMonthAndTitle(declareMonth, declareTitle);
if (count > CommonConstants.ZERO_INT) {
errorMessageList.add(new ErrorMessage(CommonConstants.ZERO_INT
, "当前月同一-封面抬头全称-已存在数据。"));
}
}
}
if (errorMessageList.isEmpty()) {
saveData(declareMonth);
}
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
......@@ -198,15 +150,17 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
saveData(declareMonth);
}
/**
* 加上存储数据库
*/
private void saveData() {
private void saveData(String declareMonth) {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTStatisticsCurrentReportMarket(cachedDataList, errorMessageList);
if (!cachedDataList.isEmpty()) {
importTStatisticsCurrentReportMarket(declareMonth, cachedDataList);
}
log.info("存储数据库成功!");
}
}).sheet().doRead();
......@@ -214,29 +168,37 @@ public class TStatisticsCurrentReportMarketServiceImpl extends ServiceImpl<TStat
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
boolean isTrue = true;
for (ErrorMessage message : errorMessageList) {
if (!CommonConstants.SAVE_SUCCESS.equals(message.getMessage())) {
isTrue = false;
break;
}
}
if (isTrue) {
return R.ok();
} else {
return R.failed(errorMessageList);
}
}
private void importTStatisticsCurrentReportMarket(List<TStatisticsCurrentReportMarketVo> excelVOList, List<ErrorMessage> errorMessageList) {
private void importTStatisticsCurrentReportMarket(String declareMonth, List<TStatisticsCurrentReportMarketVo> excelVOList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
TStatisticsCurrentReportMarketVo excel;
TStatisticsCurrentReportMarket insert;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TStatisticsCurrentReportMarketVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
excel = excelVOList.get(i);
insert = new TStatisticsCurrentReportMarket();
BeanUtil.copyProperties(excel, insert);
insert.setDeclareMonth(declareMonth);
this.save(insert);
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TStatisticsCurrentReportMarketVo excel) {
TStatisticsCurrentReportMarket insert = new TStatisticsCurrentReportMarket();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
@Override
public int deleteByYearMonth(String yearMonth) {
return baseMapper.deleteByYearMonth(yearMonth);
}
}
......@@ -194,7 +194,7 @@
LEFT JOIN t_salary_account_item l ON l.SALARY_ACCOUNT_ID = a.id and l.JAVA_FIED_NAME = 'relaySalary'
WHERE
a.DELETE_FLAG = 0
and a.SEND_MONTH = #{settleMonth}
and s.SEND_MONTH = #{settleMonth}
AND s.STATUS IN (3, 4)
GROUP BY a.EMP_IDCARD,a.SALARY_DATE
) b
......
......@@ -41,6 +41,7 @@
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="auditUser" column="AUDIT_USER"/>
<result property="auditTime" column="AUDIT_TIME"/>
<result property="auditRemark" column="AUDIT_REMARK"/>
<result property="province" column="PROVINCE"/>
<result property="city" column="CITY"/>
<result property="town" column="TOWN"/>
......@@ -82,6 +83,7 @@
a.DELETE_FLAG,
a.AUDIT_USER,
a.AUDIT_TIME,
a.AUDIT_REMARK,
a.PROVINCE,
a.CITY,
a.TOWN,
......@@ -159,6 +161,9 @@
<if test="tSalaryStandard.auditTime != null">
AND a.AUDIT_TIME = #{tSalaryStandard.auditTime}
</if>
<if test="tSalaryStandard.auditReamrk != null and tSalaryStandard.auditReamrk.trim() != ''">
AND a.AUDIT_REAMRK = #{tSalaryStandard.auditReamrk}
</if>
<if test="tSalaryStandard.province != null">
AND a.PROVINCE = #{tSalaryStandard.province}
</if>
......
......@@ -112,7 +112,8 @@
left join t_salary_employee b on b.id = a.EMP_ID
left join t_salary_account_item annualbonus on annualbonus.SALARY_ACCOUNT_ID = a.id and annualbonus.CN_NAME='年终奖'
left join t_salary_account_item tax on tax.SALARY_ACCOUNT_ID = a.id and tax.CN_NAME='年终奖单独扣税'
where a.DELETE_FLAG = '1' and a.SETTLEMENT_MONTH like '${lastYear}%' and annualbonus.SALARY_MONEY > 0 and tax.SALARY_MONEY > 0
left join t_salary_standard s ON s.id = a.SALARY_FORM_ID
where a.DELETE_FLAG = '1' and annualbonus.SALARY_MONEY > 0 and tax.SALARY_MONEY > 0 and s.SEND_MONTH like '${lastYear}%'
GROUP BY a.EMP_IDCARD,a.EMP_NAME
</select>
</mapper>
......@@ -276,4 +276,18 @@
<include refid="tStatisticsCurrentReportMarket_where"/>
</where>
</select>
<!-- 删除-按申报月份 -->
<delete id="deleteByYearMonth">
DELETE FROM t_statistics_current_report_market WHERE DECLARE_MONTH = #{yearMonth}
</delete>
<!-- 查重 -->
<select id="getCountByMonthAndTitle" resultType="java.lang.Integer">
SELECT
count(1)
FROM t_statistics_current_report_market a
where a.INVOICE_TITLE = #{declareTitle} and a.declare_MONTH = #{declareMonth}
</select>
</mapper>
......@@ -16,13 +16,7 @@
<description>yifu-social 业务模块</description>
<dependencies>
<!-- seata 依赖 -->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-seata</artifactId>
</dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-social-api</artifactId>
......@@ -73,11 +67,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<version>5.8.0</version>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-archives-api</artifactId>
......@@ -90,6 +79,20 @@
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-transaction-base-seata-at</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-core</artifactId>
</dependency>
</dependencies>
<build>
......
package com.yifu.cloud.plus.v1.yifu.social.config;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Range;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Component
public class OTAStrategyShardingAlgorithm implements StandardShardingAlgorithm<LocalDateTime> {
private static final DateTimeFormatter yyyy = DateTimeFormatter.ofPattern("yyyy");
/**
* 数据插入
* @param collection
* @param preciseShardingValue
* @Author hyc
* @Date 2022-07-21
* @return
*/
@Override
public String doSharding(Collection<String> collection, PreciseShardingValue<LocalDateTime> preciseShardingValue) {
LocalDateTime value = preciseShardingValue.getValue();
String tableSuffix = value.format(yyyy);
String logicTableName = preciseShardingValue.getLogicTableName();
String table = logicTableName.concat("_").concat(tableSuffix);
System.out.println("OrderStrategy.doSharding table name: " + table);
return collection.stream().filter(s -> s.equals(table)).findFirst().orElseThrow(() -> new RuntimeException("逻辑分表不存在"));
}
/**
* 【范围】数据查询
* @param collection
* @param rangeShardingValue
* @Author hyc
* @Date 2022-07-21
* @return
*/
@Override
public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<LocalDateTime> rangeShardingValue) {
// 逻辑表名
String logicTableName = rangeShardingValue.getLogicTableName();
// 范围参数
Range<LocalDateTime> valueRange = rangeShardingValue.getValueRange();
Set<String> queryRangeTables = extracted(logicTableName, valueRange.lowerEndpoint(), valueRange.upperEndpoint());
ArrayList<String> tables = new ArrayList<>(collection);
tables.retainAll(queryRangeTables);
System.out.println(JSON.toJSONString(tables));
return tables;
}
/**
* 根据范围计算表名
* @param logicTableName 逻辑表明
* @param lowerEndpoint 范围起点
* @param upperEndpoint 范围终端
* @Author hyc
* @Date 2022-07-21
* @return 物理表名集合
*/
private Set<String> extracted(String logicTableName, LocalDateTime lowerEndpoint, LocalDateTime upperEndpoint) {
Set<String> rangeTable = new HashSet<>();
while (lowerEndpoint.isBefore(upperEndpoint)) {
String str = getTableNameByDate(lowerEndpoint, logicTableName);
rangeTable.add(str);
lowerEndpoint = lowerEndpoint.plusYears(1);
}
// 获取物理表明
String tableName = getTableNameByDate(upperEndpoint, logicTableName);
rangeTable.add(tableName);
return rangeTable;
}
/**
* 根据日期获取表明
* @param dateTime 日期
* @param logicTableName 逻辑表名
* @Author hyc
* @Date 2022-07-21
* @return 物理表名
*/
private String getTableNameByDate(LocalDateTime dateTime, String logicTableName) {
String tableSuffix = dateTime.format(yyyy);
return logicTableName.concat("_").concat(tableSuffix);
}
@Override
public Properties getProps() {
return null;
}
@Override
public void init(Properties properties) {
}
}
......@@ -25,7 +25,9 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.social.entity.TDispatchInfo;
import com.yifu.cloud.plus.v1.yifu.social.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
......@@ -50,14 +52,16 @@ public interface TDispatchInfoService extends IService<TDispatchInfo> {
List<TDispatchInfo> noPageDiy(TDispatchInfoSearchVo searchVo);
@GlobalTransactional
@Transactional
@ShardingTransactionType(TransactionType.BASE)
void importTDispatchInfo(List<TDispatchImportVo> excelVOList,
List<ErrorMessage> errorMessageList,
YifuUser user);
R<List<ErrorMessage>> importReduceDiy(InputStream inputStream);
@GlobalTransactional
@Transactional
@ShardingTransactionType(TransactionType.BASE)
void batchReduceDispatch(List<TDispatchReduceVo> excelVOList, List<ErrorMessage> errorMessageList, YifuUser user);
R<Boolean> removeByIdDiy(String id);
......
......@@ -50,9 +50,10 @@ import com.yifu.cloud.plus.v1.yifu.social.service.TDispatchInfoService;
import com.yifu.cloud.plus.v1.yifu.social.service.TForecastLibraryService;
import com.yifu.cloud.plus.v1.yifu.social.util.ServiceUtil;
import com.yifu.cloud.plus.v1.yifu.social.vo.*;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
......@@ -294,8 +295,8 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
return R.ok(errorMessageList);
}
@Override
@GlobalTransactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
@ShardingTransactionType(TransactionType.BASE)
public void importTDispatchInfo(List<TDispatchImportVo> excelVOList,
List<ErrorMessage> errorMessageList,
YifuUser user) {
......@@ -2365,9 +2366,9 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
return R.ok(errorMessageList);
}
@GlobalTransactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
@Override
@Transactional(rollbackFor = Exception.class)
@ShardingTransactionType(TransactionType.BASE)
public void batchReduceDispatch(List<TDispatchReduceVo> excelVOList, List<ErrorMessage> errorMessageList, YifuUser user) {
if (!Common.isNotNull(excelVOList)){
return;
......@@ -2679,8 +2680,8 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
* @Param
* @return
**/
@GlobalTransactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
@ShardingTransactionType(TransactionType.BASE)
@Override
public List<ErrorMessage> addBatchApplyAudit(List<String> idsList, YifuUser user, int flag, String auditStatus, String auditRemark, String remark) {
List<ErrorMessage> errorList = new ArrayList<>();
......@@ -3008,8 +3009,8 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
* @Author fxj
* @Date 2022-07-26
**/
@GlobalTransactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
@ShardingTransactionType(TransactionType.BASE)
public List<ErrorMessage> addBatchApplyHandle(List<String> idsList, String typeSub, YifuUser user
, int flag, String handleStatus, String handleRemark, String socialType, String remark) {
List<ErrorMessage> errorList = new ArrayList<>();
......
......@@ -320,7 +320,9 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT1;
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
//所有行数
Integer rowNumber;
/**
*临时存储
*/
......@@ -329,6 +331,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
public void invoke(TPaymentInfoVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
// 获取总行数(含表头)
rowNumber = context.readSheetHolder().getApproximateTotalRowNumber();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
......@@ -354,7 +358,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTPaymentSocialInfo(cachedDataList, errorMessageList, random, user);
importTPaymentSocialInfo(cachedDataList, errorMessageList, random, user, rowNumber);
log.info("存储数据库成功!");
}
}).sheet().doRead();
......@@ -366,7 +370,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
private void importTPaymentSocialInfo(List<TPaymentInfoVo> list, List<ErrorMessage> errorMessageList,
String random, YifuUser user) {
String random, YifuUser user, Integer rowNumber) {
long start = System.currentTimeMillis();
HashMap<String, String> areaMap = new HashMap<String, String>();
......@@ -390,7 +394,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
errorMessageList.add(new ErrorMessage(-1, "当前用户数据导入中,请稍后重试!"));
redisUtil.remove(key);
} else {
redisUtil.set(key, user.getId(), 1800L);
redisUtil.set(key, user.getId(), 360L);
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if (CollUtil.isNotEmpty(list)) {
......@@ -509,6 +513,32 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT);
List<CompletableFuture<List<ErrorMessage>>> completableFutureList = new ArrayList<>();
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = "";
String sumNumKey = user.getId() + CommonConstants.DOWN_LINE_STRING + "sum_key";
Integer bfInt = (Integer) redisUtil.get(sumNumKey);
if (Common.isNotNull(bfInt)) {
if (bfInt <= rowNumber.intValue()) {
maerialRatio = numberFormat.format((float) bfInt.intValue() / (float) rowNumber.intValue() * 100);
bfInt = bfInt + 100;
} else {
maerialRatio = "100";
}
}else {
if (100 <= rowNumber.intValue()) {
maerialRatio = numberFormat.format((float) 100 / (float) rowNumber.intValue() * 100);
bfInt = 100;
} else {
maerialRatio = "100";
}
}
redisUtil.set(sumNumKey, bfInt, 360L);
redisUtil.set(importSuccessKey, maerialRatio, 360L);
try {
// 1.list.size()不足partSize,直接执行
if (list.size() < partSize) {
......@@ -518,12 +548,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CommonConstants.ONE_INT, errorMessageList), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = numberFormat.format((float)atomicLine.get()/(float)list.size()*100);
redisUtil.set(importSuccessKey, maerialRatio, 180L);
}
// 2.list.size()大于partSize,循环分批执行
......@@ -554,12 +578,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
tempList = new ArrayList<>();
}
}
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = numberFormat.format((float)atomicLine.get()/(float)list.size()*100);
redisUtil.set(importSuccessKey, maerialRatio, 180L);
}
// 3.第2种方式执行完后,有余数的情况下,执行3
......@@ -584,12 +602,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
finalLastIdx, errorMessageList), yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = numberFormat.format((float)atomicLine.get()/(float)list.size()*100);
redisUtil.set(importSuccessKey, maerialRatio, 180L);
}
// 阻塞当前线程,等待所有的线程执行完毕
......@@ -1202,6 +1214,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
Integer rowNumber;
/**
*临时存储
*/
......@@ -1209,6 +1222,9 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
public void invoke(TPaymentHeFeiVo data, AnalysisContext context) {
// 获取总行数(含表头)
rowNumber = context.readSheetHolder().getApproximateTotalRowNumber();
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
......@@ -1235,7 +1251,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTPaymentSocialHeFei(cachedDataList, errorMessageList, random, user, type);
importTPaymentSocialHeFei(cachedDataList, errorMessageList, random, user, type,rowNumber);
log.info("存储数据库成功!");
}
}).sheet().doRead();
......@@ -1589,7 +1605,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
private void importTPaymentSocialHeFei(List<TPaymentHeFeiVo> list, List<ErrorMessage> errorMessageList,
String random, YifuUser user, String type) {
String random, YifuUser user, String type, Integer rowNumber) {
HashMap<String, String> areaMap = new HashMap<String, String>();
HashMap<String, String> areaMap2 = new HashMap<String, String>();
......@@ -1606,9 +1622,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
// 判断是否有相同的用户在导入社保费用 存在提示稍后重试
String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_IMPORT;
// 将以下代码提取出来,使用paymentInfoMap提升性能,避免list多次循环查询数据库浪费性能
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if (CollUtil.isNotEmpty(list)) {
......@@ -1713,6 +1726,34 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
List<TPaymentHeFeiVo> tempList = new ArrayList<>();
AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT);
List<CompletableFuture<List<ErrorMessage>>> completableFutureList = new ArrayList<>();
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = "";
String sumNumKey = user.getId() + CommonConstants.DOWN_LINE_STRING + "sum_key";
Integer bfInt = (Integer) redisUtil.get(sumNumKey);
if (Common.isNotNull(bfInt)) {
if (bfInt <= rowNumber.intValue()) {
maerialRatio = numberFormat.format((float) bfInt.intValue() / (float) rowNumber.intValue() * 100);
bfInt = bfInt + 100;
} else {
maerialRatio = "100";
}
}else {
if (100 <= rowNumber.intValue()) {
maerialRatio = numberFormat.format((float) 100 / (float) rowNumber.intValue() * 100);
bfInt = 100;
} else {
maerialRatio = "100";
}
}
redisUtil.set(sumNumKey, bfInt, 360L);
redisUtil.set(importSuccessKey, maerialRatio, 360L);
try {
// 1.list.size()不足partSize,直接执行
if (list.size() < partSize) {
......@@ -1789,19 +1830,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
} while (computeFlag);
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = numberFormat.format((float)atomicLine.get()/(float)list.size()*100);
redisUtil.set(importSuccessKey, maerialRatio, 1800L);
} catch (Exception e) {
log.error("社保缴费库数据批量导入异常:" + e);
redisUtil.remove(key);
} finally {
paymentInfoPensionMap.clear();
paymentInfoBigMap.clear();
......
spring:
shardingsphere:
datasource:
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.65:22306/mvp_social?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: root
password: yf_zsk
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}
username: ${spring.datasource.username}
password: ${spring.datasource.password}
pool-name: AmytangHikariCP
minimum-idle: 10 # 最小空闲连接数量
idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 12 # 连接池最大连接数,默认是10
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
names: ds0
rules:
sharding:
key-generators:
snowflake:
type: SNOWFLAKE
sharding-algorithms:
t-payment-inline:
props:
strategy: standard
algorithmClassName: com.yifu.cloud.plus.v1.yifu.social.config.OTAStrategyShardingAlgorithm
type: CLASS_BASED
tables:
t_payment_info:
actual-data-nodes: ds0.t_payment_info_20$->{17..22}
key-generate-strategy:
column: ID
key-generator-name: snowflake
table-strategy:
standard:
sharding-column: CREATE_TIME
sharding-algorithm-name: t-payment-inline
mvc:
pathmatch:
matching-strategy: ant_path_matcher
......@@ -8,21 +50,4 @@ spring:
redis:
host: 192.168.1.65
port: 22379
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/mvp_social?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}
username: ${spring.datasource.username}
password: ${spring.datasource.password}
pool-name: AmytangHikariCP
minimum-idle: 10 # 最小空闲连接数量
idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 12 # 连接池最大连接数,默认是10
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
\ No newline at end of file
password: '@yf_2017'
\ No newline at end of file
......@@ -103,3 +103,61 @@ springdoc:
- group: social
#按包路径匹配
packagesToScan: com.yifu.cloud.plus.v1.yifu.social.controller
seata:
enabled: true
application-id: seata-server
tx-service-group: yifu_tx_group # 事务群组(可以每个应用独立取名,也可以使用相同的名字)
client:
rm-report-success-enable: true
rm-table-meta-check-enable: false # 自动刷新缓存中的表结构(默认false)
rm-report-retry-count: 5 # 一阶段结果上报TC重试次数(默认5)
rm-async-commit-buffer-limit: 10000 # 异步提交缓存队列长度(默认10000)
rm:
lock:
lock-retry-internal: 10 # 校验或占用全局锁重试间隔(默认10ms)
lock-retry-times: 30 # 校验或占用全局锁重试次数(默认30)
lock-retry-policy-branch-rollback-on-conflict: true # 分支事务与其它全局回滚事务冲突时锁策略(优先释放本地锁让回滚成功)
tm-commit-retry-count: 3 # 一阶段全局提交结果上报TC重试次数(默认1次,建议大于1)
tm-rollback-retry-count: 3 # 一阶段全局回滚结果上报TC重试次数(默认1次,建议大于1)
undo:
data-validation: true # 二阶段回滚镜像校验(默认true开启)
log-serialization: kryo # undo序列化方式(默认jackson 不支持 LocalDateTime)
log-table: undo_log # 自定义undo表名(默认undo_log)
log:
exceptionRate: 100 # 日志异常输出概率(默认100)
support:
spring:
datasource-autoproxy: true
service:
vgroup-mapping:
yifu_tx_group: default # TC 集群(必须与seata-server保持一致)
enable-degrade: false # 降级开关
disable-global-transaction: false # 禁用全局事务(默认false)
grouplist:
default: 192.168.1.65:33091
transport:
shutdown:
wait: 3
thread-factory:
boss-thread-prefix: NettyBoss
worker-thread-prefix: NettyServerNIOWorker
server-executor-thread-prefix: NettyServerBizHandler
share-boss-worker: false
client-selector-thread-prefix: NettyClientSelector
client-selector-thread-size: 1
client-worker-thread-prefix: NettyClientWorkerThread
type: TCP
server: NIO
heartbeat: true
serialization: seata
compressor: none
enable-client-batch-send-request: true # 客户端事务消息请求是否批量合并发送(默认true)
registry:
file:
name: file.conf
type: file
config:
file:
name: file.conf
type: file
......@@ -455,7 +455,7 @@
s.MEDICAL_HANDLE,
s.UNEMPLOY_HANDLE,
s.WORK_INJURY_HANDLE,
s.BIGAILMENT_HANDLE,
s.BIRTH_HANDLE,
s.BIGAILMENT_HANDLE,
a.FUND_HANDLE_STATUS,
a.CREATE_NAME,
......
client {
application.id = seata-server ## 应用唯一id
transaction.service.group = yifu_tx_group ## 所属事务组
}
\ No newline at end of file
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