Commit ffda128b authored by hongguangwu's avatar hongguangwu

MVP1.5.2-开户行

parent cbd22ff2
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.entity;
import com.alibaba.excel.annotation.ExcelProperty;
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.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
@Data
@TableName("t_bank_set")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "开户行配置表")
public class TBankSet extends BaseEntity {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* bankName
*/
@ExcelAttribute(name = "开户行", isNotEmpty = true, errorInfo = "开户行不能为空", maxLength = 50)
@NotBlank(message = "开户行不能为空")
@Length(max = 50, message = "开户行不能超过50个字符")
@ExcelProperty("开户行")
@Schema(description = "开户行")
private String bankName;
}
\ No newline at end of file
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.vo;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TBankSet;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
@Data
public class TBankSetSearchVo extends TBankSet {
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID,多个逗号分割")
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
@Schema(description = "查询limit 开始")
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
@Schema(description = "查询limit 数据条数")
private int limitEnd;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
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;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
@Data
public class TBankSetVo 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;
/**
* bankName
*/
@NotBlank(message = "bankName 不能为空")
@Length(max = 50, message = "bankName 不能超过50 个字符")
@ExcelAttribute(name = "bankName", isNotEmpty = true, errorInfo = "bankName 不能为空", maxLength = 50)
@Schema(description = "bankName")
@ExcelProperty("bankName")
private String bankName;
/**
* 创建人id
*/
@Length(max = 64, message = "创建人id 不能超过64 个字符")
@ExcelAttribute(name = "创建人id", maxLength = 64)
@Schema(description = "创建人id")
@ExcelProperty("创建人id")
private String createBy;
/**
* 创建人姓名
*/
@Length(max = 64, message = "创建人姓名 不能超过64 个字符")
@ExcelAttribute(name = "创建人姓名", maxLength = 64)
@Schema(description = "创建人姓名")
@ExcelProperty("创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间", isDate = true)
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private Date createTime;
/**
* 更新人id
*/
@Length(max = 32, message = "更新人id 不能超过32 个字符")
@ExcelAttribute(name = "更新人id", maxLength = 32)
@Schema(description = "更新人id")
@ExcelProperty("更新人id")
private String updateBy;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间", isDate = true)
@Schema(description = "更新时间")
@ExcelProperty("更新时间")
private Date updateTime;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TBankSet;
import com.yifu.cloud.plus.v1.yifu.salary.service.TBankSetService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankSetSearchVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tbankset")
@Tag(name = "开户行配置表管理")
public class TBankSetController {
private final TBankSetService tBankSetService;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tBankSet 开户行配置表
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<TBankSet>> getTBankSetPage(Page<TBankSet> page, TBankSetSearchVo tBankSet) {
return new R<>(tBankSetService.getTBankSetPage(page, tBankSet));
}
/**
* 不分页查询
*
* @param tBankSet 开户行配置表
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage")
public R<List<TBankSet>> getTBankSetNoPage(@RequestBody TBankSetSearchVo tBankSet) {
return R.ok(tBankSetService.noPageDiy(tBankSet));
}
/**
* 通过id查询开户行配置表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('salary_tbankset_get')")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('salary_tbankset_get')")
public R<TBankSet> getById(@PathVariable("id") String id) {
return R.ok(tBankSetService.getById(id));
}
/**
* 新增开户行配置表
*
* @param tBankSet 开户行配置表
* @return R
*/
@Operation(summary = "新增开户行配置表", description = "新增开户行配置表:hasPermission('salary_tbankset_add')")
@SysLog("新增开户行配置表")
@PostMapping
@PreAuthorize("@pms.hasPermission('salary_tbankset_add')")
public R<Boolean> save(@RequestBody TBankSet tBankSet) {
return R.ok(tBankSetService.save(tBankSet));
}
/**
* 修改开户行配置表
*
* @param tBankSet 开户行配置表
* @return R
*/
@Operation(summary = "修改开户行配置表", description = "修改开户行配置表:hasPermission('salary_tbankset_edit')")
@SysLog("修改开户行配置表")
@PutMapping
@PreAuthorize("@pms.hasPermission('salary_tbankset_edit')")
public R<Boolean> updateById(@RequestBody TBankSet tBankSet) {
return R.ok(tBankSetService.updateById(tBankSet));
}
/**
* 通过id删除开户行配置表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id删除开户行配置表", description = "通过id删除开户行配置表:hasPermission('salary_tbankset_del')")
@SysLog("通过id删除开户行配置表")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('salary_tbankset_del')")
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tBankSetService.removeById(id));
}
/**
* 开户行配置表 批量导入
*
* @author hgw
* @date 2023-03-06 11:54:21
**/
@SneakyThrows
@Operation(description = "批量新增开户行配置表 hasPermission('salary_tbankset-batch-import')")
@SysLog("批量新增开户行配置表")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('salary_tbankset-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tBankSetService.importDiy(file.getInputStream());
}
/**
* 开户行配置表 批量导出
*
* @author hgw
* @date 2023-03-06 11:54:21
**/
@Operation(description = "导出开户行配置表 hasPermission('salary_tbankset-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('salary_tbankset-export')")
public void export(HttpServletResponse response, @RequestBody TBankSetSearchVo searchVo) {
tBankSetService.listExport(response, searchVo);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TBankSet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
@Mapper
public interface TBankSetMapper extends BaseMapper<TBankSet> {
/**
* 开户行配置表简单分页查询
*
* @param tBankSet 开户行配置表
* @return
*/
IPage<TBankSet> getTBankSetPage(Page<TBankSet> page, @Param("tBankSet") TBankSet tBankSet);
List<String> getTBankSetList(@Param("bankName") String bankName);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.salary.entity.TBankSet;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankSetSearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
public interface TBankSetService extends IService<TBankSet> {
/**
* 开户行配置表简单分页查询
* @param tBankSet 开户行配置表
* @return
*/
IPage<TBankSet> getTBankSetPage(Page<TBankSet> page, TBankSetSearchVo tBankSet);
/**
* @param bankName 开户行
* @Description: 获取Map
* @Author: hgw
* @Date: 2023/3/6 15:23
* @return: java.util.Map<java.lang.String, java.lang.String>
**/
Map<String, String> getBankMap(String bankName);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TBankSetSearchVo searchVo);
List<TBankSet> noPageDiy(TBankSetSearchVo searchVo);
}
......@@ -84,6 +84,8 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
private final TSalaryStandardIssueResService tSalaryStandardIssueResService;
private final TBankSetService tBankSetService;
// 缓存信息
private final CacheManager cacheManager;
......@@ -212,9 +214,11 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
}
}
}
Map<String, String> bankMap = tBankSetService.getBankMap(null);
util1.getJsonStringToList(user, vo, dept, configSalary, salaryConfigMap, isMustMap,
empIdCardMap, empNameMap, isDuplicateName, checkListY, invoiceTitle,
employeeService, checkMap, specialMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
employeeService, checkMap, specialMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService, bankMap);
List<TSalaryAccountVo> saList = util1.getEntityList();
if ((null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty())) {
......
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcelFactory;
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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TBankSet;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TBankSetMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TBankSetService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankSetSearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TBankSetVo;
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.HashMap;
import java.util.List;
import java.util.Map;
/**
* 开户行配置表
*
* @author hgw
* @date 2023-03-06 11:54:21
*/
@Log4j2
@Service
public class TBankSetServiceImpl extends ServiceImpl<TBankSetMapper, TBankSet> implements TBankSetService {
/**
* 开户行配置表简单分页查询
*
* @param tBankSet 开户行配置表
* @return
*/
@Override
public IPage<TBankSet> getTBankSetPage(Page<TBankSet> page, TBankSetSearchVo tBankSet) {
return baseMapper.getTBankSetPage(page, tBankSet);
}
/**
* 开户行Map
* @param bankName 开户行
* @return
*/
@Override
public Map<String, String> getBankMap(String bankName) {
List<String> sList = baseMapper.getTBankSetList(bankName);
Map<String, String> bankMap = new HashMap<>();
if (sList != null && !sList.isEmpty()) {
for (String s : sList) {
bankMap.put(s,s);
}
}
return bankMap;
}
/**
* 开户行配置表批量导出
*
* @param searchVo 开户行配置表
* @return
*/
@Override
public void listExport(HttpServletResponse response, TBankSetSearchVo searchVo) {
String fileName = "开户行配置表批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TBankSet> 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, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcelFactory.write(out, TBankSet.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i = i + CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcelFactory.writerSheet("开户行配置表" + index).build();
excelWriter.write(list, writeSheet);
index++;
list.clear();
}
}
} else {
WriteSheet writeSheet = EasyExcelFactory.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<TBankSet> noPageDiy(TBankSetSearchVo searchVo) {
LambdaQueryWrapper<TBankSet> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TBankSet::getId, idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0) {
wrapper.last(" limit " + searchVo.getLimitStart() + "," + searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(TBankSetSearchVo searchVo) {
LambdaQueryWrapper<TBankSet> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TBankSet::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TBankSetSearchVo entity) {
LambdaQueryWrapper<TBankSet> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TBankSet::getCreateTime, entity.getCreateTimes()[0])
.le(TBankSet::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())) {
wrapper.eq(TBankSet::getCreateName, entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TBankSetVo> util1 = new ExcelUtil<>(TBankSetVo.class);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcelFactory.read(inputStream, TBankSetVo.class, new ReadListener<TBankSetVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TBankSetVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TBankSetVo 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());
importTBankSet(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 importTBankSet(List<TBankSetVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TBankSetVo excel = excelVOList.get(i);
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TBankSetVo excel) {
TBankSet insert = new TBankSet();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
}
......@@ -45,6 +45,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprCheckProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryEmployeeMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TBankSetService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryEmployeeService;
import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import com.yifu.cloud.plus.v1.yifu.salary.vo.*;
......@@ -77,6 +78,8 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
@Autowired
private DaprCheckProperties checkProperties;
@Autowired
private TBankSetService tBankSetService;
/**
* 薪酬人员表简单分页查询
*
......@@ -538,6 +541,7 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
// 开户行省市的区域暂存
String areaStr;
boolean curTaxMonth;
Map<String, String> bankMap = tBankSetService.getBankMap(null);
for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i);
if (excel != null) {
......@@ -551,6 +555,10 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
emp.setTaxMonth(excel.getTaxMonth());
}
if (Common.isNotNull(excel.getBankName())) {
if (bankMap.get(emp.getBankName()) == null) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.BANK_NAME_ERROR));
continue;
}
emp.setBankName(excel.getBankName());
}
if (Common.isNotNull(excel.getBankSubName())) {
......@@ -715,6 +723,7 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
List<TSalaryEmployee> saveList = new ArrayList<>();
List<TSalaryEmployee> updateList = new ArrayList<>();
TSettleDomain dept = vo.getDept();
Map<String, String> bankMap = tBankSetService.getBankMap(null);
for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i);
if (excel != null) {
......@@ -740,6 +749,10 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
}
}
if (Common.isNotNull(excel.getBankName())) {
if (bankMap.get(emp.getBankName()) == null) {
errorMessageList.add(new ErrorMessage((i + 2), SalaryConstants.BANK_NAME_ERROR));
continue;
}
emp.setBankName(excel.getBankName());
}
if (Common.isNotNull(excel.getBankSubName())) {
......
......@@ -69,7 +69,7 @@ public class SalaryAccountUtil implements Serializable {
, Map<String, TSalaryEmployee> empIdCardMap, Map<String, TSalaryEmployee> empNameMap, boolean isDuplicateName
, List<String> checkListY, String invoiceTitle, TSalaryEmployeeService tSalaryEmployeeService
, Map<String, Integer> checkMap, Map<String, BigDecimal> specialMap, Map<String, Integer> ownEmployeeMap
, Map<String, Integer> ownDeptMap, TSalaryAccountService tSalaryAccountService) {
, Map<String, Integer> ownDeptMap, TSalaryAccountService tSalaryAccountService, Map<String, String> bankMap) {
String jsonStr = vo.getJsonString();
String salaryType = vo.getSalaryType();
Integer isIssue = vo.getIsIssue();
......@@ -388,7 +388,7 @@ public class SalaryAccountUtil implements Serializable {
if (!notLabour) {
R<TSalaryEmployee> eR = this.getNewEmp(newEmp, i, errorList, notLabour, entity, salaryType, dept, user
, salaryStyle, salaryGiveTimeFlag, invoiceTitle, tSalaryAccountService
, tSalaryEmployeeService);
, tSalaryEmployeeService, bankMap);
if (eR.getCode() != 200) {
continue;
} else {
......@@ -403,7 +403,7 @@ public class SalaryAccountUtil implements Serializable {
if (emp != null) {
if (setEntityByEmpInfo(dept, ownEmployeeMap, ownDeptMap, salaryType, isIssue, errorList
, entity, emp, saiList, salaryGiveTimeFlag, isNewEmployee, empName, salaryStyle
, nowMonth, updateEmpList, checkBankInfoEmpList, i))
, nowMonth, updateEmpList, checkBankInfoEmpList, i, bankMap))
continue;
}
if (saiList != null && !saiList.isEmpty()) {
......@@ -470,7 +470,7 @@ public class SalaryAccountUtil implements Serializable {
if (!this.setNewEmpBase(newEmps, newEmps.getLineNums(), errorList, notLabour
, entity, salaryType, dept, user, entity.getSalaryStyle()
, CommonConstants.ZERO_STRING.equals(entity.getSalaryGiveTime()), invoiceTitle
, entity.getSaiList())) {
, entity.getSaiList(), bankMap)) {
continue;
}
newEmps.setSalaryGiveTime(entity.getSalaryGiveTime());
......@@ -492,7 +492,7 @@ public class SalaryAccountUtil implements Serializable {
, CommonConstants.ZERO_STRING.equals(entity.getSalaryGiveTime())
, CommonConstants.ONE_STRING.equals(entity.getIsNewEmployee())
, otherEmp.getEmpName(), entity.getSalaryStyle()
, nowMonth, updateEmpList, checkBankInfoEmpList, newEmps.getLineNums())) {
, nowMonth, updateEmpList, checkBankInfoEmpList, newEmps.getLineNums(), bankMap)) {
isContinue = false;
}
}
......@@ -539,7 +539,7 @@ public class SalaryAccountUtil implements Serializable {
, Map<String, Integer> ownDeptMap, String salaryType, Integer isIssue, List<ErrorMessage> errorList
, TSalaryAccountVo entity, TSalaryEmployee emp, List<TSalaryAccountItemVo> saiList
, boolean salaryGiveTimeFlag, boolean isNewEmployee, String empName, String salaryStyle, String nowMonth
, List<TSalaryEmployee> updateEmpList, List<TSalaryEmployee> checkBankInfoEmpList, int i) {
, List<TSalaryEmployee> updateEmpList, List<TSalaryEmployee> checkBankInfoEmpList, int i, Map<String, String> bankMap) {
TSalaryAccountItemVo sai;
String error;
if (Common.isEmpty(emp.getEmpName())) {
......@@ -630,6 +630,11 @@ public class SalaryAccountUtil implements Serializable {
errorList.add(new ErrorMessage((i + 2), error));
return true;
}
if (bankMap.get(emp.getBankName()) == null) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行总行-不符合财务要求,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error));
return true;
}
entity.setBankName(emp.getBankName());
entity.setBankNo(emp.getBankNo());
entity.setBankProvince(String.valueOf(emp.getBankProvince()));
......@@ -637,6 +642,11 @@ public class SalaryAccountUtil implements Serializable {
entity.setBankSubName(emp.getBankSubName());
} else {
if (Common.isNotNull(emp.getBankName())) {
if (bankMap.get(emp.getBankName()) == null) {
error = "第" + (i + 2) + SalaryConstants.LINE_EMP + emp.getEmpIdcard() + "-发放方式为银行发放,但是-开户行总行-不符合财务要求,请去薪酬人员查询处更新!";
errorList.add(new ErrorMessage((i + 2), error));
return true;
}
entity.setBankName(emp.getBankName());
} else {
entity.setBankName(null);
......@@ -696,7 +706,7 @@ public class SalaryAccountUtil implements Serializable {
private R<TSalaryEmployee> getNewEmp(TSalaryEmployee newEmp, int i, List<ErrorMessage> errorList, boolean notLabour
, TSalaryAccountVo entity, String salaryType, TSettleDomainSelectVo dept, YifuUser user, String salaryStyle
, boolean salaryGiveTimeFlag, String invoiceTitle, TSalaryAccountService tSalaryAccountService
, TSalaryEmployeeService tSalaryEmployeeService) {
, TSalaryEmployeeService tSalaryEmployeeService, Map<String, String> bankMap) {
String newEmpStr = "新员工";
if (!notLabour) {
newEmpStr = "劳务费";
......@@ -756,6 +766,11 @@ public class SalaryAccountUtil implements Serializable {
errorList.add(new ErrorMessage((i + 2), error));
return R.failed();
} else {
if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error));
return R.failed();
}
newEmp.setBankName(entity.getBankName());
}
if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) {
......@@ -793,6 +808,11 @@ public class SalaryAccountUtil implements Serializable {
}
} else {
if (Common.isNotNull(entity.getBankName())) {
if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error));
return R.failed();
}
newEmp.setBankName(entity.getBankName());
}
if (Common.isNotNull(entity.getBankNo())) {
......@@ -847,7 +867,7 @@ public class SalaryAccountUtil implements Serializable {
private boolean setNewEmpBase(TSalaryEmployee newEmp, int i, List<ErrorMessage> errorList, boolean notLabour
, TSalaryAccountVo entity, String salaryType, TSettleDomainSelectVo dept, YifuUser user, String salaryStyle
, boolean salaryGiveTimeFlag, String invoiceTitle, List<TSalaryAccountItemVo> saiList) {
, boolean salaryGiveTimeFlag, String invoiceTitle, List<TSalaryAccountItemVo> saiList, Map<String, String> bankMap) {
String newEmpStr = "新员工";
if (!notLabour) {
newEmpStr = "劳务费";
......@@ -914,6 +934,11 @@ public class SalaryAccountUtil implements Serializable {
errorList.add(new ErrorMessage((i + 2), error));
return false;
} else {
if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error));
return false;
}
newEmp.setBankName(entity.getBankName());
}
if (Common.isEmpty(entity.getBankProvince()) || Common.isEmpty(entity.getBankCity())) {
......@@ -951,6 +976,11 @@ public class SalaryAccountUtil implements Serializable {
}
} else {
if (Common.isNotNull(entity.getBankName())) {
if (bankMap.get(entity.getBankName()) == null) {
error = "第" + (i + 2) + "行:" + newEmpStr + "-开户行总行-不符合财务要求,请去【开户行配置】菜单查询!";
errorList.add(new ErrorMessage((i + 2), error));
return false;
}
newEmp.setBankName(entity.getBankName());
}
if (Common.isNotNull(entity.getBankNo())) {
......
......@@ -184,6 +184,7 @@ public class SalaryConstants {
public static final String DATA_MUST = "未获取到表格数据!";
public static final String ID_CARD_MUST = "身份证不可为空!";
public static final String NOT_HAVE_EMP = "根据身份证、项目编码未找到人员!";
public static final String BANK_NAME_ERROR = "开户行总行错误,不符合财务要求,请查询开户行配置!";
public static final String PROVINCE_ERROR = "开户行省错误!";
public static final String CITY_ERROR = "开户行市错误!";
public static final String CUR_TAX_INFO = "当前项目薪酬人员已维护计税月份,计税月份沿用系统原值,其他字段已更新!";
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TBankSetMapper">
<resultMap id="tBankSetMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TBankSet">
<id property="id" column="ID"/>
<result property="bankName" column="BANK_NAME"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.BANK_NAME,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
</sql>
<sql id="tBankSet_where">
<if test="tBankSet != null">
<if test="tBankSet.id != null and tBankSet.id.trim() != ''">
AND a.ID = #{tBankSet.id}
</if>
<if test="tBankSet.bankName != null and tBankSet.bankName.trim() != ''">
AND a.BANK_NAME = #{tBankSet.bankName}
</if>
<if test="tBankSet.createBy != null and tBankSet.createBy.trim() != ''">
AND a.CREATE_BY = #{tBankSet.createBy}
</if>
<if test="tBankSet.createName != null and tBankSet.createName.trim() != ''">
AND a.CREATE_NAME = #{tBankSet.createName}
</if>
<if test="tBankSet.createTime != null">
AND a.CREATE_TIME = #{tBankSet.createTime}
</if>
<if test="tBankSet.updateBy != null and tBankSet.updateBy.trim() != ''">
AND a.UPDATE_BY = #{tBankSet.updateBy}
</if>
<if test="tBankSet.updateTime != null">
AND a.UPDATE_TIME = #{tBankSet.updateTime}
</if>
</if>
</sql>
<!--tBankSet简单分页查询-->
<select id="getTBankSetPage" resultMap="tBankSetMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_bank_set a
<where>
1=1
<include refid="tBankSet_where"/>
</where>
order by a.CREATE_TIME desc
</select>
<!--list-->
<select id="getTBankSetList" resultType="java.lang.String">
SELECT
a.BANK_NAME
FROM t_bank_set a
<if test="bankName != null and bankName.trim() != ''">
where a.BANK_NAME = #{bankName}
</if>
order by a.CREATE_TIME desc
</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