Compare commits

...

4 Commits

@ -1,6 +1,6 @@
<component name="ArtifactManager"> <component name="ArtifactManager">
<artifact type="jar" name="weaver-develop:jar"> <artifact type="jar" name="weaver-develop:jar">
<output-path>$PROJECT_DIR$/out/artifacts/weaver_develop_jar</output-path> <output-path>$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib</output-path>
<root id="archive" name="weaver-develop.jar"> <root id="archive" name="weaver-develop.jar">
<element id="module-output" name="weaver-develop" /> <element id="module-output" name="weaver-develop" />
</root> </root>

@ -0,0 +1,13 @@
package com.api.gainway.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2024/12/11 2:18 PM
* @Description:
* @Version 1.0
*/
@Path("/gainway/basicResource")
public class BasicResourceTableAction extends com.engine.gainway.web.BasicResourceTableAction {
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,111 @@
package com.api.hrm.util;
import com.engine.common.service.HrmCommonService;
import com.engine.common.service.impl.HrmCommonServiceImpl;
import com.engine.hrm.biz.HrmSanyuanAdminBiz;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.appdetach.AppDetachComInfo;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.hrm.resource.ResourceComInfo;
import java.util.StringJoiner;
public class HrmReportDetachUtil extends BaseBean {
private char flag = Util.getSeparator();
private String rightStr = "HrmResourceAdd:Add";
public String getDetachSqlWhere(int userId, String alias){
String sqlWhere = "";
String manageDetachSqlWhere = this.getManageDetachSqlWhere(userId, alias);
String appDetachSqlWhere = "";
AppDetachComInfo appDetachComInfo = new AppDetachComInfo();
try {
appDetachSqlWhere = appDetachComInfo.getScopeSqlByHrmResourceSearch("" + userId, true, "resource_" + alias);
} catch (Exception e){
writeLog("获取应用分权SQL片段异常");
writeLog(e);
}
if (StringUtils.isNotBlank(manageDetachSqlWhere) && StringUtils.isNotBlank(appDetachSqlWhere)){
sqlWhere = manageDetachSqlWhere + " and " + appDetachSqlWhere;
} else if (StringUtils.isNotBlank(manageDetachSqlWhere) && StringUtils.isBlank(appDetachSqlWhere)){
sqlWhere = manageDetachSqlWhere;
} else if (StringUtils.isBlank(manageDetachSqlWhere) && StringUtils.isNotBlank(appDetachSqlWhere)){
sqlWhere = appDetachSqlWhere;
}
writeLog("分权sqlwhere" + sqlWhere);
return sqlWhere;
}
private String getManageDetachSqlWhere(int userId, String alias){
String sqlWhere = "";
try {
ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
RecordSet recordSet = new RecordSet();
// 是否开启了管理分权
if (manageDetachComInfo.isUseManageDetach()){
// 是否启用了人力资源管理分权
if (manageDetachComInfo.isUseHrmManageDetach()){
// 系统管理员和大三员可以看所有机构
boolean canView = HrmSanyuanAdminBiz.canViewAllSubCompany(userId);
if (userId == 1 || canView){
return sqlWhere;
}
StringJoiner stringJoiner = new StringJoiner(",");
writeLog("启用人力资源管理分权");
recordSet.executeProc("HrmRoleSR_SeByURId", "" + userId + flag + rightStr);
while (recordSet.next()) {
if (recordSet.getInt("rightlevel") > -1) {
stringJoiner.add(String.valueOf(recordSet.getInt("subcompanyid")));
} else if (recordSet.getInt("rightlevel") == -1) {
stringJoiner.add(String.valueOf(-1 * recordSet.getInt("subcompanyid")));
}
}
String subCompanyIds = stringJoiner.toString();
if (subCompanyIds.length() == 0){
// 没有机构权限,查看不了任何分部
sqlWhere = " 1= 2";
} else {
sqlWhere = alias + ".subcompanyid1 in (" + subCompanyIds + ")";
}
} else {
writeLog("未启用人力资源管理分权");
if (resourceComInfo.isAdmin("" + userId)){
return sqlWhere;
}
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
int roleLevel = hrmCommonService.getMaxRoleLevel(userId, rightStr);
if (roleLevel < 0){
sqlWhere = " 1=2 ";
} else if (roleLevel == 0){
// 成员级别为部门
String departmentId = resourceComInfo.getDepartmentID("" + userId);
sqlWhere = alias + ".departmentid = " + departmentId;
} else if (roleLevel == 1){
// 成员级别为分部
String subCompanyId = resourceComInfo.getSubCompanyID("" + userId);
sqlWhere = alias + ".subcompanyid1 = " + subCompanyId;
}
}
}
} catch (Exception e){
writeLog("获取管理分权SQL片段异常");
writeLog(e);
}
return sqlWhere;
}
}

@ -0,0 +1,24 @@
package com.engine.gainway.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/12/12 5:49 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EducationLevelPo {
private Integer id;
private String levelName;
}

@ -0,0 +1,24 @@
package com.engine.gainway.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/12/12 5:49 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProvinceNamePo {
private Integer id;
private String provinceName;
}

@ -0,0 +1,21 @@
package com.engine.gainway.service;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/12/11 2:27 PM
* @Description: TODO
* @Version 1.0
*/
public interface BasicResourceTableService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/12/11 2:39 PM
* @param: [params]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String, Object> linkTable(Map<String, Object> params);
}

@ -0,0 +1,241 @@
package com.engine.gainway.service.impl;
import com.api.hrm.util.HrmReportDetachUtil;
import com.cloudstore.eccom.pc.table.WeaTable;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.core.impl.Service;
import com.engine.gainway.entity.EducationLevelPo;
import com.engine.gainway.entity.ProvinceNamePo;
import com.engine.gainway.service.BasicResourceTableService;
import com.engine.gainway.util.BasicResourceUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.PageIdConst;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.appdetach.AppDetachComInfo;
import weaver.systeminfo.SystemEnv;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/12/11 2:27 PM
* @Description: TODO
* @Version 1.0
*/
public class BasicResourceTableServiceImpl extends Service implements BasicResourceTableService {
@Override
public Map<String, Object> linkTable(Map<String, Object> params) {
Map<String, Object> resultMap = new HashMap<>(4);
BaseBean bb = new BaseBean();
String cmd = Util.null2String(params.get("cmd"));
String name = Util.null2String(params.get("name"));
String dateselect = Util.null2String(params.get("dateselect"));
String fromdate = Util.null2String(params.get("fromdate"));
String enddate = Util.null2String(params.get("enddate"));
String department =Util.null2String(params.get("departmentid"));
String subcompany =Util.null2String(params.get("subcompanyid"));
String location =Util.null2String(params.get("location"));
String status =Util.null2String(params.get("workstatus"));
String agearea =Util.null2String(params.get("agearea"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(dateselect,user.getLanguage());
if(!"".equals(startdateselect) && !"0".equals(startdateselect) && !"6".equals(startdateselect)){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
String field1 = bb.getPropValue("gwsecond", "deptOne");
String field2 = bb.getPropValue("gwsecond", "deptTwo");
String field3 = bb.getPropValue("gwsecond", "deptThree");
String field4 = bb.getPropValue("gwsecond", "deptFour");
String scopeId = bb.getPropValue("gwsecond", "scopeId");
String nativeplace = bb.getPropValue("gwsecond", "nativeplace");
WeaTable table = new WeaTable();
String pageId = "7036b679-029d-411f-b885-8e1720514f83";
table.setPageID(pageId);
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
table.setPagesize(pageSize);
String fields = "a.subcompanyid1,b."+field1+",b."+field2+",b."+field3+",b."+field4+",c."+nativeplace+",a.workcode,a.lastname,a.jobtitle,\n" +
" a.companystartdate,a.sex,a.birthday,a.birthday as age,a.educationlevel,a.companystartdate as companyworkyear";
table.setBackfields(fields);
String fromSql = "from hrmresource a left join cus_fielddata b on a.id = b.id and b.scope = 'HrmCustomFieldByInfoType' " +
" and b.scopeid = "+scopeId+" left join cus_fielddata c on a.id = c.id and c.scope = 'HrmCustomFieldByInfoType' and c.scopeid = 1";
table.setSqlform(fromSql);
String sqlWhere = "where (accounttype is null or accounttype = 0) ";
//查询条件筛选
if (!"".equals(fromdate) && !"0".equals(fromdate)) {
sqlWhere += " and a.companystartdate>= '"+fromdate+"'";
}
if(!"".equals(enddate) && !"0".equals(enddate)) {
sqlWhere += " and (a.companystartdate<='"+enddate+"' or a.companystartdate is null)";
}
if(!"".equals(location) && !"0".equals(location)){
sqlWhere += " and a.locationid ="+location;
}
if(!"".equals(department) && !"0".equals(department)){
sqlWhere += " and a.departmentid in ("+department+") ";
}
if(!"".equals(subcompany) && !"0".equals(subcompany)){
sqlWhere += " and a.subcompanyid1 in ("+subcompany+") ";
}
if(!("".equals(status) || "9".equals(status))){
if("8".equals(status)){
sqlWhere += " and a.status <= 3";
}else{
sqlWhere += " and a.status ="+status;
}
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
innerResourceSql = innerResourceSql.replace("hrmresource", "a");
//只查询行政纬度人员
sqlWhere += " and "+innerResourceSql;
//按照pie图点击查询
String s = buildSqlwhere(cmd, name);
sqlWhere = sqlWhere+s;
// todo 分权不做 该项目未开启分权
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
table.setSqlwhere(sqlWhere);
table.setSqlprimarykey("a.id");
table.getColumns().add(new WeaTableColumn("10%", "分部", "subcompanyid1").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectSubCompanyName"));
table.getColumns().add(new WeaTableColumn("10%", "一级部门", field1));
table.getColumns().add(new WeaTableColumn("10%", "二级部门", field2));
table.getColumns().add(new WeaTableColumn("10%", "三级部门", field3));
table.getColumns().add(new WeaTableColumn("10%", "四级部门", field4));
table.getColumns().add(new WeaTableColumn("10%", "编号", "workcode"));
table.getColumns().add(new WeaTableColumn("10%", "姓名", "lastname"));
table.getColumns().add(new WeaTableColumn("10%", "岗位", "jobtitle").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectJobName"));
table.getColumns().add(new WeaTableColumn("10%", "入职日期", "companystartDate"));
table.getColumns().add(new WeaTableColumn("10%", "性别", "sex").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectSexName"));
if ("AgeRp".equals(cmd)) {
table.getColumns().add(new WeaTableColumn("10%", "出生日期", "birthday"));
table.getColumns().add(new WeaTableColumn("10%", "年龄", "age").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectAge"));
}
if ("EduRp".equals(cmd)) {
table.getColumns().add(new WeaTableColumn("10%", "学历", "educationlevel").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectEducation"));
}
if ("SeniorityRp".equals(cmd)) {
table.getColumns().add(new WeaTableColumn("10%", "司龄", "companyworkyear").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectCompanyYear"));
}
if ("JobCallRp".equals(cmd)) {
table.getColumns().add(new WeaTableColumn("10%", "籍贯(省)", nativeplace).setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectNativeplace").setOtherpara(String.valueOf(user.getUID())));
}
table.setTableType(WeaTableType.NONE);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
resultMap.putAll(result.getResultMap());
return resultMap;
}
private String buildSqlwhere(String cmd,String name) {
String nativeplace = new BaseBean().getPropValue("gwsecond", "nativeplace");
String sql = "";
if ("AgeRp".equals(cmd)) {
if (SystemEnv.getHtmlLabelName(15863,user.getLanguage()).equals(name)) {
sql += " and (a.birthday is null or a.birthday ='')";
}else {
Map<String,String> map = BasicResourceUtil.selectRangeSet(name);
String fromDate = map.get("fromDate");
String toDate = map.get("toDate");
sql += " and a.birthday >'"+fromDate+"' and a.birthday <='"+toDate+"' and a.birthday is not null";
}
}else if("SexRp".equals(cmd)) {
if (SystemEnv.getHtmlLabelName(15808,user.getLanguage()).equals(name)) {
sql += " and (a.sex is null or a.sex ='')";
}else if (SystemEnv.getHtmlLabelName(28473,user.getLanguage()).equals(name)){
sql += " and a.sex = 0";
}else {
sql += " and a.sex = 1";
}
}else if ("SeniorityRp".equals(cmd)) {
if (SystemEnv.getHtmlLabelName(15863,user.getLanguage()).equals(name)) {
sql += " and (a.companystartdate is null or a.companystartdate ='')";
}else {
Map<String,String> map = BasicResourceUtil.companyYearRangeSet(name);
String fromDate = map.get("fromDate");
String toDate = map.get("toDate");
sql += " and a.companystartdate >'"+fromDate+"' and a.companystartdate <='"+toDate+"' and a.companystartdate is not null";
}
} else if ("EduRp".equals(cmd)) {
if (SystemEnv.getHtmlLabelName(21381,user.getLanguage()).equals(name)) {
sql += " and (a.educationlevel is null or a.educationlevel < 2)";
}else {
List<EducationLevelPo> educationLevel = new ArrayList<>();
//获取学历数据
getEduLevel(educationLevel);
Integer levelId = educationLevel.stream()
.filter(edu -> name.equals(edu.getLevelName()))
.map(EducationLevelPo::getId)
.findFirst()
.orElse(-1);
sql += " and a.educationlevel = "+levelId;
}
}else if("JobCallRp".equals(cmd)) {
if (SystemEnv.getHtmlLabelName(15863,user.getLanguage()).equals(name)) {
sql += " and (c."+nativeplace+" is null or c."+nativeplace+" ='')";
} else {
List<ProvinceNamePo> provinceNames = new ArrayList<>();
getNativeplace(provinceNames);
Integer provinceId = provinceNames.stream()
.filter(edu -> name.equals(edu.getProvinceName()))
.map(ProvinceNamePo::getId)
.findFirst()
.orElse(-1);
sql += " and c."+nativeplace+"= "+provinceId;
}
}
return sql;
}
private void getEduLevel(List<EducationLevelPo> educationLevel) {
RecordSet rs = new RecordSet();
rs.executeQuery("select id,name from hrmeducationlevel");
while (rs.next()) {
Integer id = Util.getIntValue(rs.getString("id"));
String name = Util.formatMultiLang(Util.null2String(rs.getString("name")),String.valueOf(user.getLanguage()));
educationLevel.add(EducationLevelPo.builder().id(id).levelName(name).build());
}
}
private void getNativeplace(List<ProvinceNamePo> provinceNames) {
RecordSet rs = new RecordSet();
rs.executeQuery("select id,provincename from hrmprovince");
while (rs.next()) {
Integer id = Util.getIntValue(rs.getString("id"));
String name = Util.formatMultiLang(Util.null2String(rs.getString("provincename")),String.valueOf(user.getLanguage()));
provinceNames.add(ProvinceNamePo.builder().id(id).provinceName(name).build());
}
}
}

@ -0,0 +1,88 @@
package com.engine.gainway.transmethod;
import com.engine.gainway.util.BasicResourceUtil;
import com.engine.hrm.biz.HrmFieldManager;
import org.apache.commons.lang.StringUtils;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.EducationLevelComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
/**
* @Author liang.cheng
* @Date 2024/12/12 9:33 AM
* @Description: TODO
* @Version 1.0
*/
public class BasicResourceTrans {
public static String selectSubCompanyName(String subcompanyid) {
SubCompanyComInfo sub = new SubCompanyComInfo();
return sub.getSubCompanyname(subcompanyid);
}
public static String selectJobName(String jobId) {
JobTitlesComInfo jc = new JobTitlesComInfo();
return jc.getJobTitlesname(jobId);
}
public static String selectSexName(String sex) {
if (StringUtils.isEmpty(sex)) {
return "未设置";
}else {
return "0".equals(sex) ? "男" : "女";
}
}
public static String selectAge(String birthday) {
String age = "";
if (StringUtils.isNotEmpty(birthday)) {
age = String.valueOf(BasicResourceUtil.calculateAge(birthday));
}
return age;
}
public static String selectEducation(String educationlevel) {
EducationLevelComInfo edu = new EducationLevelComInfo();
String eduName = edu.getEducationLevelname(educationlevel);
if (StringUtils.isEmpty(eduName)) {
eduName = "空";
}
return eduName;
}
public static String selectCompanyYear(String companydate) {
Calendar calendar = Calendar.getInstance();
int currentYear = calendar.get(Calendar.YEAR);
String yearDifference = "";
if (StringUtils.isNotEmpty(companydate)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(companydate, formatter);
int dateYear = date.getYear();
yearDifference = String.valueOf(currentYear - dateYear);
}
return yearDifference;
}
public static String selectNativeplace(String nativeplace,String userId) {
HrmFieldManager hrmFieldManager = new HrmFieldManager();
String title = "";
User user = new User();
try {
user.setUid(Integer.parseInt(userId));
title = hrmFieldManager.getFieldvalue(user, null, 0, 3, 2222, nativeplace, 0);
title = Util.formatMultiLang(title, Util.null2String(user.getLanguage()));
}catch (Exception e) {
e.printStackTrace();
}
return title;
}
}

@ -0,0 +1,90 @@
package com.engine.gainway.util;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Author liang.cheng
* @Date 2024/12/12 10:19 AM
* @Description: TODO
* @Version 1.0
*/
public class BasicResourceUtil {
public static int calculateAge(String birthday) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate birthDate = LocalDate.parse(birthday, formatter);
LocalDate today = LocalDate.now();
int age = Period.between(birthDate, today).getYears();
if (today.getMonthValue() < birthDate.getMonthValue() ||
(today.getMonthValue() == birthDate.getMonthValue() && today.getDayOfMonth() < birthDate.getDayOfMonth())) {
// 如果当前日期还没有到达生日日期年龄减1
age--;
}
return age;
}
public static Map<String,Integer> rangeExtractor(String name){
Pattern pattern = Pattern.compile("\\d{1,2}");
Matcher matcher = pattern.matcher(name);
int from = 0;
int to = 0;
if (matcher.find()) {
from = Integer.parseInt(matcher.group());
}
if (matcher.find()) {
to = Integer.parseInt(matcher.group());
}
Map<String,Integer> map = new HashMap<>(2);
map.put("from",from);
map.put("to",to);
return map;
}
public static String calculateDate(LocalDate today, int number) {
LocalDate birthDate = today.minusYears(number);
return birthDate.toString();
}
public static Map<String,String> selectRangeSet(String name) {
Map<String,String> map = new HashMap<>(2);
//提取范围
Map<String, Integer> extractor = rangeExtractor(name);
int from = extractor.get("from");
int to = extractor.get("to");
LocalDate today = LocalDate.now();
String fromDate = calculateDate(today, to+1);
String toDate = calculateDate(today, from);
map.put("fromDate",fromDate);
map.put("toDate",toDate);
return map;
}
public static Map<String,String> companyYearRangeSet(String name) {
Map<String,String> map = new HashMap<>(2);
//提取范围
Map<String, Integer> extractor = rangeExtractor(name);
int from = extractor.get("from");
int to = extractor.get("to");
LocalDate today = LocalDate.now();
String fromDate = calculateDate(today, to);
String toDate = calculateDate(today, from);
map.put("fromDate",fromDate);
map.put("toDate",toDate);
return map;
}
}

@ -0,0 +1,50 @@
package com.engine.gainway.web;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.gainway.service.BasicResourceTableService;
import com.engine.gainway.service.impl.BasicResourceTableServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/12/11 2:25 PM
* @Description: TODO
* @Version 1.0
*/
public class BasicResourceTableAction {
private BasicResourceTableService getService(User user) {
return ServiceUtil.getService(BasicResourceTableServiceImpl.class, user);
}
@GET
@Path("/linkTable")
@Produces(MediaType.TEXT_PLAIN)
public String linkTable(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("datas",getService(user).linkTable(ParamUtil.request2Map(request)));
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
}

@ -1,5 +1,12 @@
package test; package test;
import com.engine.hrm.biz.HrmFieldManager;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* @Author weaver_cl * @Author weaver_cl
* @Description: * @Description:
@ -9,6 +16,35 @@ package test;
public class MainTest { public class MainTest {
public static void main(String[] args) { public static void main(String[] args) {
String ageRangeStr = "20-39 岁";
// 使用正则表达式提取数字
Pattern pattern = Pattern.compile("\\d{1,2}");
Matcher matcher = pattern.matcher(ageRangeStr);
int ageFrom = 0;
int ageTo = 0;
if (matcher.find()) {
ageFrom = Integer.parseInt(matcher.group());
}
if (matcher.find()) {
ageTo = Integer.parseInt(matcher.group());
}
System.out.println("Age From: " + ageFrom);
System.out.println("Age To: " + ageTo);
}
public static String getBrowserShowNames(User user, int browserType, String value) {
HrmFieldManager hrmFieldManager = new HrmFieldManager();
String fieldShowName;
try {
fieldShowName = hrmFieldManager.getFieldvalue(user, null, 0, 3, browserType, value, 0);
fieldShowName = Util.formatMultiLang(fieldShowName, Util.null2String(user.getLanguage()));
} catch (Exception e) {
throw new RuntimeException(e);
}
return fieldShowName;
} }
} }

Loading…
Cancel
Save