Compare commits

...

9 Commits

2
.gitignore vendored

@ -5,7 +5,7 @@
HELP.md
target/
.idea
.idea/
/test
/src/rebel.xml

@ -1,6 +1,6 @@
<component name="ArtifactManager">
<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">
<element id="module-output" name="weaver-develop" />
</root>

@ -1,13 +0,0 @@
package com.api.jygf.web;
import javax.ws.rs.Path;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
@Path("/mobile/permission")
public class MobilePermissionsAction extends com.engine.jygf.web.MobilePermissionsAction {
}

@ -0,0 +1,14 @@
package com.api.matfron.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2023/9/26 5:49 PM
* @Description:
* @Version 1.0
*/
@Path("/matfron/portal/element")
public class StatisticsPortalAction extends com.engine.matfron.web.StatisticsPortalAction {
}

@ -1,68 +0,0 @@
package com.engine.jygf.cmd;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.hrm.User;
import weaver.wechat.util.Utils;
import java.util.*;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MobilePermissionsCmd extends AbstractCommonCommand<Map<String, Object>> {
private static final String FIELDID = "field100043"; //移动电话自定义字段field100026
private static final String SCOPE = "HrmCustomFieldByInfoType";
private static final String SCOPEID = "-1";
public MobilePermissionsCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> data = new HashMap<>();
String uid = Utils.null2String(user.getUID());
RecordSet rs = new RecordSet();
HashSet<String> ids = new HashSet<>();
ids.add(uid);
rs.executeQuery("select ckr,bckr from uf_yddhqx_dt1");
while (rs.next()) {
String ckr = Utils.null2String(rs.getString("ckr"));
String bckr = Utils.null2String(rs.getString("bckr"));
if (Arrays.asList(ckr.split(",")).contains(uid)) {
ids.addAll(Arrays.asList(bckr.split(",")));
}
}
Map<String,String> mobileInfo = new HashMap<>();
String value = StringUtils.join(ids,",");
rs.executeQuery("select id,"+FIELDID+" from cus_fielddata where scope = ? and scopeid = ?" +
" and id in ("+value+")",SCOPE,SCOPEID);
while (rs.next()){
mobileInfo.put(Utils.null2String(rs.getString("id")),rs.getString(FIELDID));
}
data.put("ids",ids);
data.put("mobileInfo",mobileInfo);
return data;
}
}

@ -1,16 +0,0 @@
package com.engine.jygf.service;
import weaver.hrm.User;
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public interface MobilePermissionsService {
Map<String, Object> getPermissionInfo(Map<String, Object> params, User user);
}

@ -1,24 +0,0 @@
package com.engine.jygf.service.impl;
import com.engine.core.impl.Service;
import com.engine.jygf.cmd.MobilePermissionsCmd;
import com.engine.jygf.service.MobilePermissionsService;
import weaver.hrm.User;
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MobilePermissionsServiceImpl extends Service implements MobilePermissionsService {
@Override
public Map<String, Object> getPermissionInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new MobilePermissionsCmd(params,user));
}
}

@ -1,57 +0,0 @@
package com.engine.jygf.web;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.jygf.service.MobilePermissionsService;
import com.engine.jygf.service.impl.MobilePermissionsServiceImpl;
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 weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MobilePermissionsAction {
public MobilePermissionsService getMobilePermissionsService(User user) {
return ServiceUtil.getService(MobilePermissionsServiceImpl.class,user);
}
/**
*
* @param request
* @param response
* @return
*/
@GET
@Path("/controller")
@Produces(MediaType.APPLICATION_JSON)
public String getPermissionInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
//实例化Service 并调用业务类处理
apidatas = getMobilePermissionsService(user).getPermissionInfo(ParamUtil.request2Map(request), user);
} catch (Exception e) {
//异常处理
apidatas.put("api_status", false);
}
return JSONObject.toJSONString(apidatas);
}
}

@ -0,0 +1,24 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/10/10 1:41 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BrowserParam {
private Integer id;
private String name;
}

@ -0,0 +1,26 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/9/28 10:06 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentParam {
private Integer departmentId;
private String name;
private Integer count;
}

@ -0,0 +1,47 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.LinkedList;
/**
* @Author liang.cheng
* @Date 2023/9/27 5:30 PM
* @Description: echarts option
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OptionVO {
private String titleText;
private LinkedList<String> xData;
private Integer yMin;
private Integer yMax;
private Integer yInterval;
private LinkedList<Integer> yData;
private LinkedList<String> legendDataFirst;
private LinkedList<String> legendDataTwo;
private LinkedList<Integer> barSeriesData;
private LinkedList<Integer> barSeriesDataTwo;
private LinkedList<Integer> barSeriesDataThree;
private LinkedList<SeriesParam> seriesData;
}

@ -0,0 +1,25 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/9/27 3:45 PM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PortalTopVO<T> {
private String title;
private T count;
}

@ -0,0 +1,28 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/9/28 2:02 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SeriesParam {
private Double value;
private String name;
private String color;
}

@ -0,0 +1,25 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/10/9 1:11 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SurnameParam {
private Double companyworkyear;
private Integer count;
}

@ -0,0 +1,22 @@
package com.engine.matfron.exception;
/**
* @Author weaver_cl
* @Description:
* @Date 2023/2/21
* @Version V1.0
**/
public class CustomizeRunTimeException extends RuntimeException{
public CustomizeRunTimeException(String message) {
super(message);
}
public CustomizeRunTimeException(Throwable cause) {
super(cause);
}
public CustomizeRunTimeException(String message, Throwable cause) {
super(message, cause);
}
}

@ -0,0 +1,118 @@
package com.engine.matfron.service;
import com.engine.matfron.entity.OptionVO;
import com.engine.matfron.entity.PortalTopVO;
import java.util.LinkedList;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/9/26 5:51 PM
* @Description:
* @Version 1.0
*/
public interface StatisticsPortalService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/27 4:02 PM
* @param: []
* @return: com.engine.matfron.entity.PortalTopVO
*/
LinkedList<PortalTopVO> getPortalTop();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/27 5:40 PM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getPortalDepartment();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/28 11:23 AM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getPortalSubCompany();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/9 9:52 AM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getPortalEthnic();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/10 5:57 PM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getHomePlace();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/9 9:53 AM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getEducational();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/9 11:21 AM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getSurname();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/9 2:32 PM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getAgeAndSex();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/9 5:52 PM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getJobType();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/9 7:00 PM
* @param: [departmentIds]
* @return: map
*/
Map<String,Object> getLeaveMonth(String departmentIds);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/10/10 9:37 AM
* @param: [departmentIds]
* @return: map
*/
Map<String,Object> getLeaveYear(String departmentIds);
}

@ -0,0 +1,644 @@
package com.engine.matfron.service.impl;
import com.engine.core.impl.Service;
import com.engine.matfron.entity.*;
import com.engine.matfron.exception.CustomizeRunTimeException;
import com.engine.matfron.service.StatisticsPortalService;
import com.engine.matfron.util.CommonDateUtil;
import com.engine.matfron.util.CommonUtils;
import com.weaver.general.BaseBean;
import lombok.SneakyThrows;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.YearMonth;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2023/9/26 5:52 PM
* @Description:
* @Version 1.0
*/
public class StatisticsPortalServiceImpl extends Service implements StatisticsPortalService {
private final DecimalFormat df = new DecimalFormat("#.00");
@Override
public LinkedList<PortalTopVO> getPortalTop() {
RecordSet rs = new RecordSet();
LinkedList<PortalTopVO> portalTopVOList = new LinkedList<>();
rs.executeQuery("select count(1) as count from hrmresource where status < 4");
rs.next();
Integer count = Util.getIntValue(rs.getString("count"), 0);
portalTopVOList.add(PortalTopVO.builder().title("在职人数总数").count(count).build());
rs.executeQuery("select count(1) as sum from hrsa_insurance_base_info where run_status in (2,3) and delete_type = 0");
rs.next();
portalTopVOList.add(PortalTopVO.builder().title("社保缴纳人数").count(Util.getIntValue(rs.getString("sum"), 0)).build());
List<String> birthdayList = new ArrayList<>();
rs.executeQuery("select birthday from hrmresource where status < 4 and birthday is not null and birthday <> ''");
while (rs.next()) {
birthdayList.add(Util.null2String(rs.getString("birthday")));
}
double averageAge = birthdayList.stream()
.map(CommonUtils::parseLocalDate)
.mapToInt(CommonUtils::calculateAge)
.average()
.orElse(0);
String avgAge = df.format(averageAge);
portalTopVOList.add(PortalTopVO.builder().title("平均年龄").count(avgAge).build());
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now()));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate >= ? and companystartdate <= ",startMonth,endMonth);
rs.next();
Integer sum = Util.getIntValue(rs.getString("sum"),0);
portalTopVOList.add(PortalTopVO.builder().title("本月新入职人员").count(sum).build());
return portalTopVOList;
}
@SneakyThrows
@Override
public OptionVO getPortalDepartment() {
RecordSet rs = new RecordSet();
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> yData = new LinkedList<>();
DepartmentComInfo comInfo = new DepartmentComInfo();
List<Integer> ids = new ArrayList<>();
rs.executeQuery("select id,departmentname from hrmdepartment where supdepid = 0 and (canceled = 0 or canceled is null)");
while (rs.next()) {
xData.add(Util.null2String(rs.getString("departmentname")));
ids.add(Util.getIntValue(rs.getString("id")));
}
List<DepartmentParam> deptList = new ArrayList<>();
rs.executeQuery("SELECT d.id, CASE WHEN t.count IS NULL THEN 0 ELSE t.count END AS num \n" +
" FROM hrmdepartment d left join (SELECT departmentid, COUNT(1) AS count FROM hrmresource where status < 4 GROUP BY departmentid) t ON d.id = t.departmentid \n" +
" where d.id in ("+StringUtils.join(ids,",")+")");
while (rs.next()) {
int deptid = Util.getIntValue(rs.getString("id"));
int num = Util.getIntValue(rs.getString("num"));
ArrayList<String> allSubDepartment = new ArrayList<>();
comInfo.getAllChildDeptByDepId(allSubDepartment, String.valueOf(deptid));
if (CollectionUtils.isNotEmpty(allSubDepartment)) {
int count = countBydeptIds(StringUtils.join(allSubDepartment,","));
num = num + count;
}
yData.add(num);
deptList.add(DepartmentParam.builder().departmentId(deptid).count(num).build());
}
int max = Collections.max(yData);
int ceil =(int) Math.ceil((double) max / 5);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 5);
return OptionVO.builder()
.titleText("一级部门人数统计")
.xData(xData)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.yData(yData)
.build();
}
@Override
public OptionVO getPortalSubCompany() {
RecordSet rs = new RecordSet();
LinkedList<Integer> yData = new LinkedList<>();
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
yearMonths.forEach(yearMonth -> {
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ?",endMonth);
if (rs.next()) {
Integer sum = Util.getIntValue(rs.getString("sum"),0);
yData.add(sum);
}
});
int max = Collections.max(yData);
int ceil =(int) Math.ceil((double) max / 5);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 5);
return OptionVO.builder()
.titleText("各月份分部总人数")
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.yData(yData)
.build();
}
@Override
public OptionVO getPortalEthnic() {
RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#6e94f3","#faf0e6","#7cfc00","#ao20f0","#00ced1","#83d8ae","#697695","#8ac9e9","#9933fa","#c0ff3e","#ffe4c4","#cd6090");
LinkedList<SeriesParam> seriesData = new LinkedList<>();
LinkedList<String> nameSet = new LinkedList<>();
rs.executeQuery("select distinct folk,count(1) as sums from hrmresource where status < 4 \n" +
" and folk is not null group by folk");
while (rs.next()) {
Random random = new Random();
String color = colorList.get(random.nextInt(colorList.size()));
String name = Util.null2String(rs.getString("folk"));
seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sums")))
.name(name).color(color).build());
nameSet.add(name);
}
double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum();
seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage))));
// LinkedList<String> legendDataFirst = null;
// if (nameSet.size() > 2) {
// int splitSize = nameSet.size() / 2;
// legendDataFirst = nameSet.stream()
// .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize,
// Collectors.toCollection(LinkedList::new)))
// .get(false);
// nameSet.removeAll(legendDataFirst);
// }
return OptionVO.builder()
.titleText("民族分析")
.legendDataTwo(nameSet)
.seriesData(seriesData)
.build();
}
@Override
public OptionVO getHomePlace() {
RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#ao20f0","#8ac9e9","#697695","#83d8ae","#faf0e6","#7cfc00","#6e94f3","#9933fa","#c0ff3e","#00ced1","#ffe4c4","#cd6090");
LinkedList<SeriesParam> seriesData = new LinkedList<>();
LinkedList<String> legendData = new LinkedList<>();
rs.executeQuery("select h.locationid,l.locationname,count(1) as num from hrmresource h\n" +
" left join hrmlocations l on h.locationid = l.id\n" +
" where h.status < 4 and h.locationid is not null group by h.locationid,l.locationname");
while (rs.next()) {
String locationname = Util.null2String(rs.getString("locationname"));
legendData.add(locationname);
Random random = new Random();
String color = colorList.get(random.nextInt(colorList.size()));
seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("num"))).name(locationname).color(color).build());
}
List<Double> values = seriesData.stream().map(SeriesParam :: getValue).collect(Collectors.toList());
double percentage = values.stream().mapToDouble(Double::doubleValue).sum();
seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage))));
return OptionVO.builder()
.titleText("归属地分析")
.legendDataFirst(legendData)
.seriesData(seriesData)
.build();
}
@Override
public OptionVO getEducational() {
RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#faf0e6","#7cfc00","#ee8164","#9933fa","#f19c45","#6fcecf","#507ef7","#ao20f0");
LinkedList<SeriesParam> seriesData = new LinkedList<>();
LinkedList<String> nameSet = new LinkedList<>();
rs.executeQuery("select distinct h.educationlevel,count(1) as sum,d.name from hrmresource h\n" +
"left join hrmeducationlevel d on h.educationlevel = d.id where status < 4 \n" +
"and h.educationlevel is not null and d.name is not null group by h.educationlevel,d.name ");
int index = 0;
while (rs.next()) {
if (index > colorList.size()){
index = 0;
}
index++;
String name = Util.formatMultiLang (Util.null2String(rs.getString("name")));
seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sum")))
.name(name).color(colorList.get(index)).build());
nameSet.add(name);
}
double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum();
seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage))));
LinkedList<String> legendDataFirst = new LinkedList<>();
if (nameSet.size() > 2) {
legendDataFirst = treeSetSplitExample(nameSet);
}
return OptionVO.builder()
.titleText("学历分析")
.legendDataFirst(legendDataFirst)
.legendDataTwo(nameSet)
.seriesData(seriesData)
.build();
}
@Override
public OptionVO getSurname() {
RecordSet rs = new RecordSet();
LinkedList<SeriesParam> seriesData = new LinkedList<>();
List<SurnameParam> surnameList = new ArrayList<>();
rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " +
" and companyworkyear is not null group by companyworkyear ");
while (rs.next()) {
surnameList.add(SurnameParam.builder().companyworkyear(Util.getDoubleValue(rs.getString("companyworkyear"))).count(Util.getIntValue(rs.getString("sum"))).build());
}
List<Integer> statisticsArr = Arrays.asList(0,1,3,5,10,100);
List<Double> statisticsList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
double count = statisticsSurname(statisticsArr.get(i), statisticsArr.get(i+1), surnameList);
statisticsList.add(count);
}
double percentage = statisticsList.stream().mapToDouble(Double::doubleValue).sum();
List<Double> newList = statisticsList.stream()
.map(num -> Double.valueOf (df.format((num * 100 ) / percentage)))
.collect(Collectors.toList());
newList.forEach(count -> seriesData.add(SeriesParam.builder().value(count).build()));
return OptionVO.builder()
.titleText("司龄统计")
.seriesData(seriesData)
.build();
}
@Override
public OptionVO getAgeAndSex() {
RecordSet rs = new RecordSet();
LinkedList<Integer> barSeriesData = new LinkedList<>();
LinkedList<Integer> barSeriesDataTwo = new LinkedList<>();
List<String> ageArr = Arrays.asList("16~20","21~25","26~30","31~35","36~40","41~45","46~50","51~55","56~60","61~65","66~70");
List<String> birthdayListMen = new ArrayList<>();
rs.executeQuery("select birthday from hrmresource where status < 4 and sex is not null and birthday is not null and birthday <> '' and sex = 0");
while (rs.next()) {
birthdayListMen.add(Util.null2String(rs.getString("birthday")));
}
List<Integer> menAge = birthdayListMen.stream()
.map(birthday -> {
LocalDate birthdate = LocalDate.parse(birthday);
LocalDate now = LocalDate.now();
return Period.between(birthdate, now).getYears();
})
.collect(Collectors.toList());
for (int i = 0; i < ageArr.size(); i++) {
String[] split = ageArr.get(i).split("~");
List<Integer> collect = menAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList());
barSeriesData.add(collect.size());
}
int yMax = barSeriesData.stream().max(Integer::compare).orElse(0);
List<String> birthdayListWomen = new ArrayList<>();
rs.executeQuery("select birthday from hrmresource where status < 4 and sex is not null and birthday is not null and sex = 1");
while (rs.next()) {
birthdayListWomen.add(Util.null2String(rs.getString("birthday")));
}
List<Integer> womenAge = birthdayListWomen.stream()
.map(birthday -> {
LocalDate birthdate = LocalDate.parse(birthday);
LocalDate now = LocalDate.now();
return Period.between(birthdate, now).getYears();
})
.collect(Collectors.toList());
LinkedList<Integer> list = new LinkedList<>();
for (int i = 0; i < ageArr.size(); i++) {
String[] split = ageArr.get(i).split("~");
List<Integer> collect = womenAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList());
barSeriesDataTwo.add(-collect.size());
list.add(collect.size());
}
int yMin = -(list.stream().max(Integer::compare).orElse(0));
int sum = yMax > Math.abs(yMin) ? yMax : yMin ;
int divisor = sum % 6;
sum = sum + (6 - divisor) + 12;
int ceil =(int) Math.ceil((double) sum / 3);
return OptionVO.builder()
.titleText("年龄与性别分析")
.yMin(-sum)
.yMax(sum)
.yInterval(ceil)
.barSeriesData(barSeriesData)
.barSeriesDataTwo(barSeriesDataTwo)
.build();
}
@Override
public OptionVO getJobType() {
RecordSet rs = new RecordSet();
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> barSeriesData = new LinkedList<>();
rs.executeQuery("select a.*,b.jobgroupname from (select g.id as jobgroupid,count(1) as sum from hrmresource h \n" +
" left join hrmjobtitles j on h.jobtitle = j.id\n" +
" left join hrmjobactivities c on j.jobactivityid = c.id\n" +
" left join hrmjobgroups g on c.jobgroupid = g.id\n" +
" where h.status < 4 and g.id is not null group by g.id) as a left join hrmjobgroups b on a.jobgroupid = b.id");
while (rs.next()) {
xData.add(Util.null2String(rs.getString("jobgroupname")));
barSeriesData.add(Util.getIntValue(rs.getString("sum")));
}
int max = Collections.max(barSeriesData);
int ceil =(int) Math.ceil((double) max / 4);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 4);
return OptionVO.builder()
.titleText("职务类别统计")
.xData(xData)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.barSeriesData(barSeriesData)
.build();
}
@Override
public Map<String,Object> getLeaveMonth(String departmentIds) {
Map<String,Object> data = new HashMap<>(4);
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now()));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
LinkedList<String> xData = new LinkedList<>();
LinkedList<Integer> barSeriesData = new LinkedList<>();
LinkedList<BrowserParam> browser = new LinkedList<>();
StringBuilder sql = new StringBuilder();
sql.append("select t.departmentname, t.id,CASE \n" +
" WHEN a.sum IS NULL THEN 0 \n" +
" ELSE a.sum \n" +
" END AS num from hrmdepartment t \n" +
" left join (select s.departmentid,count(1) as sum from hrmstatushistory h left join hrmresource s on h.resourceid = s.id " +
" where h.type_n = 5 and h.changedate >= ? and h.changedate <= ? group by s.departmentid ) a\n" +
" on t.id = a.departmentid ");
sql.append(" where (t.canceled = 0 or t.canceled is null)");
if(StringUtils.isNotEmpty(departmentIds)) {
sql.append(" and t.id in (").append(departmentIds).append(")");
}
bb.writeLog("sql2023"+sql.toString()+"->"+startMonth+endMonth);
rs.executeQuery(sql.toString(),startMonth,endMonth);
int i = 0;
while (rs.next() && i < 5) {
i++;
Integer id = Util.getIntValue(rs.getString("id"));
String name = Util.null2String(rs.getString("departmentname"));
int num = Util.getIntValue(rs.getString("num"));
xData.add(name);
int countBydeptId = countBydeptId(id, endMonth) + num;
barSeriesData.add( countBydeptId == 0 ? 0 : (num * 100) / countBydeptId);
browser.add(BrowserParam.builder().id(id).name(name).build());
}
int max = Collections.max(barSeriesData);
max = max < 80 ? max + 20 : 100;
int ceil =(int) Math.ceil((double) max / 4);
int roundedMax = CommonUtils.roundedMax(ceil, 4);
OptionVO optionVo = OptionVO.builder().titleText("当月多部门离职率统计")
.xData(xData)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.barSeriesData(barSeriesData)
.build();
data.put("replaceDatas",browser);
data.put("optionVo",optionVo);
return data;
}
@Override
public Map<String,Object> getLeaveYear(String departmentIds) {
Map<String,Object> data = new HashMap<>(4);
RecordSet rs = new RecordSet();
LinkedList<String> legendDataFirst = new LinkedList<>();
LinkedList<Integer> barSeriesData = new LinkedList<>();
LinkedList<Integer> barSeriesDataTwo = new LinkedList<>();
LinkedList<Integer> barSeriesDataThree = new LinkedList<>();
DepartmentComInfo comInfo = new DepartmentComInfo();
LinkedList<BrowserParam> browser = new LinkedList<>();
List<Integer> deptList = new ArrayList<>();
if(StringUtils.isNotEmpty(departmentIds)) {
deptList = Arrays.stream(departmentIds.split(",")).map(Integer::parseInt)
.collect(Collectors.toList());
}else {
// rs.executeQuery("select distinct t.id from hrmdepartment t \n" +
// " left join hrmresource h on t.id = h.departmentid\n" +
// " left join hrmstatushistory s on h.id = s.resourceid where s.type_n = 5 ");
rs.executeQuery("select id from hrmdepartment where canceled = 0 or canceled is null");
while (rs.next()) {
deptList.add(Util.getIntValue(rs.getString("id")));
}
}
deptList = deptList.stream().limit(3).collect(Collectors.toList());
deptList.forEach(dept -> {
try {
String departmentName = comInfo.getDepartmentName(String.valueOf(dept));
legendDataFirst.add(departmentName);
browser.add(BrowserParam.builder().id(dept).name(departmentName).build());
} catch (Exception e) {
throw new CustomizeRunTimeException("所选部门不存在");
}
});
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
List<Integer> finalDeptList = deptList;
yearMonths.forEach(yearMonth -> {
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
for (int i = 0; i < 3; i++) {
Integer value = calculateLeave(finalDeptList.get(i), startMonth, endMonth);
switch (i) {
case 0:
barSeriesData.add(value);
break;
case 1:
barSeriesDataTwo.add(value);
break;
case 2:
barSeriesDataThree.add(value);
break;
default:
break;
}
}
});
LinkedList<Integer> sumData = new LinkedList<>();
sumData.addAll(barSeriesData);
sumData.addAll(barSeriesDataTwo);
sumData.addAll(barSeriesDataThree);
int max = Collections.max(sumData);
max = max < 80 ? max + 20 : 100;
int ceil =(int) Math.ceil((double) max / 4);
int roundedMax = CommonUtils.roundedMax(ceil, 4);
OptionVO optionVo = OptionVO.builder().titleText("年度离职率统计")
.legendDataFirst(legendDataFirst)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.barSeriesData(barSeriesData)
.barSeriesDataTwo(barSeriesDataTwo)
.barSeriesDataThree(barSeriesDataThree)
.build();
data.put("replaceDatas",browser);
data.put("optionVo",optionVo);
return data;
}
private Integer calculateLeave(Integer id,String startMonth,String endMonth) {
RecordSet rs = new RecordSet();
String sql = ("select t.departmentname, t.id,CASE \n" +
" WHEN a.sum IS NULL THEN 0 \n" +
" ELSE a.sum \n" +
" END AS num from hrmdepartment t \n" +
" left join (select s.departmentid,count(1) as sum from hrmstatushistory h left join hrmresource s on h.resourceid = s.id " +
" where type_n = 5 and changedate >= ? and changedate <= ? group by s.departmentid ) a\n" +
" on t.id = a.departmentid where t.id = ? and (t.canceled = 0 or t.canceled is null)");
BaseBean bb = new BaseBean();
bb.writeLog("calculateLeave "+sql);
rs.executeQuery(sql,startMonth,endMonth,id);
rs.next();
int num = Util.getIntValue(rs.getString("num"));
int countBydeptId = countBydeptId(id, endMonth) + num;
return countBydeptId == 0 ? 0 : ((num * 100) / countBydeptId);
}
/**
*
* @param departmentId
* @return
*/
private int countBydeptId(Integer departmentId,String endMonth) {
RecordSet rs = new RecordSet();
rs.executeQuery("select count(1) as sum from hrmresource where departmentId = ? and status < 4 and companystartdate <= ? ",departmentId,endMonth);
rs.next();
return Util.getIntValue(rs.getString("sum"));
}
/**
*
* @param deptIds
* @return
*/
private int countBydeptIds(String deptIds) {
RecordSet rs = new RecordSet();
rs.executeQuery("select count(1) as sum from hrmresource where departmentId in ("+deptIds+")");
rs.next();
return Util.getIntValue(rs.getString("sum"));
}
/**
*
* @return
*/
private Double statisticsSurname(Integer min,Integer max,List<SurnameParam> surnameList) {
return surnameList.stream().filter(item -> item.getCompanyworkyear() > min && item.getCompanyworkyear() <= max)
.mapToDouble(SurnameParam::getCount).sum();
}
/**
* legendData
* @param nameSet
*/
private LinkedList<String> treeSetSplitExample(LinkedList<String> nameSet) {
int splitSize = nameSet.size() / 2;
LinkedList<String> legendDataFirst = nameSet.stream()
.collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize,
Collectors.toCollection(LinkedList::new)))
.get(false);
nameSet.removeAll(legendDataFirst);
return legendDataFirst;
}
/**
*
* @param input
* @return
*/
private String chineseSubstringExample(String input) {
String r = "7.*`~`8";
Pattern pattern1 = Pattern.compile(r);
Matcher matcher = pattern1.matcher(input);
while (matcher.find()) {
input = matcher.group(0);
}
// 使用正则表达式匹配中文
String pattern = "[\u4E00-\u9FA5\u8FBD-\u9FBB\uFA0E-\uFA29]+";
Pattern s = Pattern.compile(pattern);
Matcher m = s.matcher(input);
while (m.find()) {
input = m.group(0);
}
return input;
}
}

@ -0,0 +1,175 @@
package com.engine.matfron.util;
import com.engine.matfron.exception.CustomizeRunTimeException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.util.Collection;
import java.util.Map;
/**
* @Author weaver_cl
* @description:
* @Date 2022/4/26
* @Version V1.0
**/
public abstract class CommonAssert {
/**
* null
*
* @param object
* @param message
*/
public static void notNull(Object object, String message) {
if (object == null) {
throw new CustomizeRunTimeException(message);
}
}
/**
* null
*
* @param string
* @param message
*/
public static void notNull(String string, String message) {
if (StringUtils.isBlank(string)) {
throw new CustomizeRunTimeException(message);
}
}
/**
* null
*
* @param message
* @param objects
*/
public static void notNull(String message, Object... objects) {
for (Object obj : objects) {
if (obj == null) {
throw new CustomizeRunTimeException(message);
}
}
}
/**
* null
*
* @param object
* @param message
*/
public static void isNull(Object object, String message) {
if (object != null) {
throw new CustomizeRunTimeException(message);
}
}
/**
*
*
* @param collection
* @param message
*/
public static void isEmpty(Collection<?> collection, String message) {
if (!CollectionUtils.isEmpty(collection)) {
throw new CustomizeRunTimeException(message);
}
}
/**
*
*
* @param collection
* @param message
*/
public static void notEmpty(Collection<?> collection, String message) {
if (CollectionUtils.isEmpty(collection)) {
throw new CustomizeRunTimeException(message);
}
}
/**
*
*
* @param arr
* @param message
*/
public static void notEmpty(Object[] arr, String message) {
if (ObjectUtils.isEmpty(arr)) {
throw new CustomizeRunTimeException(message);
}
}
/**
* map
*
* @param map
* @param message
*/
public static void notEmpty(Map<?, ?> map, String message) {
if (CollectionUtils.isEmpty(map)) {
throw new CustomizeRunTimeException(message);
}
}
/**
*
*
* @param arr
* @param message
*/
public static void notNullElement(Object[] arr, String message) {
if (arr != null) {
for (Object obj : arr) {
if (obj == null) {
throw new CustomizeRunTimeException(message);
}
}
}
}
/**
* boolean
*
* @param expression
* @param message
*/
public static void isTrue(boolean expression, String message) {
if (!expression) {
throw new CustomizeRunTimeException(message);
}
}
public static void isFalse(boolean expression, String message) {
if (expression) {
throw new CustomizeRunTimeException(message);
}
}
public static void isBlank(CharSequence cs, String message) {
int strLen;
if (cs != null && (strLen = cs.length()) != 0) {
for (int i = 0; i < strLen; ++i) {
if (!Character.isWhitespace(cs.charAt(i))) {
throw new CustomizeRunTimeException(message);
}
}
}
}
public static void notBlank(CharSequence cs, String message) {
int strLen;
if (cs != null && (strLen = cs.length()) != 0) {
for (int i = 0; i < strLen; ++i) {
if (Character.isWhitespace(cs.charAt(i))) {
throw new CustomizeRunTimeException(message);
}
}
}
if (cs == null || cs.length() == 0) {
throw new CustomizeRunTimeException(message);
}
}
}

@ -0,0 +1,94 @@
package com.engine.matfron.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @Author liang.cheng
* @Date 2023/9/27 4:44 PM
* @Description:
* @Version 1.0
*/
@Slf4j
public class CommonDateUtil {
public static final String DATE_FORMATTER_PATTERN = "yyyy-MM-dd";
/**
* YearMonthDate
* dayOfMonth13122928
* 使toDateEndOfMonth(YearMonth)
*
* @param yearMonth
* @param dayOfMonth
* @return
*/
public static Date toDate(YearMonth yearMonth, int dayOfMonth) {
Objects.requireNonNull(yearMonth, "yearMonth");
return localDateToDate(yearMonth.atDay(dayOfMonth));
}
/**
* YearMonthDate
*
* @param yearMonth
* @return
*/
public static Date toDateStartOfMonth(YearMonth yearMonth) {
return toDate(yearMonth, 1);
}
/**
* YearMonthDate
*
* @param yearMonth
* @return
*/
public static Date toDateEndOfMonth(YearMonth yearMonth) {
Objects.requireNonNull(yearMonth, "yearMonth");
return localDateToDate(yearMonth.atEndOfMonth());
}
public static Date localDateToDate(LocalDate localDate) {
if (null == localDate) {
return null;
}
ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
return Date.from(zonedDateTime.toInstant());
}
public static String getFormatYear(Date localDate) {
if (localDate == null) {
return StringUtils.EMPTY;
}
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMATTER_PATTERN);
return simpleDateFormat.format(localDate);
} catch (Exception e) {
log.warn("格式化年份错误", e);
return StringUtils.EMPTY;
}
}
public static List<YearMonth> getYearMonths(LocalDate date) {
List<YearMonth> yearMonths = new ArrayList<>();
for (int month = 1; month <= 12; month++) {
LocalDate firstDayOfMonth = date.withMonth(month);
yearMonths.add(YearMonth.from(firstDayOfMonth));
}
return yearMonths;
}
}

@ -0,0 +1,34 @@
package com.engine.matfron.util;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
/**
* @Author liang.cheng
* @Date 2023/9/27 4:52 PM
* @Description: TODO
* @Version 1.0
*/
public class CommonUtils {
public static LocalDate parseLocalDate(String dateString) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return LocalDate.parse(dateString, formatter);
}
public static int calculateAge(LocalDate birthday) {
LocalDate currentDate = LocalDate.now();
return Period.between(birthday, currentDate).getYears();
}
public static int roundUpToNearestTen(int num) {
return (num + 9) / 10 * 10;
}
public static int roundedMax(int ceil,int copies){
return ceil * copies;
}
}

@ -0,0 +1,20 @@
package com.engine.matfron.util;
/**
* @Author weaver_cl
* @Description:
* @Date 2023/2/21
* @Version V1.0
**/
public class ExceptionUtil {
public static String getRealMessage(Throwable e) {
while (e != null) {
Throwable cause = e.getCause();
if (cause == null) {
return e.getMessage();
}
e = cause;
}
return "";
}
}

@ -0,0 +1,185 @@
package com.engine.matfron.util;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.core.exception.ECException;
import com.engine.matfron.exception.CustomizeRunTimeException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import weaver.general.BaseBean;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@Slf4j
public class ResponseResult<T, R> {
private static final long serialVersionUID = 1L;
private final User user;
private final BaseBean baseBean = new BaseBean();
private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log"));
public ResponseResult(User user) {
this.user = user;
}
/**
* ()
*/
public String customRun(Function<T, R> f, T t) {
try {
if (isLog) {
log.info("run api , param {}", t);
}
return getJsonString(f.apply(t));
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
Throwable cause = e.getCause();
return Error(cause.getMessage());
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!");
}
}
/**
*
*/
public String run(Function<T, R> f, T t) {
try {
if (isLog) {
log.info("run api , param {}", t);
}
return Ok(f.apply(t));
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
Throwable cause = e.getCause();
return Error(cause.getMessage());
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!");
}
}
/**
*
*/
public String run(Consumer<T> f, T t) {
try {
if (isLog) {
log.info("run api , param {}", t);
}
f.accept(t);
return Ok();
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
return Error(ExceptionUtil.getRealMessage(e));
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!", e);
}
}
/**
*
*/
public String run(Supplier<R> f) {
try {
if (isLog) {
log.info("run api");
}
return Ok(f.get());
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
Throwable cause = e.getCause();
return Error(cause.getMessage());
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!", e);
}
}
private static String getJsonString(Object apidatas) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(apidatas);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return "";
}
/**
*
*/
private String Ok() {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("status", true);
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
}
/**
*
*/
private String Ok(R r) {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("status", true);
apidatas.put("data", r);
String success = getJsonString(apidatas);
if (isLog) {
log.info("run salary api success return {}", success);
}
return success;
}
/**
*
*/
private static String Error(String message) {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("status", false);
apidatas.put("errormsg", message);
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
}
/**
*
*/
private static String Error(String message, Exception e) {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("status", false);
apidatas.put("errormsg", message);
apidatas.put("error", e.getMessage());
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
}
}

@ -0,0 +1,130 @@
package com.engine.matfron.web;
import com.engine.common.util.ServiceUtil;
import com.engine.matfron.entity.OptionVO;
import com.engine.matfron.entity.PortalTopVO;
import com.engine.matfron.service.StatisticsPortalService;
import com.engine.matfron.service.impl.StatisticsPortalServiceImpl;
import com.engine.matfron.util.ResponseResult;
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.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.LinkedList;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/9/26 5:51 PM
* @Description:
* @Version 1.0
*/
public class StatisticsPortalAction {
private StatisticsPortalService getCommonDutyService(User user) {
return ServiceUtil.getService(StatisticsPortalServiceImpl.class,user);
}
@GET
@Path("/statistics/top")
@Produces(MediaType.APPLICATION_JSON)
public String getPortalTop(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, LinkedList<PortalTopVO>>(user).run(getCommonDutyService(user) :: getPortalTop);
}
@GET
@Path("/statistics/department")
@Produces(MediaType.APPLICATION_JSON)
public String getPortalDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalDepartment);
}
@GET
@Path("/statistics/subcompany")
@Produces(MediaType.APPLICATION_JSON)
public String getPortalSubCompany(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalSubCompany);
}
@GET
@Path("/statistics/homePlace")
@Produces(MediaType.APPLICATION_JSON)
public String getHomePlace(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getHomePlace);
}
@GET
@Path("/statistics/ethnic")
@Produces(MediaType.APPLICATION_JSON)
public String getPortalEthnic(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalEthnic);
}
@GET
@Path("/statistics/educational")
@Produces(MediaType.APPLICATION_JSON)
public String getEducational(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getEducational);
}
@GET
@Path("/statistics/surname")
@Produces(MediaType.APPLICATION_JSON)
public String getSurname(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getSurname);
}
@GET
@Path("/statistics/ageAndSex")
@Produces(MediaType.APPLICATION_JSON)
public String getAgeAndSex(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getAgeAndSex);
}
@GET
@Path("/statistics/jobType")
@Produces(MediaType.APPLICATION_JSON)
public String getJobType(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getJobType);
}
@GET
@Path("/statistics/leaveMonth")
@Produces(MediaType.APPLICATION_JSON)
public String getLeaveMonth(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("departmentIds") String departmentIds) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, Map<String,Object>>(user).run(getCommonDutyService(user) :: getLeaveMonth,departmentIds);
}
@GET
@Path("/statistics/leaveYear")
@Produces(MediaType.APPLICATION_JSON)
public String getLeaveYear(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam("departmentIds") String departmentIds) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, Map<String,Object>>(user).run(getCommonDutyService(user) :: getLeaveYear,departmentIds);
}
}

@ -1,5 +1,15 @@
package test;
import com.engine.matfron.entity.SurnameParam;
import com.engine.matfron.util.CommonDateUtil;
import emo.doors.b;
import weaver.hrm.company.DepartmentComInfo;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Author weaver_cl
* @Description:
@ -10,5 +20,9 @@ public class MainTest {
public static void main(String[] args) {
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
}
}

@ -1,135 +0,0 @@
package weaver.interfaces.gsjrkg.action;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
/**
* @Description:
* @author:dxfeng
* @createTime: 2023/02/20
* @version: 1.0
*/
public class SyncCertificateAction implements Action {
/**
*
*/
private String modeTableName;
/**
*
*/
private String params;
private String resourceFieldGroup;
@Override
public String execute(RequestInfo requestInfo) {
if (StringUtils.isBlank(params)) {
requestInfo.getRequestManager().setMessagecontent("自定义接口参数值配置错误");
return Action.FAILURE_AND_CONTINUE;
}
if (StringUtils.isBlank(resourceFieldGroup)) {
// -1:基本信息,1:个人信息,3:工作信息
resourceFieldGroup = "1";
}
Map<String, String> fieldMap = new HashMap<>();
String[] fieldsArray = params.split(";");
for (String fields : fieldsArray) {
String[] field = fields.split(":");
if (field.length == 2) {
fieldMap.put(field[0], field[1]);
}
}
if (fieldMap.size() != fieldsArray.length) {
requestInfo.getRequestManager().setMessagecontent("自定义接口参数值格式错误,请检查");
return Action.FAILURE_AND_CONTINUE;
}
Set<String> modeFields = fieldMap.keySet();
Map<String, Set<String>> modeMap = new HashMap<>();
RecordSet rs = new RecordSet();
String resourceId = "";
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] property = mainTableInfo.getProperty();
for (Property item : property) {
String name = item.getName();
String value = Util.null2String(item.getValue());
if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
if ("xm".equals(name)) {
resourceId = value;
}
}
}
// 查询当前人员的所有数据
StringBuilder sqlBuilder = new StringBuilder("select ").append(StringUtils.join(modeFields, ",")).append(" from ").append(modeTableName).append(" where xm = ").append(resourceId).append(" order by id");
rs.executeQuery(sqlBuilder.toString());
while (rs.next()) {
appendIds(modeFields, rs, modeMap);
}
// 判断有无数据,没有的话插入数据
sqlBuilder = new StringBuilder("SELECT id FROM CUS_FIELDDATA where scope ='HrmCustomFieldByInfoType' and scopeid = '").append(resourceFieldGroup).append("' and id =? ");
rs.executeQuery(sqlBuilder.toString(), resourceId);
if (!rs.next()) {
// 插入人员信息数据
rs.executeUpdate("insert into cus_fielddata (scope,scopeid,id) values ('HrmCustomFieldByInfoType','" + resourceFieldGroup + "',?)", resourceId);
}
// 组装更新SQL语句
sqlBuilder = new StringBuilder("update cus_fielddata set ");
for (Map.Entry<String, String> entry : fieldMap.entrySet()) {
Set<String> valueSet = modeMap.get(entry.getKey());
String values = CollectionUtils.isEmpty(valueSet) ? "" : StringUtils.join(valueSet, ",");
sqlBuilder.append(" ").append(entry.getValue()).append(" = '").append(values).append("',");
}
sqlBuilder.deleteCharAt(sqlBuilder.length() - 1);
sqlBuilder.append(" where scope ='HrmCustomFieldByInfoType' and scopeid = ").append(resourceFieldGroup).append(" and id = ").append(resourceId);
rs.executeUpdate(sqlBuilder.toString());
return Action.SUCCESS;
}
private void appendIds(Set<String> modeFields, RecordSet rs, Map<String, Set<String>> modeMap) {
for (String modeField : modeFields) {
String ids = rs.getString(modeField);
if (StringUtils.isBlank(ids)) {
return;
}
if (CollectionUtils.isEmpty(modeMap.get(modeField))) {
modeMap.put(modeField, new HashSet<>());
}
modeMap.get(modeField).addAll(Arrays.asList(ids.split(",")));
}
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public String getModeTableName() {
return modeTableName;
}
public void setModeTableName(String modeTableName) {
this.modeTableName = modeTableName;
}
public String getResourceFieldGroup() {
return resourceFieldGroup;
}
public void setResourceFieldGroup(String resourceFieldGroup) {
this.resourceFieldGroup = resourceFieldGroup;
}
}
Loading…
Cancel
Save