税率修改接口bug
This commit is contained in:
parent
c183a11cba
commit
b028ad6845
|
|
@ -243,8 +243,8 @@ public class TaxRateBiz extends BaseBean {
|
|||
TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class);
|
||||
|
||||
// 查询是否存在指定的个税税率表
|
||||
TaxRateBase TaxRateBase = getById(updateParam.getTaxRateBatch().getId());
|
||||
if (Objects.isNull(TaxRateBase)) {
|
||||
TaxRateBase taxRateBase = getById(updateParam.getTaxRateBatch().getId());
|
||||
if (Objects.isNull(taxRateBase)) {
|
||||
throw new SalaryRunTimeException("个税税率表不存在");
|
||||
}
|
||||
// 个税税率表主表名称不允许重复
|
||||
|
|
@ -255,34 +255,34 @@ public class TaxRateBiz extends BaseBean {
|
|||
throw new SalaryRunTimeException("名称不允许重复");
|
||||
}
|
||||
// 系统默认的个税税率表不允许编辑
|
||||
if (SalarySystemTypeEnum.parseByValue(TaxRateBase.getSystemType()) == SalarySystemTypeEnum.SYSTEM) {
|
||||
if (SalarySystemTypeEnum.parseByValue(taxRateBase.getSystemType()) == SalarySystemTypeEnum.SYSTEM) {
|
||||
throw new SalaryRunTimeException("系统默认的个税税率表不允许编辑");
|
||||
}
|
||||
// 更新个税税率表主表
|
||||
TaxRateBase newTaxRateBase = new TaxRateBase();
|
||||
BeanUtils.copyProperties(TaxRateBase, newTaxRateBase);
|
||||
BeanUtils.copyProperties(taxRateBase, newTaxRateBase);
|
||||
newTaxRateBase.setName(updateParam.getTaxRateBatch().getName());
|
||||
newTaxRateBase.setDescription(updateParam.getTaxRateBatch().getDescription());
|
||||
taxRateBaseMapper.updateIgnoreNull(newTaxRateBase);
|
||||
// 记录日志
|
||||
// LoggerContext loggerContext = new LoggerContext<>();
|
||||
// loggerContext.setTargetId(String.valueOf(TaxRateBase.getId()));
|
||||
// loggerContext.setTargetName(TaxRateBase.getName());
|
||||
// loggerContext.setTargetId(String.valueOf(taxRateBase.getId()));
|
||||
// loggerContext.setTargetName(taxRateBase.getName());
|
||||
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
||||
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98108, "编辑个税税率表(基础信息)"));
|
||||
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(86124, "基础信息"));
|
||||
// loggerContext.setOldValues(TaxRateBase);
|
||||
// loggerContext.setOldValues(taxRateBase);
|
||||
// loggerContext.setNewValues(newTaxRateBase);
|
||||
// taxRateLoggerTemplate.write(loggerContext);
|
||||
// 更新个税税率表明细表-先删除后插入
|
||||
List<TaxRateDetail> taxRateDetailPOS = taxRateDetailMapper.listByBaseId(TaxRateBase.getId());
|
||||
taxRateDetailMapper.deleteByBatchIds(Collections.singleton(TaxRateBase.getId()));
|
||||
List<TaxRateDetail> newTaxRateDetailPOS = TaxRateBO.convert2RecordPO(TaxRateBase.getId(), updateParam.getTaxRateRecords(), employeeId);
|
||||
new TaxRateDetailBiz().saveBatch(taxRateDetailPOS);
|
||||
List<TaxRateDetail> taxRateDetailPOS = taxRateDetailMapper.listByBaseId(taxRateBase.getId());
|
||||
taxRateDetailMapper.deleteByBatchIds(Collections.singleton(taxRateBase.getId()));
|
||||
List<TaxRateDetail> newTaxRateDetailPOS = TaxRateBO.convert2RecordPO(taxRateBase.getId(), updateParam.getTaxRateRecords(), employeeId);
|
||||
new TaxRateDetailBiz().saveBatch(newTaxRateDetailPOS);
|
||||
// 记录日志
|
||||
// LoggerContext detailLoggerContext = new LoggerContext<>();
|
||||
// detailLoggerContext.setTargetId(String.valueOf(TaxRateBase.getId()));
|
||||
// detailLoggerContext.setTargetName(TaxRateBase.getName());
|
||||
// detailLoggerContext.setTargetId(String.valueOf(taxRateBase.getId()));
|
||||
// detailLoggerContext.setTargetName(taxRateBase.getName());
|
||||
// detailLoggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
||||
// detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98128, "新增个税税率表(详细设置)"));
|
||||
// detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(96687, "详细设置"));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.salary.cmd.datacollection;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AddUpDeductionExportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
public AddUpDeductionExportCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
||||
|
||||
|
||||
|
||||
return apidatas;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,11 +5,12 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.personalIncomeTax.biz.RecordsBiz;
|
||||
import com.engine.personalIncomeTax.enums.FormTypeEnum;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.general.Util;
|
||||
|
|
@ -748,4 +749,177 @@ public class ExportDeclareRecordsProcess extends BaseBean {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 解析操作按钮excel时sheet下标
|
||||
*/
|
||||
private static final int OPERATOR_PARSE_EXCEL_SHEET_INDEX = 0;
|
||||
|
||||
/**
|
||||
* 解析操作按钮excel时开始行
|
||||
*/
|
||||
private static final int OPERATOR_PARSE_EXCEL_BEGIN_ROW_INDEX = 1;
|
||||
|
||||
/**
|
||||
* 解析操作按钮excel时应有多少列
|
||||
*/
|
||||
private static final int OPERATOR_PARSE_EXCEL_VALID_CELL_NUM = 5;
|
||||
|
||||
// @Override
|
||||
// public void importOperator(MultipartFile file, String tenantCode, String systemId) {
|
||||
//
|
||||
// //验证导入参数
|
||||
// if (file == null) {
|
||||
// throw new OPERBIZException(OperatorExceptionCode.IMPORT_FILE_IS_EMPTY);
|
||||
// }
|
||||
// validOperator(tenantCode, systemId);
|
||||
//
|
||||
// //解析文件获取元素集合
|
||||
// List<OperatorBaseDto> operatorList = ExcelParseHelper.parse(file, OperatorBaseDto.class,
|
||||
// OPERATOR_PARSE_EXCEL_SHEET_INDEX, OPERATOR_PARSE_EXCEL_BEGIN_ROW_INDEX, OPERATOR_PARSE_EXCEL_VALID_CELL_NUM);
|
||||
// //操作人
|
||||
// final String userId = JWTUtil.getUserId();
|
||||
// //当前时间
|
||||
// final long currentTime = new Date().getTime();
|
||||
// //操作集合
|
||||
// final List<OperatorBaseDto> list = operatorList.stream()
|
||||
// .peek(operator -> {//初始化值
|
||||
// operator.setTenantCode(tenantCode);
|
||||
// operator.setSystemId(systemId);
|
||||
// operator.setUseStatus(NORMAL_STATUS);
|
||||
// operator.setCreateUser(userId);
|
||||
// operator.setCreateTime(currentTime);
|
||||
// operator.setUpdateUser(userId);
|
||||
// operator.setUpdateTime(currentTime);
|
||||
// })
|
||||
// .filter(operator -> StringUtils.isNoneBlank(operator.getOperatorFlag(), operator.getOperatorName(), operator.getIcon())) //过滤不合法元素
|
||||
// .collect(Collectors
|
||||
// .collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(OperatorBaseDto::getOperatorFlag))),
|
||||
// ArrayList::new));
|
||||
//
|
||||
// //将操作按新增或更新分类
|
||||
// final Pair<List<OperatorBaseDto>, List<OperatorBaseDto>> operatorListPair = classifyOperator(tenantCode, systemId, list);
|
||||
// final List<OperatorBaseDto> addlist = operatorListPair.getLeft();
|
||||
// final List<OperatorBaseDto> updateList = operatorListPair.getRight();
|
||||
//
|
||||
// //批量新增
|
||||
// operatorDalService.batchAdd(this.convertListFromSource(addlist));
|
||||
//
|
||||
// //逐条更新
|
||||
// updateList.forEach(operatorBaseDto -> operatorDalService.updateByFlag(this.convertBeanFromSource(operatorBaseDto)));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* excel标题
|
||||
*/
|
||||
// private final static List<String> title = Arrays.asList("Operation identification", "Operation name", "Icon", "Sort number", "custom");
|
||||
//
|
||||
// public HSSFWorkbook exportOperator(String tenantCode, String systemId) {
|
||||
//
|
||||
//
|
||||
//
|
||||
// //获取操作按钮资源
|
||||
//// List<List<String>> rowList = getExcelRowList(tenantCode, systemId);
|
||||
//
|
||||
// //获取excel
|
||||
// return getWorkbook(rowList);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取excel
|
||||
*
|
||||
* @param rowList 行列表
|
||||
* @return workbook
|
||||
*/
|
||||
private HSSFWorkbook getWorkbook(List<List<String>> rowList) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
HSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
HSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("0");
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<String> infoList = rowList.get(rowIndex);
|
||||
HSSFRow row = sheet.createRow(rowIndex);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
HSSFCell cell = row.createCell(cellIndex);
|
||||
cell.setCellType(CellType.STRING);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
cell.setCellValue(infoList.get(cellIndex));
|
||||
sheet.setColumnWidth(cellIndex, 35 * 256);
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取excel数据行
|
||||
*
|
||||
* @param tenantCode 租户
|
||||
* @param systemId 系统id
|
||||
* @return 导出数据行集合
|
||||
*/
|
||||
// private List<List<String>> getExcelRowList(String tenantCode, String systemId) {
|
||||
// final List<OperatorBaseDo> operatorBaseDoList = operatorDalService.selectOperatorListInOneSystem(tenantCode, systemId, null);
|
||||
// final List<List<String>> dataRowList = Optional.ofNullable(operatorBaseDoList)
|
||||
// .map(List::stream)
|
||||
// .map(operatorStream -> operatorStream.map(operatorBaseDo -> {
|
||||
// List<String> cellList = new ArrayList<>();
|
||||
// cellList.add(operatorBaseDo.getOperatorFlag());
|
||||
// cellList.add(operatorBaseDo.getOperatorName());
|
||||
// cellList.add(operatorBaseDo.getIcon());
|
||||
// cellList.add(operatorBaseDo.getSort() == null ? "" : operatorBaseDo.getSort().toString());
|
||||
// cellList.add(operatorBaseDo.getCustom());
|
||||
// return cellList;
|
||||
// }).collect(Collectors.toList()))
|
||||
// .orElse(Collections.emptyList());
|
||||
//
|
||||
// List<List<String>> rowList = new ArrayList<>();
|
||||
// rowList.add(title);
|
||||
// rowList.addAll(dataRowList);
|
||||
// return rowList;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,19 @@ import com.engine.salary.service.AddUpDeductionService;
|
|||
import com.engine.salary.service.impl.AddUpDeductionServiceImpl;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
public class AddUpDeductionController {
|
||||
|
|
@ -36,24 +39,39 @@ public class AddUpDeductionController {
|
|||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/downloadTemplate")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response getAll() {
|
||||
|
||||
//模板文件路径
|
||||
String templateFilePath = GCONST.getRootPath() + "hrm/resource/inputexcellfile/taxDeclareTemplate.xls";
|
||||
|
||||
File file = new File(templateFilePath);
|
||||
|
||||
if (!file.exists()) {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
String fileName = null;
|
||||
try {
|
||||
fileName = URLEncoder.encode("累计专项附加扣除导入模板.xlsx", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Response
|
||||
.ok(file)
|
||||
.header("Content-disposition", "attachment;filename=" + fileName)
|
||||
.header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 下载导入模板
|
||||
// * 导出
|
||||
// * @param queryParam
|
||||
// * @return
|
||||
// */
|
||||
// @POST()
|
||||
// @Path("/downloadTemplate")
|
||||
// @ApiOperation("下载导入模板")
|
||||
// @WeaPermission
|
||||
// public WeaResult<Map<String, Object>> downloadTemplate(@RequestBody AddUpDeductionQueryParam queryParam) {
|
||||
// return WeaResult.success(service.downloadTemplate(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 导出
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
// @POST
|
||||
// @Path("/export")
|
||||
// @Produces(MediaType.APPLICATION_JSON)
|
||||
|
|
|
|||
Loading…
Reference in New Issue