导入薪资项目
This commit is contained in:
parent
10d988084b
commit
bd6e30b63b
|
|
@ -13,6 +13,10 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FormulaConfig {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ import lombok.experimental.Accessors;
|
|||
@AllArgsConstructor
|
||||
public class FormulaVarConfig {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,221 +0,0 @@
|
|||
package com.engine.salary.entity.salaryitem.dto;
|
||||
|
||||
import com.engine.salary.enums.SalaryRoundingModeEnum;
|
||||
import com.engine.salary.enums.SalarySystemTypeEnum;
|
||||
import com.engine.salary.enums.SalaryValueTypeEnum;
|
||||
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SalaryItemConfig {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 是否是系统项目
|
||||
*
|
||||
* @see SalarySystemTypeEnum
|
||||
*/
|
||||
private Integer systemType;
|
||||
|
||||
/**
|
||||
* 系统薪资项目的id(是从哪个系统薪资项目复制过来的)
|
||||
*/
|
||||
private Long sysSalaryItemId;
|
||||
|
||||
/**
|
||||
* 默认使用。0:默认不适用、1:默认使用
|
||||
*/
|
||||
private Integer useDefault;
|
||||
|
||||
/**
|
||||
* 薪资档案引用。0:薪资档案未引用、1:薪资档案引用
|
||||
*/
|
||||
private Integer useInEmployeeSalary;
|
||||
|
||||
/**
|
||||
* 核算时隐藏
|
||||
*/
|
||||
private Integer hideDefault;
|
||||
|
||||
/**
|
||||
* 进位规则
|
||||
*
|
||||
* @see SalaryRoundingModeEnum
|
||||
*/
|
||||
private Integer roundingMode;
|
||||
|
||||
/**
|
||||
* 保留的小数位数
|
||||
*/
|
||||
private Integer pattern;
|
||||
|
||||
/**
|
||||
* 取值方式
|
||||
*
|
||||
* @see SalaryValueTypeEnum
|
||||
*/
|
||||
private Integer valueType;
|
||||
|
||||
/**
|
||||
* 字段类型
|
||||
*
|
||||
* @see SalaryDataTypeEnum
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 公式
|
||||
*/
|
||||
private Long formulaId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 是否可以编辑。0:不可编辑、1:可编辑
|
||||
*/
|
||||
private Integer canEdit;
|
||||
|
||||
/**
|
||||
* 可见性
|
||||
*/
|
||||
private Integer sharedType;
|
||||
|
||||
/**
|
||||
* 可见范围
|
||||
*/
|
||||
private String taxAgentIds;
|
||||
|
||||
/**
|
||||
* 0不可删除,1可删除
|
||||
*/
|
||||
private Integer canDelete;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sortedIndex;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private Integer width;
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
private String defaultValue;
|
||||
|
||||
|
||||
private Formula formula;
|
||||
|
||||
@Data
|
||||
static
|
||||
class Formula {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
private String module;
|
||||
/**
|
||||
* 用途
|
||||
*/
|
||||
private String useFor;
|
||||
/**
|
||||
* 引用类型
|
||||
*/
|
||||
private String referenceType;
|
||||
/**
|
||||
* 返回类型
|
||||
*/
|
||||
private String returnType;
|
||||
/**
|
||||
* 校验类型
|
||||
*/
|
||||
private String validateType;
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String extendParam;
|
||||
/**
|
||||
* 公式内容
|
||||
*/
|
||||
private String formula;
|
||||
|
||||
/**
|
||||
* 公式实际运行脚本
|
||||
*/
|
||||
private String formulaRunScript;
|
||||
|
||||
private List<formulaVar> vars;
|
||||
|
||||
@Data
|
||||
static
|
||||
class formulaVar {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 公式id
|
||||
*/
|
||||
private Long formulaId;
|
||||
/**
|
||||
* 字段id
|
||||
*/
|
||||
private String fieldId;
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String fieldName;
|
||||
/**
|
||||
* 字段类型,number,string
|
||||
*/
|
||||
private String fieldType;
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer orderIndex;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.engine.salary.entity.salaryitem.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 导入参数
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SalaryItemImportParam {
|
||||
|
||||
/**
|
||||
* 上传文件id
|
||||
*/
|
||||
String imageId;
|
||||
}
|
||||
|
|
@ -3,12 +3,13 @@ package com.engine.salary.enums;
|
|||
|
||||
|
||||
/**
|
||||
* @description: 是、否
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 10/28/21 5:50 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
* 开关枚举
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public enum SalaryOnOffEnum implements BaseEnum<Integer> {
|
||||
|
||||
ON(1, "是", 84967),
|
||||
|
|
@ -40,4 +41,13 @@ public enum SalaryOnOffEnum implements BaseEnum<Integer> {
|
|||
public Integer getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public static SalaryOnOffEnum parseByValue(int value) {
|
||||
for (SalaryOnOffEnum item : values()) {
|
||||
if (item.getValue().equals(value)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return OFF;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,6 @@ public enum SalaryRoundingModeEnum implements BaseEnum<Integer> {
|
|||
return modeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return ROUNDING;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public enum SalaryValueTypeEnum implements BaseEnum<Integer> {
|
|||
return salaryValueTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -65,6 +65,6 @@ public enum SalaryValueTypeEnum implements BaseEnum<Integer> {
|
|||
return enumAry[i].getDefaultLabel();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return INPUT.getDefaultLabel();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.engine.salary.mapper.salaryitem;
|
||||
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.config.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
|
|||
|
|
@ -604,6 +604,7 @@
|
|||
<result column="item_width" property="width"/>
|
||||
<result column="item_default_value" property="defaultValue"/>
|
||||
<association property="formula" javaType="com.engine.salary.entity.salaryitem.config.FormulaConfig">
|
||||
<result column="formula_id" property="id"/>
|
||||
<result column="formula_name" property="name"/>
|
||||
<result column="formula_description" property="description"/>
|
||||
<result column="formula_module" property="module"/>
|
||||
|
|
@ -615,6 +616,7 @@
|
|||
<result column="formula_formula" property="formula"/>
|
||||
<result column="formula_formulaRunScript" property="formulaRunScript"/>
|
||||
<collection property="vars" ofType="com.engine.salary.entity.salaryitem.config.FormulaVarConfig">
|
||||
<result column="var_id" property="id"/>
|
||||
<result column="var_name" property="name"/>
|
||||
<result column="var_formula_id" property="formulaId"/>
|
||||
<result column="var_field_id" property="fieldId"/>
|
||||
|
|
@ -628,7 +630,8 @@
|
|||
|
||||
|
||||
<sql id="itemColumns">
|
||||
item.name as item_name
|
||||
item.id as item_id
|
||||
,item.name as item_name
|
||||
, item.code as item_code
|
||||
, item.system_type as item_system_type
|
||||
, item.sys_salary_item_id as item_sys_salary_item_id
|
||||
|
|
@ -652,6 +655,7 @@
|
|||
|
||||
|
||||
<sql id="formulaColumns">
|
||||
, formula.id as formula_id
|
||||
, formula.name as formula_name
|
||||
, formula.description as formula_description
|
||||
, formula.module as formula_module
|
||||
|
|
@ -665,6 +669,7 @@
|
|||
</sql>
|
||||
|
||||
<sql id="varColumns">
|
||||
, var.id as var_id
|
||||
, var.name as var_name
|
||||
, var.formula_id as var_formula_id
|
||||
, var.field_id as var_field_id
|
||||
|
|
@ -684,6 +689,15 @@
|
|||
left join hrsa_formula formula on item.formula_id = formula.id
|
||||
left join hrsa_formula_var var on var.formula_id = formula.id
|
||||
where item.delete_type=0 and formula.delete_type=0 and var.delete_type=0
|
||||
and item.use_in_employee_salary = 0
|
||||
and system_type = 0
|
||||
|
||||
<if test="ids != null and ids.size()>0">
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.config.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemExportParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.engine.salary.config.SalaryElogConfig;
|
|||
import com.engine.salary.entity.salaryformula.po.FormulaPO;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.config.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemExportParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.engine.salary.web;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.component.WeaFormOption;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
|
||||
import com.engine.salary.entity.salaryitem.dto.SysSalaryItemListDTO;
|
||||
|
|
@ -15,6 +15,7 @@ import com.engine.salary.wrapper.SalaryItemWrapper;
|
|||
import com.engine.salary.wrapper.SysSalaryItemWrapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -23,6 +24,11 @@ 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;
|
||||
|
|
@ -184,10 +190,35 @@ public class SalaryItemController {
|
|||
|
||||
@POST
|
||||
@Path("/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemExportParam param) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSalaryItemWrapper(user).export(param);
|
||||
String time = LocalDate.now().toString();
|
||||
String fileName = "薪资项目" + 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;
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/import")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String updateSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemExportParam param) {
|
||||
public String importSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemImportParam importParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalaryItemExportParam, List<SalaryItemConfig>>(user).run(getSalaryItemWrapper(user)::export, param);
|
||||
return new ResponseResult<SalaryItemImportParam, Map<String, Object>>(user).run(getSalaryItemWrapper(user)::importSalaryItem, importParam);
|
||||
}
|
||||
|
||||
/**********************************自定义薪资项目 end*********************************/
|
||||
|
|
|
|||
|
|
@ -2,19 +2,17 @@ package com.engine.salary.wrapper;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.hrmelog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.component.WeaFormOption;
|
||||
import com.engine.salary.config.SalaryElogConfig;
|
||||
import com.engine.hrmelog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
|
||||
import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.config.SalaryItemConfig;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO;
|
||||
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemExportParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
||||
import com.engine.salary.entity.salaryitem.param.SyncSalaryItemParam;
|
||||
import com.engine.salary.entity.salaryitem.param.*;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
|
|
@ -28,14 +26,19 @@ import com.engine.salary.sys.service.SalarySysConfService;
|
|||
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
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.valid.RuntimeTypeEnum;
|
||||
import com.engine.salary.util.valid.ValidUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -292,6 +295,7 @@ public class SalaryItemWrapper extends Service {
|
|||
|
||||
/**
|
||||
* 获取薪资项目在哪些账套中使用
|
||||
*
|
||||
* @param salaryItemId
|
||||
*/
|
||||
public List<Map<String, Object>> getSalarySobBySalaryItem(Long salaryItemId) {
|
||||
|
|
@ -300,17 +304,45 @@ public class SalaryItemWrapper extends Service {
|
|||
|
||||
/**
|
||||
* 将薪资项目管理中的信息同步至账套
|
||||
*
|
||||
* @param syncSalaryItemParam
|
||||
*/
|
||||
public void syncSalaryItemToSalarySobItem(SyncSalaryItemParam syncSalaryItemParam) {
|
||||
getSalaryItemService(user).syncSalaryItemToSalarySobItem(syncSalaryItemParam);
|
||||
}
|
||||
|
||||
public List<SalaryItemConfig> export(SalaryItemExportParam param) {
|
||||
public XSSFWorkbook export(SalaryItemExportParam param) {
|
||||
|
||||
return getSalaryItemService(user).getConfig(param);
|
||||
String[] titles = {"名称", "默认使用", "核算时隐藏", "进位规则", "保留的小数位数", "取值方式", "字段类型", "公式", "备注", "排序", "宽度", "默认值"};
|
||||
List<SalaryItemConfig> configs = getSalaryItemService(user).getConfig(param);
|
||||
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
rows.add(Arrays.asList(titles));
|
||||
configs.forEach(e -> {
|
||||
List<Object> row = new ArrayList<>();
|
||||
|
||||
row.add(e.getName());
|
||||
row.add(SalaryOnOffEnum.parseByValue(e.getUseDefault()).getDefaultLabel());
|
||||
row.add(e.getHideDefault());
|
||||
row.add(SalaryRoundingModeEnum.parseByValue(e.getRoundingMode()).getDefaultLabel());
|
||||
row.add(e.getPattern());
|
||||
row.add(SalaryValueTypeEnum.parseByValue(e.getValueType()).getDefaultLabel());
|
||||
row.add(e.getDataType());
|
||||
row.add("e.getFormula()");
|
||||
row.add(e.getDescription());
|
||||
row.add(e.getSortedIndex());
|
||||
row.add(e.getWidth());
|
||||
row.add(e.getDefaultValue());
|
||||
rows.add(row);
|
||||
});
|
||||
|
||||
return ExcelUtil.genWorkbookV2(rows, "薪资项目");
|
||||
}
|
||||
|
||||
public void importSalaryItem(SalaryItemImportParam param) {
|
||||
InputStream fileInputStream = null;
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
||||
List<AddUpDeductionDTO> addUpDeductions = ExcelParseHelper.parse2Map(fileInputStream, AddUpDeductionDTO.class, 0, 1, 14, "addUpDeductionTemplate.xlsx");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue