Commit 2a09e5c9 authored by hongguangwu's avatar hongguangwu

优化,别弄掉了

parent af2f9239
......@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
......@@ -77,103 +78,103 @@ public class TSocialFundInfo extends BaseEntity {
/**
* 员工身份证
*/
@Length(max = 20, message = "员工身份证 不能超过20个字符" )
@ExcelAttribute(name = "员工身份证", maxLength = 20)
@Schema(description = "员工身份证" )
@ExcelProperty("员工身份证" )
@Length(max = 20, message = "身份证号 不能超过20个字符" )
@ExcelAttribute(name = "身份证号", maxLength = 20)
@Schema(description = "身份证号" )
@ExcelProperty("身份证号" )
private String empIdcard;
/**
* 员工类型
*/
@Length(max = 32, message = "员工类型 不能超过32个字符" )
@ExcelAttribute(name = "员工类型", maxLength = 32)
@ExcelAttribute(name = "员工类型", maxLength = 32, isDataId = true, dataType = ExcelAttributeConstants.EMP_NATRUE)
@Schema(description = "员工类型" )
@ExcelProperty("员工类型" )
private String empType;
/**
* 结算主体
*/
@Length(max = 32, message = "结算主体 不能超过32个字符" )
@ExcelAttribute(name = "结算主体", maxLength = 32)
@Schema(description = "结算主体" )
@ExcelProperty("结算主体" )
@Length(max = 32, message = "项目id 不能超过32个字符" )
@ExcelAttribute(name = "项目id", maxLength = 32)
@Schema(description = "项目id" )
@ExcelProperty("项目id" )
private String settleDomain;
/**
* 结算主体
*/
@Length(max = 50, message = "结算主体 不能超过50个字符" )
@ExcelAttribute(name = "结算主体", maxLength = 50)
@Schema(description = "结算主体" )
@ExcelProperty("结算主体" )
@Length(max = 50, message = "社保项目名称不能超过50个字符" )
@ExcelAttribute(name = "社保项目名称", maxLength = 50)
@Schema(description = "社保项目名称" )
@ExcelProperty("社保项目名称" )
private String settleDomainName;
/**
* 结算主体编码
*/
@Length(max = 50, message = "结算主体编码不能超过50个字符" )
@ExcelAttribute(name = "结算主体编码", maxLength = 50)
@Schema(description = "结算主体编码" )
@ExcelProperty("结算主体编码" )
@Length(max = 50, message = "社保项目编码不能超过50个字符" )
@ExcelAttribute(name = "社保项目编码", maxLength = 50)
@Schema(description = "社保项目编码" )
@ExcelProperty("社保项目编码" )
private String settleDomainCode;
/**
* unitName
*/
@Length(max = 50, message = "unitName 不能超过50个字符" )
@ExcelAttribute(name = "unitName", maxLength = 50)
@Schema(description = "unitName" )
@ExcelProperty("unitName" )
@Length(max = 50, message = "社保单位名称不能超过50个字符" )
@ExcelAttribute(name = "社保单位名称", maxLength = 50)
@Schema(description = "社保单位名称" )
@ExcelProperty("社保单位名称" )
private String unitName;
/**
* unitId
*/
@ExcelAttribute(name = "unitId", maxLength = 32)
@Schema(description = "unitId" )
@ExcelProperty("unitId" )
@ExcelAttribute(name = "社保单位id", maxLength = 32)
@Schema(description = "社保单位id" )
@ExcelProperty("社保单位id" )
private String unitId;
/**
* 结算主体-公积金
*/
@ExcelAttribute(name = "结算主体-公积金", maxLength = 32)
@Schema(description = "结算主体-公积金" )
@ExcelProperty("结算主体-公积金" )
@ExcelAttribute(name = "公积金项目id", maxLength = 32)
@Schema(description = "公积金项目id" )
@ExcelProperty("公积金项目id" )
private String settleDomainFund;
/**
* 结算主体-公积金
*/
@ExcelAttribute(name = "结算主体-公积金", maxLength = 50)
@Schema(description = "结算主体-公积金" )
@ExcelProperty("结算主体-公积金" )
@ExcelAttribute(name = "公积金项目名称", maxLength = 50)
@Schema(description = "公积金项目名称" )
@ExcelProperty("公积金项目名称" )
private String settleDomainNameFund;
/**
* 结算主体编码-公积金
*/
@ExcelAttribute(name = "结算主体编码-公积金", maxLength = 50)
@Schema(description = "结算主体编码-公积金" )
@ExcelProperty("结算主体编码-公积金" )
@ExcelAttribute(name = "公积金项目编码", maxLength = 50)
@Schema(description = "公积金项目编码" )
@ExcelProperty("公积金项目编码" )
private String settleDomainCodeFund;
/**
* 单位名称-公积金
*/
@ExcelAttribute(name = "单位名称-公积金", maxLength = 50)
@Schema(description = "单位名称-公积金" )
@ExcelProperty("单位名称-公积金" )
@ExcelAttribute(name = "公积金单位名称", maxLength = 50)
@Schema(description = "公积金单位名称" )
@ExcelProperty("公积金单位名称" )
private String unitNameFund;
/**
* 单位ID
*/
@ExcelAttribute(name = "单位ID", maxLength = 32)
@Schema(description = "单位ID" )
@ExcelProperty("单位ID" )
@ExcelAttribute(name = "公积金单位id", maxLength = 32)
@Schema(description = "公积金单位id" )
@ExcelProperty("公积金单位id" )
private String unitIdFund;
/**
* 社保户
*/
@Length(max = 32, message = "社保户 不能超过32个字符" )
@ExcelAttribute(name = "社保户", maxLength = 32)
@Schema(description = "社保户" )
@ExcelProperty("社保户" )
@Length(max = 32, message = "社保户id 不能超过32个字符" )
@ExcelAttribute(name = "社保户id", maxLength = 32)
@Schema(description = "社保户id" )
@ExcelProperty("社保户id" )
private String socialHousehold;
/**
* 社保户
......
......@@ -59,6 +59,7 @@ import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
* 社保公积金查询表
*
......@@ -77,21 +78,23 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
/**
* 社保公积金查询表简单分页查询
*
* @param tSocialFundInfo 社保公积金查询表
* @return
*/
@Override
public IPage<TSocialFundInfo> getTSocialFundInfoPage(Page<TSocialFundInfo> page, TSocialFundInfoSearchVo tSocialFundInfo){
return baseMapper.getTSocialFundInfoPage(page,tSocialFundInfo);
public IPage<TSocialFundInfo> getTSocialFundInfoPage(Page<TSocialFundInfo> page, TSocialFundInfoSearchVo tSocialFundInfo) {
return baseMapper.getTSocialFundInfoPage(page, tSocialFundInfo);
}
/**
* 社保公积金查询表批量导出
*
* @return
*/
@Override
public void listExport(HttpServletResponse response, TSocialFundInfoSearchVo searchVo){
String fileName = "不良记录批量导出" + DateUtil.getThisTime() + ".xlsx";
public void listExport(HttpServletResponse response, TSocialFundInfoSearchVo searchVo) {
String fileName = "社保公积金批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TSocialFundInfo> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
......@@ -100,45 +103,38 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
out = response.getOutputStream();
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName , "UTF-8"));
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, TSocialFundInfo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
for (int i = 0; i <= count; ) {
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){
if (Common.isNotNull(list)) {
ExcelUtil<TSocialFundInfo> util = new ExcelUtil<>(TSocialFundInfo.class);
for (TSocialFundInfo vo:list){
util.convertEntity(vo,null,null,null);
for (TSocialFundInfo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)){
WriteSheet writeSheet = EasyExcel.writerSheet("社保公积金查询表"+index).build();
excelWriter.write(list,writeSheet);
if (list != null) {
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();
} else {
WriteSheet writeSheet = EasyExcel.writerSheet("社保公积金查询表" + index).build();
excelWriter.write(list, writeSheet);
}
out.flush();
excelWriter.finish();
}catch (Exception e){
log.error("执行异常" ,e);
}finally {
} catch (Exception e) {
log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
......@@ -153,11 +149,11 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
public List<TSocialFundInfo> noPageDiy(TSocialFundInfoSearchVo searchVo) {
LambdaQueryWrapper<TSocialFundInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TSocialFundInfo::getId,idList);
if (Common.isNotNull(idList)) {
wrapper.in(TSocialFundInfo::getId, idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0){
wrapper.last(" limit "+ searchVo.getLimitStart() +","+ searchVo.getLimitEnd());
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0) {
wrapper.last(" limit " + searchVo.getLimitStart() + "," + searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
......@@ -166,21 +162,21 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
private Long noPageCountDiy(TSocialFundInfoSearchVo searchVo) {
LambdaQueryWrapper<TSocialFundInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TSocialFundInfo::getId,idList);
if (Common.isNotNull(idList)) {
wrapper.in(TSocialFundInfo::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TSocialFundInfoSearchVo entity){
private LambdaQueryWrapper buildQueryWrapper(TSocialFundInfoSearchVo entity) {
LambdaQueryWrapper<TSocialFundInfo> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TSocialFundInfo::getCreateTime, entity.getCreateTimes()[0])
.le(TSocialFundInfo::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())){
wrapper.eq(TSocialFundInfo::getCreateName,entity.getCreateName());
if (Common.isNotNull(entity.getCreateName())) {
wrapper.eq(TSocialFundInfo::getCreateName, entity.getCreateName());
}
return wrapper;
}
......@@ -188,7 +184,8 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TSocialFundInfoVo> util1 = new ExcelUtil<>(TSocialFundInfoVo.class);;
ExcelUtil<TSocialFundInfoVo> util1 = new ExcelUtil<>(TSocialFundInfoVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
......@@ -207,11 +204,11 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
public void invoke(TSocialFundInfoVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
}else {
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
......@@ -220,6 +217,7 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
......@@ -230,16 +228,17 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTSocialFundInfo(cachedDataList,errorMessageList);
importTSocialFundInfo(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void importTSocialFundInfo(List<TSocialFundInfoVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
......@@ -250,9 +249,10 @@ public class TSocialFundInfoServiceImpl extends ServiceImpl<TSocialFundInfoMappe
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.SAVE_SUCCESS));
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
......
......@@ -85,10 +85,6 @@
select="com.yifu.cloud.plus.v1.yifu.social.mapper.SysPayProportionMapper.selectByPrimaryId" column="id">
</collection>
</resultMap>
<sql id="base_column_list">
SELECT
a.*
</sql>
<sql id="Base_Column_List">
a.ID,
a.PROVINCE,
......@@ -328,6 +324,7 @@
</sql>
<!--sysBaseSetInfo简单分页查询-->
<select id="getSysBaseSetInfoPage" resultMap="sysBaseSetInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys_base_set_info a
<where>
......@@ -338,7 +335,8 @@
</select>
<!--sysBaseSetInfo简单查询-->
<select id="getAllByEntity" resultMap="sysBaseSetInfoMap">
<include refid="base_column_list"/>
SELECT
<include refid="Base_column_list"/>
FROM sys_base_set_info a
<where>
1=1
......@@ -348,7 +346,8 @@
<!--获取对应户名称的公积金基数信息-->
<select id="getFundBaseSet" resultMap="sysBaseSetInfoMap">
<include refid="base_column_list"/>
SELECT
<include refid="Base_column_list"/>
FROM sys_base_set_info a
<where>
1=1
......@@ -369,7 +368,8 @@
<!--sysBaseSetInfo不分页查询-->
<select id="getSysBaseSetInfoNoPage" resultMap="sysBaseSetInfoMap">
<include refid="base_column_list"/>
SELECT
<include refid="Base_column_list"/>
FROM sys_base_set_info a
<where>
1=1
......
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