Commit d89b1d67 authored by hongguangwu's avatar hongguangwu

优化sonar

parent 4223427c
...@@ -158,15 +158,15 @@ public class TSalaryStandardController { ...@@ -158,15 +158,15 @@ public class TSalaryStandardController {
* 审核 * 审核
* *
* @param auditFlag 是否通过 0 是 1 否 * @param auditFlag 是否通过 0 是 1 否
* @param AuditRemark 审核意见 * @param auditRemark 审核意见
* @param id * @param id
* @return * @return
*/ */
@Operation(description = "薪酬审核") @Operation(description = "薪酬审核")
@PostMapping("/salaryStandardAudit") @PostMapping("/salaryStandardAudit")
public R salaryStandardAudit(@RequestParam String auditFlag, @RequestParam(required = false) String AuditRemark, public R<String> salaryStandardAudit(@RequestParam String auditFlag, @RequestParam(required = false) String auditRemark,
@RequestParam String id) { @RequestParam String id) {
return tSalaryStandardService.salaryStandardAudit(auditFlag, AuditRemark, id); return tSalaryStandardService.salaryStandardAudit(auditFlag, auditRemark, id);
} }
/** /**
...@@ -175,7 +175,7 @@ public class TSalaryStandardController { ...@@ -175,7 +175,7 @@ public class TSalaryStandardController {
*/ */
@Operation(description = "保存并提交") @Operation(description = "保存并提交")
@PostMapping("/doSubmit") @PostMapping("/doSubmit")
public R salaryStandardAudit(@RequestBody TSalaryStandard tSalaryStandard) { public R<String> salaryStandardAudit(@RequestBody TSalaryStandard tSalaryStandard) {
if (tSalaryStandard != null && Common.isNotNull(tSalaryStandard.getId())) { if (tSalaryStandard != null && Common.isNotNull(tSalaryStandard.getId())) {
TSalaryStandard s = tSalaryStandardService.getById(tSalaryStandard.getId()); TSalaryStandard s = tSalaryStandardService.getById(tSalaryStandard.getId());
if (s == null) { if (s == null) {
......
...@@ -20,14 +20,12 @@ package com.yifu.cloud.plus.v1.yifu.salary.service; ...@@ -20,14 +20,12 @@ package com.yifu.cloud.plus.v1.yifu.salary.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandard; import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandard;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardExportVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -44,8 +42,6 @@ public interface TSalaryStandardService extends IService<TSalaryStandard> { ...@@ -44,8 +42,6 @@ public interface TSalaryStandardService extends IService<TSalaryStandard> {
*/ */
IPage<TSalaryStandard> getTSalaryStandardPage(Page<TSalaryStandard> page, TSalaryStandardSearchVo tSalaryStandard); IPage<TSalaryStandard> getTSalaryStandardPage(Page<TSalaryStandard> page, TSalaryStandardSearchVo tSalaryStandard);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TSalaryStandardSearchVo searchVo); void listExport(HttpServletResponse response, TSalaryStandardSearchVo searchVo);
List<TSalaryStandardExportVo> noPageDiy(TSalaryStandardSearchVo searchVo); List<TSalaryStandardExportVo> noPageDiy(TSalaryStandardSearchVo searchVo);
...@@ -60,11 +56,11 @@ public interface TSalaryStandardService extends IService<TSalaryStandard> { ...@@ -60,11 +56,11 @@ public interface TSalaryStandardService extends IService<TSalaryStandard> {
/** /**
* 标准薪酬工资表审核 * 标准薪酬工资表审核
* @param auditFlag 是否通过 0 是 1 否 * @param auditFlag 是否通过 0 是 1 否
* @param AuditRemark 审核意见 * @param auditRemark 审核意见
* @param id * @param id
* @return * @return
*/ */
R salaryStandardAudit(String auditFlag, String AuditRemark,String id); R<String> salaryStandardAudit(String auditFlag, String auditRemark,String id);
/** /**
* @Description: 删除工资表 * @Description: 删除工资表
......
...@@ -16,13 +16,8 @@ ...@@ -16,13 +16,8 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.salary.service.impl; package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import cn.hutool.core.bean.BeanUtil; import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter; 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.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -31,7 +26,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -31,7 +26,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TDepartSettlementInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TDepartSettlementInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSocialProperties; import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSocialProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil; import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
...@@ -51,7 +49,6 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardService; ...@@ -51,7 +49,6 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardService;
import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants; import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardExportVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardVo;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -61,7 +58,6 @@ import org.springframework.stereotype.Service; ...@@ -61,7 +58,6 @@ import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -103,6 +99,7 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe ...@@ -103,6 +99,7 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
public IPage<TSalaryStandard> getTSalaryStandardPageApply(Page<TSalaryStandard> page, TSalaryStandardSearchVo tSalaryStandard) { public IPage<TSalaryStandard> getTSalaryStandardPageApply(Page<TSalaryStandard> page, TSalaryStandardSearchVo tSalaryStandard) {
return baseMapper.getTSalaryStandardPageApply(page, tSalaryStandard); return baseMapper.getTSalaryStandardPageApply(page, tSalaryStandard);
} }
/** /**
* 标准薪酬工资表简单分页查询 * 标准薪酬工资表简单分页查询
* *
...@@ -132,10 +129,10 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe ...@@ -132,10 +129,10 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8")); response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TSalaryStandardExportVo.class).build(); ExcelWriter excelWriter = EasyExcelFactory.write(out, TSalaryStandardExportVo.class).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; ) { for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
...@@ -147,17 +144,16 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe ...@@ -147,17 +144,16 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
} }
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("项目薪酬表" + index).build(); WriteSheet writeSheet = EasyExcelFactory.writerSheet("项目薪酬表" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
index++; index++;
} }
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
list.clear(); list.clear();
} }
} }
} else { } else {
WriteSheet writeSheet = EasyExcel.writerSheet("项目薪酬表" + index).build(); WriteSheet writeSheet = EasyExcelFactory.writerSheet("项目薪酬表" + index).build();
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
...@@ -180,91 +176,11 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe ...@@ -180,91 +176,11 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
@Override @Override
public List<TSalaryStandardExportVo> noPageDiy(TSalaryStandardSearchVo searchVo) { public List<TSalaryStandardExportVo> noPageDiy(TSalaryStandardSearchVo searchVo) {
return baseMapper.getSalaryStandardExport(searchVo,Common.getList(searchVo.getIds())); return baseMapper.getSalaryStandardExport(searchVo, Common.getList(searchVo.getIds()));
} }
private int noPageCountDiy(TSalaryStandardSearchVo searchVo) { private int noPageCountDiy(TSalaryStandardSearchVo searchVo) {
return baseMapper.getSalaryStandardExportCount(searchVo,Common.getList(searchVo.getIds())); return baseMapper.getSalaryStandardExportCount(searchVo, Common.getList(searchVo.getIds()));
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TSalaryStandardVo> util1 = new ExcelUtil<>(TSalaryStandardVo.class);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TSalaryStandardVo.class, new ReadListener<TSalaryStandardVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TSalaryStandardVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TSalaryStandardVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTSalaryStandard(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void importTSalaryStandard(List<TSalaryStandardVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TSalaryStandardVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TSalaryStandardVo excel) {
TSalaryStandard insert = new TSalaryStandard();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
} }
@Override @Override
...@@ -273,7 +189,7 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe ...@@ -273,7 +189,7 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
} }
@Override @Override
public R salaryStandardAudit(String auditFlag, String auditRemark, String id) { public R<String> salaryStandardAudit(String auditFlag, String auditRemark, String id) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
TSalaryStandard tSalaryStandard = baseMapper.selectById(id); TSalaryStandard tSalaryStandard = baseMapper.selectById(id);
if (Common.isNotNull(tSalaryStandard)) { if (Common.isNotNull(tSalaryStandard)) {
...@@ -320,7 +236,6 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe ...@@ -320,7 +236,6 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
} else { } else {
return R.failed("删除失败:未找到工资表!"); return R.failed("删除失败:未找到工资表!");
} }
String deptId = sf.getDeptId();
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
if (null == user || null == user.getId()) { if (null == user || null == user.getId()) {
return R.failed("删除工资表失败-获取登录人信息为空"); return R.failed("删除工资表失败-获取登录人信息为空");
......
...@@ -274,6 +274,12 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl ...@@ -274,6 +274,12 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
return this.save(income); return this.save(income);
} }
/**
* @Description: 明细转统计核心逻辑
* @Author: hgw
* @Date: 2022/9/2 10:22
* @return: boolean
**/
private boolean copyCore(TIncomeDetail tIncomeDetail, List<TIncome> incomeList, List<TIncomeDetail> detailList) { private boolean copyCore(TIncomeDetail tIncomeDetail, List<TIncome> incomeList, List<TIncomeDetail> detailList) {
// 判断,比例,直接加 // 判断,比例,直接加
if (CommonConstants.ONE_STRING.equals(tIncomeDetail.getFeeMode())) { if (CommonConstants.ONE_STRING.equals(tIncomeDetail.getFeeMode())) {
......
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