Commit 79bebed7 authored by hongguangwu's avatar hongguangwu

回盘

parent 9ea9c330
......@@ -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);
}
......@@ -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);
}
}
......@@ -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>
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