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;
/**
* 创建时间区间 [开始时间,结束时间]
*/
......
......@@ -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<>();
......
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