Merge branch 'feature/V3-taxAgentsAddImport-0112' into release/2.5.3.2301.01
This commit is contained in:
commit
2b3752a554
|
|
@ -0,0 +1,57 @@
|
|||
package com.engine.salary.entity.salarysob.dto;
|
||||
|
||||
import com.cloudstore.eccom.pc.table.WeaTableType;
|
||||
import com.engine.salary.annotation.SalaryTable;
|
||||
import com.engine.salary.annotation.SalaryTableColumn;
|
||||
import com.engine.salary.annotation.SalaryTableOperate;
|
||||
import com.engine.salary.annotation.TableTitle;
|
||||
import com.engine.salary.util.excel.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/09 13:42
|
||||
* @description 薪资账套-人员范围-导入
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SalaryTable(pageId = "a4f85287-e3f9-6614-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = {
|
||||
@SalaryTableOperate(text = "查看明细")
|
||||
})
|
||||
public class SalarySobRangeImportListDTO {
|
||||
|
||||
//主键id
|
||||
@SalaryTableColumn(column = "id", display = false)
|
||||
private Long id;
|
||||
|
||||
//姓名
|
||||
@SalaryTableColumn(text = "姓名", width = "10%", column = "username")
|
||||
@TableTitle(title = "姓名", dataIndex = "username", key = "username")
|
||||
@ExcelProperty(index = 0)
|
||||
private String username;
|
||||
|
||||
|
||||
//部门
|
||||
@SalaryTableColumn(text = "部门", width = "10%", column = "departmentName")
|
||||
@TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName")
|
||||
@ExcelProperty(index = 1)
|
||||
private String departmentName;
|
||||
|
||||
//手机号
|
||||
@SalaryTableColumn(text = "手机号", width = "10%", column = "mobile")
|
||||
@TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile")
|
||||
@ExcelProperty(index = 2)
|
||||
private String mobile;
|
||||
|
||||
//工号
|
||||
@SalaryTableColumn(text = "工号", width = "10%", column = "jobNum")
|
||||
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
|
||||
@ExcelProperty(index = 3)
|
||||
private String jobNum;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.engine.salary.entity.salarysob.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/09 13:35
|
||||
* @description 薪资账套人员范围导入参数
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SalarySobRangeImportParam {
|
||||
|
||||
//上传文件id
|
||||
String imageId;
|
||||
|
||||
//薪资账套id
|
||||
String salarySobId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.engine.salary.entity.taxagent.dto;
|
||||
|
||||
import com.cloudstore.eccom.pc.table.WeaTableType;
|
||||
import com.engine.salary.annotation.SalaryTable;
|
||||
import com.engine.salary.annotation.SalaryTableColumn;
|
||||
import com.engine.salary.annotation.SalaryTableOperate;
|
||||
import com.engine.salary.annotation.TableTitle;
|
||||
import com.engine.salary.util.excel.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/06 10:48
|
||||
* @description 个税扣缴义务人-人员范围
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SalaryTable(pageId = "a4f85287-e3f9-6614-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = {
|
||||
@SalaryTableOperate(text = "查看明细")
|
||||
})
|
||||
public class TaxAgentManageRangeEmployeeListDTO {
|
||||
|
||||
//主键id
|
||||
@SalaryTableColumn(column = "id", display = false)
|
||||
private Long id;
|
||||
|
||||
//员工id
|
||||
private Long employeeId;
|
||||
|
||||
//姓名
|
||||
@SalaryTableColumn(text = "姓名", width = "10%", column = "username")
|
||||
@TableTitle(title = "姓名", dataIndex = "username", key = "username")
|
||||
@ExcelProperty(index = 0)
|
||||
private String username;
|
||||
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人id
|
||||
*/
|
||||
private Long taxAgentId;
|
||||
|
||||
//部门
|
||||
@SalaryTableColumn(text = "部门", width = "10%", column = "departmentName")
|
||||
@TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName")
|
||||
@ExcelProperty(index = 1)
|
||||
private String departmentName;
|
||||
|
||||
//手机号
|
||||
@SalaryTableColumn(text = "手机号", width = "10%", column = "mobile")
|
||||
@TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile")
|
||||
@ExcelProperty(index = 2)
|
||||
private String mobile;
|
||||
|
||||
//工号
|
||||
@SalaryTableColumn(text = "工号", width = "10%", column = "jobNum")
|
||||
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
|
||||
@ExcelProperty(index = 3)
|
||||
private String jobNum;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.engine.salary.entity.taxagent.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/06 9:48
|
||||
* @description 个税扣缴义务人人员范围导入
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaxAgentImportParam {
|
||||
|
||||
//上传文件id
|
||||
String imageId;
|
||||
|
||||
//个税扣缴义务人
|
||||
Long taxAgentId;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.engine.salary.entity.taxagent.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/05 14:39
|
||||
* @description 个税扣缴义务人的人员范围导入模板参数
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class TaxAgentRangeDownloadTemplateParam {
|
||||
/**
|
||||
* 个税扣缴义务人的id
|
||||
*/
|
||||
private Long taxAgentId;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.enums.salarysob;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.engine.salary.enums.BaseEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -87,4 +88,32 @@ public enum SalaryEmployeeStatusEnum implements BaseEnum<Integer> {
|
|||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取所有人员状态的value值的list
|
||||
* @return List<String>
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 14:34
|
||||
*/
|
||||
public static List<String> getAllSalaryEmployeeStatusValues() {
|
||||
List<String> values = new ArrayList<>();
|
||||
for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) {
|
||||
values.add(ObjectUtil.toString(statusEnum.getValue()));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
// /***
|
||||
// * @description 获取所有人员状态value,返回string格式用”,“间隔
|
||||
// * @return List<String>
|
||||
// * @author Harryxzy
|
||||
// * @date 2023/1/9 14:35
|
||||
// */
|
||||
// public static String getAllSalaryEmployeeStatusValuesStr() {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) {
|
||||
// sb.append(statusEnum.getValue());
|
||||
// }
|
||||
// return sb.toString();
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeImportParam;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 薪资账套人员范围
|
||||
|
|
@ -79,4 +82,28 @@ public interface SalarySobRangeService {
|
|||
* @param item
|
||||
*/
|
||||
void updateEmployeeStatuses(SalarySobRangePO item);
|
||||
|
||||
/***
|
||||
* @description 下载人员范围导入模板
|
||||
* @return XSSFWorkbook
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 11:34
|
||||
*/
|
||||
XSSFWorkbook downloadTemplateRange();
|
||||
|
||||
/***
|
||||
* @description 人员范围导入预览
|
||||
* @return Map<String,Object>
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 13:39
|
||||
*/
|
||||
Map<String, Object> preview(SalarySobRangeImportParam importParam);
|
||||
|
||||
/**
|
||||
* @description 导入薪资账套人员范围
|
||||
* @return Map<String,Object>
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 14:10
|
||||
*/
|
||||
Map<String, Object> importData(SalarySobRangeImportParam importParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentImportParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentRangeDownloadTemplateParam;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/05 15:10
|
||||
* @description
|
||||
*/
|
||||
public interface TaxAgentExcelService {
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*
|
||||
* @param downloadTemplateParam
|
||||
* @param currentEmployeeId
|
||||
*/
|
||||
XSSFWorkbook downloadTemplateRange(TaxAgentRangeDownloadTemplateParam downloadTemplateParam, int currentEmployeeId);
|
||||
|
||||
/**
|
||||
* 预览
|
||||
* @param taxAgentImportParam
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> preview(TaxAgentImportParam taxAgentImportParam);
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentImportParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentRangeQueryParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminRangeQueryParam;
|
||||
|
|
@ -9,6 +10,7 @@ import com.engine.salary.util.page.PageInfo;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人的管理范围
|
||||
|
|
@ -69,4 +71,10 @@ public interface TaxAgentManageRangeService {
|
|||
void deleteByTaxAgentIds(Collection<Long> taxAgentIds);
|
||||
|
||||
void syncManageRange(List<Long> taxAgentIds,String index);
|
||||
|
||||
/**
|
||||
* 人员范围导入
|
||||
* @param taxAgentImportParam
|
||||
*/
|
||||
Map<String, Object> importData(TaxAgentImportParam taxAgentImportParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,57 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.hrm.biz.OrganizationShowSetBiz;
|
||||
import com.engine.salary.biz.EmployBiz;
|
||||
import com.engine.salary.biz.SalarySobRangeBiz;
|
||||
import com.engine.salary.biz.SpecialAddDeductionBiz;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.hrm.DeptInfo;
|
||||
import com.engine.salary.entity.hrm.PositionInfo;
|
||||
import com.engine.salary.entity.hrm.SubCompanyInfo;
|
||||
import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO;
|
||||
import com.engine.salary.entity.salarysob.bo.SalarySobRangeSaveBO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobRangeImportListDTO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeImportParam;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
||||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
||||
import com.engine.salary.enums.salarysob.TargetTypeEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
||||
import com.engine.salary.service.SalaryEmployeeService;
|
||||
import com.engine.salary.service.SalarySobRangeService;
|
||||
import com.engine.salary.service.SalarySobService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.excel.ExcelComment;
|
||||
import com.engine.salary.util.excel.ExcelParseHelper;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
import com.engine.salary.util.valid.ValidUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -52,6 +74,17 @@ public class SalarySobRangeServiceImpl extends Service implements SalarySobRange
|
|||
return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private TaxAgentService getTaxAgentService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalarySysConfMapper getSalarySysConfMapper() {
|
||||
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
||||
}
|
||||
|
||||
// private ComInfoCache comInfoCache;
|
||||
// private LoggerTemplate salarySobLoggerTemplate;
|
||||
|
|
@ -200,4 +233,230 @@ public class SalarySobRangeServiceImpl extends Service implements SalarySobRange
|
|||
public void updateEmployeeStatuses(SalarySobRangePO item) {
|
||||
salarySobRangeBiz.updateEmployeeStatuses(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook downloadTemplateRange() {
|
||||
//获取操作按钮资源
|
||||
List<List<Object>> rowList = getExcelRowList();
|
||||
//查询对于人员信息导入筛选的全局配置
|
||||
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
||||
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
||||
// 注释
|
||||
List<ExcelComment> excelComments = Lists.newArrayList();
|
||||
if(salarySysConfPO.getConfValue().equals("1")){
|
||||
// 人员校验规则为工号
|
||||
excelComments.add(new ExcelComment(3, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
||||
}else {
|
||||
excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
||||
}
|
||||
|
||||
//获取excel
|
||||
return ExcelUtil.genWorkbookV2(rowList, "薪资账套人员范围", excelComments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> importData(SalarySobRangeImportParam importParam) {
|
||||
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
|
||||
long currentEmployeeId = user.getUID();
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz();
|
||||
|
||||
//查询对于人员信息导入筛选的全局配置
|
||||
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
||||
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
||||
|
||||
//检验参数
|
||||
checkImportParam(importParam);
|
||||
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(importParam.getImageId());
|
||||
//薪资账套ID
|
||||
String salarySobIdStr = Util.null2String(importParam.getSalarySobId());
|
||||
Long salarySobId = SalaryEntityUtil.string2Long(salarySobIdStr);
|
||||
|
||||
// 查询薪资账套
|
||||
SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId);
|
||||
if (Objects.isNull(salarySobPO)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
||||
}
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
List<SalarySobRangeImportListDTO> salarySobRangeImportLists = ExcelParseHelper.parse2Map(fileInputStream, SalarySobRangeImportListDTO.class, 0, 1, 4, "SpecialAddDeductionTemplate.xlsx");
|
||||
|
||||
int total = salarySobRangeImportLists.size();
|
||||
int index = 0;
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
//人员信息
|
||||
List<DataCollectionEmployee> employees = employBiz.listEmployee();
|
||||
// 获取所有个税扣缴义务人
|
||||
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
||||
// 错误excel内容
|
||||
List<Map> errorData = new ArrayList<>();
|
||||
//合规数据
|
||||
List<SalarySobRangeSaveParam.SalarySobRangeTargetParam> eligibleData = new ArrayList<>();
|
||||
for (int i = 0; i < salarySobRangeImportLists.size(); i++) {
|
||||
SalarySobRangeImportListDTO dto = salarySobRangeImportLists.get(i);
|
||||
|
||||
//待插入数据库对象
|
||||
SalarySobRangeSaveParam.SalarySobRangeTargetParam po = new SalarySobRangeSaveParam.SalarySobRangeTargetParam();
|
||||
po.setTargetType(TargetTypeEnum.EMPLOYEE);
|
||||
|
||||
//异常点数量
|
||||
int errorSum = 0;
|
||||
|
||||
//行号
|
||||
String rowIndex = String.format("第%s行", i + 2);
|
||||
|
||||
//相同的姓名
|
||||
String userName = dto.getUsername();
|
||||
String deparmentName = dto.getDepartmentName();
|
||||
String mobile = dto.getMobile();
|
||||
String workcode = dto.getJobNum();
|
||||
List<Long> employeeSameIds = new ArrayList<>();
|
||||
|
||||
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
||||
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user)
|
||||
.matchImportEmployee(employees, userName, deparmentName, mobile, workcode, null);
|
||||
//含在职和离职,选在职数据
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
||||
employeeSameIds = emps.stream()
|
||||
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
||||
employeeSameIds = emps.stream()
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
||||
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
||||
//姓名 不能为空
|
||||
//错误消息对象
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else {
|
||||
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
||||
if (employeeId != null && employeeId > 0) {
|
||||
po.setTargetId(employeeId);
|
||||
} else {
|
||||
//姓名错误,系统内不存在该姓名
|
||||
Map<String, String> errorMessageMap = new HashMap<>();
|
||||
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
}
|
||||
}
|
||||
//fixme 分权判断
|
||||
if (errorSum == 0) {
|
||||
successCount += 1;
|
||||
// 合格数据
|
||||
eligibleData.add(po);
|
||||
} else {
|
||||
errorCount += 1;
|
||||
// 添加错误数据
|
||||
}
|
||||
}
|
||||
|
||||
// 入库
|
||||
eligibleData = handleImportData(eligibleData);
|
||||
// 查询已有的人员范围
|
||||
List<SalarySobRangePO> salarySobRangePOS = listBySalarySobIdAndIncludeType(salarySobId, 1);
|
||||
SalarySobRangeSaveParam saveParam = new SalarySobRangeSaveParam();
|
||||
saveParam.setTargetParams(eligibleData);
|
||||
saveParam.setEmployeeStatus( SalaryEmployeeStatusEnum.values());
|
||||
saveParam.setIncludeType(1);
|
||||
saveParam.setSalarySobId(salarySobId);
|
||||
// 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新)
|
||||
SalarySobRangeSaveBO.Result result = SalarySobRangeSaveBO.handle(salarySobRangePOS, saveParam, (long) user.getUID());
|
||||
// 保存
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobRanges())) {
|
||||
salarySobRangeBiz.batchInsert(result.getNeedInsertSalarySobRanges());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedUpdateSalarySobRanges())) {
|
||||
result.getNeedUpdateSalarySobRanges().forEach(e -> salarySobRangeBiz.updateById(e));
|
||||
}
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", errorCount);
|
||||
apidatas.put("errorData", errorData);
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
// 处理导入数据
|
||||
private List<SalarySobRangeSaveParam.SalarySobRangeTargetParam> handleImportData(List<SalarySobRangeSaveParam.SalarySobRangeTargetParam> pos) {
|
||||
if (CollectionUtils.isEmpty(pos)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos);
|
||||
// 去重(通过记录的唯一条件(人员id)
|
||||
List<SalarySobRangeSaveParam.SalarySobRangeTargetParam> finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTargetId() ))), ArrayList::new));
|
||||
return finalPos;
|
||||
}
|
||||
|
||||
private void checkImportParam(SalarySobRangeImportParam importParam) {
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(importParam.getImageId());
|
||||
|
||||
if (StringUtils.isBlank(imageId)) {
|
||||
throw new SalaryRunTimeException("文件不存在");
|
||||
}
|
||||
if (StringUtils.isBlank(importParam.getSalarySobId())) {
|
||||
throw new SalaryRunTimeException("薪资账套ID为空");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> preview(SalarySobRangeImportParam importParam) {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(importParam.getImageId());
|
||||
Validate.notBlank(imageId, "imageId为空");
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
List<SalarySobRangeImportListDTO> salarySobRangeImportList = ExcelParseHelper.parse2Map(fileInputStream, SalarySobRangeImportListDTO.class, 0, 1, 4, "TaxAgentEmployee.xlsx");
|
||||
apidatas.put("preview", salarySobRangeImportList);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 获取excel数据行
|
||||
* @return List<List<String>>
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 11:37
|
||||
*/
|
||||
private List<List<Object>> getExcelRowList() {
|
||||
// 表头
|
||||
List<Object> headers = Lists.newArrayList();
|
||||
headers.add(SalaryI18nUtil.getI18nLabel( 85429, "姓名"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel( 86185, "部门"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
||||
List<List<Object>> rowList = new ArrayList<>();
|
||||
rowList.add(headers);
|
||||
return rowList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeListDTO;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentImportParam;
|
||||
import com.engine.salary.entity.taxagent.param.TaxAgentRangeDownloadTemplateParam;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.service.TaxAgentExcelService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.excel.ExcelComment;
|
||||
import com.engine.salary.util.excel.ExcelParseHelper;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Harryxzy
|
||||
* @date 2023/01/05 15:11
|
||||
* @description
|
||||
*/
|
||||
public class TaxAgentExcelServiceImpl extends Service implements TaxAgentExcelService {
|
||||
|
||||
public TaxAgentService getTaxAgentService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook downloadTemplateRange(TaxAgentRangeDownloadTemplateParam downloadTemplateParam, int currentEmployeeId) {
|
||||
// 没有传递TaxAgentId就是当前登录人能够导入自己所能管理的个税扣缴义务人
|
||||
TaxAgentPO taxAgent = downloadTemplateParam.getTaxAgentId() == null ? null : getTaxAgentService(user).getById(downloadTemplateParam.getTaxAgentId());
|
||||
//获取操作按钮资源
|
||||
List<List<Object>> rowList = getExcelRowList(taxAgent);
|
||||
// 注释
|
||||
List<ExcelComment> excelComments = Lists.newArrayList();
|
||||
excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
||||
//获取excel
|
||||
return ExcelUtil.genWorkbookV2(rowList, "个税扣缴义务人人员范围", excelComments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> preview(TaxAgentImportParam importParam) {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(importParam.getImageId());
|
||||
Validate.notBlank(imageId, "imageId为空");
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
List<TaxAgentManageRangeEmployeeListDTO> taxAgentManageRangeEmployees = ExcelParseHelper.parse2Map(fileInputStream, TaxAgentManageRangeEmployeeListDTO.class, 0, 1, 4, "TaxAgentEmployee.xlsx");
|
||||
apidatas.put("preview", taxAgentManageRangeEmployees);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取excel数据行
|
||||
* @return List<List<String>>
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/5 15:47
|
||||
*/
|
||||
private List<List<Object>> getExcelRowList(TaxAgentPO taxAgent) {
|
||||
// 表头
|
||||
List<Object> headers = Lists.newArrayList();
|
||||
if (taxAgent == null) {
|
||||
headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"));
|
||||
}
|
||||
headers.add(SalaryI18nUtil.getI18nLabel( 85429, "姓名"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel( 86185, "部门"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
||||
headers.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
|
||||
List<List<Object>> rowList = new ArrayList<>();
|
||||
rowList.add(headers);
|
||||
return rowList;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
||||
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
|
|
@ -10,34 +11,42 @@ import com.engine.salary.entity.hrm.HrmStatus;
|
|||
import com.engine.salary.entity.hrm.PositionInfo;
|
||||
import com.engine.salary.entity.hrm.SubCompanyInfo;
|
||||
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeListDTO;
|
||||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
|
||||
import com.engine.salary.entity.taxagent.param.*;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.enums.UserStatusEnum;
|
||||
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
||||
import com.engine.salary.enums.salarysob.TargetTypeEnum;
|
||||
import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.datacollection.EmployMapper;
|
||||
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
||||
import com.engine.salary.mapper.taxagent.TaxAgentManageRangeMapper;
|
||||
import com.engine.salary.service.SalaryArchiveService;
|
||||
import com.engine.salary.service.TaxAgentEmpService;
|
||||
import com.engine.salary.service.TaxAgentManageRangeService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.engine.salary.util.excel.ExcelParseHelper;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.weaver.util.threadPool.ThreadPoolUtil;
|
||||
import com.weaver.util.threadPool.entity.LocalRunnable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
|
@ -77,6 +86,13 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
|
|||
return MapperProxyFactory.getProxy(EmployMapper.class);
|
||||
}
|
||||
|
||||
private SalarySysConfMapper getSalarySysConfMapper() {
|
||||
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
||||
}
|
||||
|
||||
private SalaryEmployeeService getSalaryEmployeeService() {
|
||||
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private EmployBiz employBiz = new EmployBiz();
|
||||
|
||||
|
|
@ -304,7 +320,7 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
|
|||
result.getNeedInsertTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().insertIgnoreNull(range));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) {
|
||||
result.getNeedInsertTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().updateIgnoreNull(range));
|
||||
result.getNeedUpdateTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().updateIgnoreNull(range));
|
||||
}
|
||||
|
||||
/* 同步本地人员范围的关联人员=========================== */
|
||||
|
|
@ -519,4 +535,214 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
|
|||
ThreadPoolUtil.execute(localRunnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
* @param taxAgentImportParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> importData(TaxAgentImportParam taxAgentImportParam) {
|
||||
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
long currentEmployeeId = user.getUID();
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
|
||||
//查询对于人员信息导入筛选的全局配置
|
||||
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
||||
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
||||
|
||||
//检验参数
|
||||
checkImportParam(taxAgentImportParam);
|
||||
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(taxAgentImportParam.getImageId());
|
||||
Validate.notBlank(imageId, "imageId为空");
|
||||
//个税扣缴义务人
|
||||
Long taxAgentId = taxAgentImportParam.getTaxAgentId();
|
||||
TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId);
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
List<TaxAgentManageRangeEmployeeListDTO> rangeEmployees = ExcelParseHelper.parse2Map(fileInputStream, TaxAgentManageRangeEmployeeListDTO.class, 0, 1, 4, "TaxAgentEmployee.xlsx");
|
||||
|
||||
int total = rangeEmployees.size();
|
||||
int index = 0;
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
//人员信息
|
||||
List<DataCollectionEmployee> employees = employBiz.listEmployee();
|
||||
|
||||
// 错误excel内容
|
||||
List<Map> errorData = new ArrayList<>();
|
||||
//合规数据
|
||||
List<TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam> eligibleData = new ArrayList<>();
|
||||
// 全部员工状态
|
||||
Set<String> allEmployeeStatuses = new HashSet<>();
|
||||
allEmployeeStatuses.addAll(SalaryEmployeeStatusEnum.getAllSalaryEmployeeStatusValues());
|
||||
|
||||
TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam();
|
||||
taxAgentRangeSaveParam.setTaxAgentId(taxAgentId);
|
||||
taxAgentRangeSaveParam.setIncludeType(1);
|
||||
taxAgentRangeSaveParam.setSync(true);
|
||||
taxAgentRangeSaveParam.setEmployeeStatus(allEmployeeStatuses);
|
||||
|
||||
for (int i = 0; i < rangeEmployees.size(); i++) {
|
||||
TaxAgentManageRangeEmployeeListDTO dto = rangeEmployees.get(i);
|
||||
//待插入数据库对象
|
||||
TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam po = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam();
|
||||
po.setTargetType(TargetTypeEnum.EMPLOYEE);
|
||||
|
||||
//异常点数量
|
||||
int errorSum = 0;
|
||||
|
||||
//行号
|
||||
String rowIndex = String.format("第%s行", i + 2);
|
||||
|
||||
//相同的姓名
|
||||
String userName = dto.getUsername();
|
||||
String deparmentName = dto.getDepartmentName();
|
||||
String mobile = dto.getMobile();
|
||||
String workcode = dto.getJobNum();
|
||||
List<Long> employeeSameIds = new ArrayList<>();
|
||||
|
||||
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
||||
List<DataCollectionEmployee> emps = getSalaryEmployeeService()
|
||||
.matchImportEmployee(employees, userName, deparmentName, mobile, workcode, null);
|
||||
if (CollectionUtils.isNotEmpty(emps)) {
|
||||
employeeSameIds = emps.stream()
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//含在职和离职,选在职数据
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
||||
employeeSameIds = emps.stream()
|
||||
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
||||
employeeSameIds = emps.stream()
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
||||
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
||||
//姓名 不能为空
|
||||
//错误消息对象
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else {
|
||||
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
||||
if (employeeId != null && employeeId > 0) {
|
||||
po.setTargetId(employeeId);
|
||||
} else {
|
||||
//姓名错误,系统内不存在该姓名
|
||||
Map<String, String> errorMessageMap = new HashMap<>();
|
||||
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Objects.isNull(taxAgent)) {
|
||||
//个税扣缴义务人不存在
|
||||
Map<String, String> errorMessageMap = new HashMap<>();
|
||||
errorMessageMap.put("message","个税扣缴义务人不存在或不在权限范围内");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
}
|
||||
|
||||
//fixme 分权判断
|
||||
if (errorSum == 0) {
|
||||
successCount += 1;
|
||||
// 合格数据
|
||||
eligibleData.add(po);
|
||||
} else {
|
||||
errorCount += 1;
|
||||
// 添加错误数据
|
||||
}
|
||||
}
|
||||
|
||||
//入库-----------------start
|
||||
eligibleData = handleImportData(eligibleData);
|
||||
taxAgentRangeSaveParam.setTargetParams(eligibleData);
|
||||
// 查询已有的管理范围
|
||||
List<TaxAgentManageRangePO> taxAgentManageAllRanges = listByTaxAgentId(taxAgentId);
|
||||
List<TaxAgentManageRangePO> taxAgentManageRanges = taxAgentManageAllRanges.stream().filter(f -> f.getIncludeType().equals(taxAgentRangeSaveParam.getIncludeType())).collect(Collectors.toList());
|
||||
// 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新)
|
||||
TaxAgentBO.Result result = TaxAgentBO.handleTaxAgentRange(taxAgentManageRanges, taxAgentRangeSaveParam, taxAgent.getId(), (long) user.getUID());
|
||||
|
||||
/* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================start */
|
||||
List<TaxAgentManageRangePO> allRanges = Lists.newArrayList(taxAgentManageAllRanges);
|
||||
allRanges.addAll(result.getNeedInsertTaxAgentManageRanges());
|
||||
allRanges.addAll(result.getNeedUpdateTaxAgentManageRanges());
|
||||
// 去重
|
||||
allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))), ArrayList::new));
|
||||
|
||||
List<DataCollectionEmployee> salaryEmployees = getEmployMapper().listAll();
|
||||
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allRanges, salaryEmployees);
|
||||
|
||||
/* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================end */
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) {
|
||||
result.getNeedInsertTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().insertIgnoreNull(range));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) {
|
||||
result.getNeedInsertTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().updateIgnoreNull(range));
|
||||
}
|
||||
|
||||
/* 同步本地人员范围的关联人员=========================== */
|
||||
if (taxAgentRangeSaveParam.isSync()) {
|
||||
//同步执行
|
||||
syncLocalEmp(taxAgentId, allSalaryEmployees, null);
|
||||
} else {
|
||||
taskExecutor.execute(() -> {
|
||||
syncLocalEmp(taxAgentId, allSalaryEmployees, null);
|
||||
});
|
||||
}
|
||||
//-----------------end
|
||||
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", errorCount);
|
||||
apidatas.put("errorData", errorData);
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
// 处理导入数据
|
||||
private List<TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam> handleImportData(List<TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam> pos) {
|
||||
if (CollectionUtils.isEmpty(pos)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos);
|
||||
// 去重(通过记录的唯一条件(人员id)
|
||||
List<TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam> finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTargetId() ))), ArrayList::new));
|
||||
return finalPos;
|
||||
}
|
||||
|
||||
private void checkImportParam(TaxAgentImportParam importParam) {
|
||||
//excel文件id
|
||||
String imageId = Util.null2String(importParam.getImageId());
|
||||
|
||||
if (StringUtils.isBlank(imageId)) {
|
||||
throw new SalaryRunTimeException("文件不存在");
|
||||
}
|
||||
Long taxAgentId = importParam.getTaxAgentId();
|
||||
if(Objects.isNull(taxAgentId)){
|
||||
throw new SalaryRunTimeException("个税扣缴义务人为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
|||
import com.engine.salary.entity.salarysob.dto.*;
|
||||
import com.engine.salary.entity.salarysob.param.*;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
|
|
@ -15,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -23,9 +25,15 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 薪资账套
|
||||
|
|
@ -196,6 +204,70 @@ public class SalarySobController {
|
|||
return new ResponseResult<Collection<Long>, String>(user).run(getSalarySobRangeWrapper(user)::delete, ids);
|
||||
}
|
||||
|
||||
/***
|
||||
* @description 下载薪资账套人员范围导入模板
|
||||
* @return Response
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 11:10
|
||||
*/
|
||||
@GET
|
||||
@Path("/range/downloadTemplate")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response downloadSobRangeTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salarySobId") Long salarySobId) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
SalarySobPO salarySobPO = Objects.isNull(salarySobId) ? null : getSalarySobWrapper(user).getSalarySobService(user).getById(salarySobId);
|
||||
if(Objects.isNull(salarySobPO)){
|
||||
throw new SalaryRunTimeException("薪资账套不存在或已被删除");
|
||||
}
|
||||
try {
|
||||
XSSFWorkbook workbook = getSalarySobRangeWrapper(user).exportImportTemplate();
|
||||
String time = LocalDate.now().toString();
|
||||
String fileName = salarySobPO.getName() + "人员范围导入模板" + time ;
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
StreamingOutput output = outputStream -> {
|
||||
workbook.write(outputStream);
|
||||
outputStream.flush();
|
||||
};
|
||||
response.setContentType("application/octet-stream");
|
||||
return Response.ok(output).
|
||||
header("Content-disposition", "attachment;filename=" + fileName).
|
||||
header("Cache-Control", "no-cache").build();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 薪资账套人员范围导入预览
|
||||
* @return String
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 13:32
|
||||
*/
|
||||
@POST
|
||||
@Path("/range/preview")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeImportParam importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalarySobRangeImportParam, Map<String, Object>>(user).run(getSalarySobRangeWrapper(user)::preview, importParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 薪资账套人员范围导入
|
||||
* @return String
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 13:32
|
||||
*/
|
||||
@POST
|
||||
@Path("/range/importData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String importData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeImportParam importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalarySobRangeImportParam, Map<String, Object>>(user).run(getSalarySobRangeWrapper(user)::importData, importParam);
|
||||
}
|
||||
|
||||
/**********************************薪资账套的人员范围 end*********************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeFormDTO;
|
|||
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
|
||||
import com.engine.salary.entity.taxagent.param.*;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentBasePO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.wrapper.TaxAgentBaseWrapper;
|
||||
import com.engine.salary.wrapper.TaxAgentSubAdminWrapper;
|
||||
import com.engine.salary.wrapper.TaxAgentWrapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -21,10 +23,12 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
public class TaxAgentController {
|
||||
|
||||
|
|
@ -258,6 +262,66 @@ public class TaxAgentController {
|
|||
return new ResponseResult<Collection<Long>, String>(user).run(getTaxAgentWrapper(user)::deleteRange, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载人员范围导入模板
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/range/downloadTemplate")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response downloadTemplateRange(@Context HttpServletRequest request, @Context HttpServletResponse response ,@QueryParam(value = "taxAgentId") Long taxAgentId) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
TaxAgentPO taxAgent = taxAgentId == null ? null : getTaxAgentWrapper(user).getTaxAgentService(user).getById(taxAgentId);
|
||||
TaxAgentRangeDownloadTemplateParam build = TaxAgentRangeDownloadTemplateParam.builder().taxAgentId(taxAgentId).build();
|
||||
XSSFWorkbook workbook = getTaxAgentWrapper(user).exportImportTemplate(build);
|
||||
String time = LocalDate.now().toString();
|
||||
String fileName = Objects.isNull(taxAgent) ? "人员范围导入模板" + time : taxAgent.getName() + "人员范围导入模板" + time;
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
StreamingOutput output = outputStream -> {
|
||||
workbook.write(outputStream);
|
||||
outputStream.flush();
|
||||
};
|
||||
response.setContentType("application/octet-stream");
|
||||
return Response.ok(output).
|
||||
header("Content-disposition", "attachment;filename=" + fileName).
|
||||
header("Cache-Control", "no-cache").build();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览人员范围导入模板
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/range/preview")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentImportParam importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<TaxAgentImportParam, Map<String, Object>>(user).run(getTaxAgentWrapper(user)::preview, importParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人人员范围导入
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/range/importData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String importEmployeeRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentImportParam importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<TaxAgentImportParam, Map<String, Object>>(user).run(getTaxAgentWrapper(user)::importData, importParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人下拉列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,15 +3,18 @@ package com.engine.salary.wrapper;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeImportParam;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam;
|
||||
import com.engine.salary.service.SalarySobRangeService;
|
||||
import com.engine.salary.service.impl.SalarySobRangeServiceImpl;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 薪资账套的人员范围
|
||||
|
|
@ -73,4 +76,34 @@ public class SalarySobRangeWrapper extends Service {
|
|||
public void delete(Collection<Long> ids) {
|
||||
getSalarySobRangeService(user).deleteByIds(ids);
|
||||
}
|
||||
|
||||
/***
|
||||
* @description 下载薪资账套人员范围导入模板
|
||||
* @return XSSFWorkbook
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 11:32
|
||||
*/
|
||||
public XSSFWorkbook exportImportTemplate() {
|
||||
return getSalarySobRangeService(user).downloadTemplateRange();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 薪资账套人员范围导入预览
|
||||
* @return void
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 13:37
|
||||
*/
|
||||
public Map<String, Object> preview(SalarySobRangeImportParam importParam) {
|
||||
return getSalarySobRangeService(user).preview(importParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 导入薪资账套人员范围
|
||||
* @return Map<String,Object>
|
||||
* @author Harryxzy
|
||||
* @date 2023/1/9 14:10
|
||||
*/
|
||||
public Map<String, Object> importData(SalarySobRangeImportParam importParam) {
|
||||
return getSalarySobRangeService(user).importData(importParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import java.util.stream.Collectors;
|
|||
public class SalarySobWrapper extends Service {
|
||||
|
||||
|
||||
private SalarySobService getSalarySobService(User user) {
|
||||
public SalarySobService getSalarySobService(User user) {
|
||||
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
|
|||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
|
@ -60,6 +61,12 @@ public class TaxAgentWrapper extends Service {
|
|||
return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public TaxAgentExcelService getTaxAgentExcelService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentExcelServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// private PaymentAgencyService paymentAgencyService;
|
||||
//
|
||||
// private SIEmployeeStatusMapper siEmployeeStatusMapper;
|
||||
|
|
@ -406,4 +413,29 @@ public class TaxAgentWrapper extends Service {
|
|||
}
|
||||
return SalaryI18nUtil.getI18nLabel(93945, "同步成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载人员范围导入模板
|
||||
* @param downloadTemplateParam
|
||||
* @return
|
||||
*/
|
||||
public XSSFWorkbook exportImportTemplate(TaxAgentRangeDownloadTemplateParam downloadTemplateParam) {
|
||||
return getTaxAgentExcelService(user).downloadTemplateRange(downloadTemplateParam, user.getUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览人员范围
|
||||
* @param taxAgentImportParam
|
||||
*/
|
||||
public Map<String, Object> preview(TaxAgentImportParam taxAgentImportParam) {
|
||||
return getTaxAgentExcelService(user).preview(taxAgentImportParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人-人员范围导入
|
||||
* @param taxAgentImportParam
|
||||
*/
|
||||
public Map<String, Object> importData(TaxAgentImportParam taxAgentImportParam) {
|
||||
return getTaxAgentManageRangeService(user).importData(taxAgentImportParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue