Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
|
62496a31d9 | 9 months ago |
|
9996672826 | 9 months ago |
|
774316c8ae | 12 months ago |
|
3597676b36 | 1 year ago |
|
1f7070c611 | 2 years ago |
|
884052dc1d | 2 years ago |
|
cf8841a775 | 2 years ago |
|
dee3855003 | 2 years ago |
|
bc855b294b | 2 years ago |
@ -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,30 @@
|
||||
package com.engine.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/8/6 9:31 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PersonStatisticsPo {
|
||||
|
||||
private Integer dataId;
|
||||
|
||||
/**
|
||||
* 1分部 2部门
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
|
||||
private Integer onJob;
|
||||
}
|
@ -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 = "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,120 @@
|
||||
package weaver.interfaces.akx.cronjob;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.engine.entity.PersonStatisticsPo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.company.SubCompanyComInfo;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/8/6 9:27 AM
|
||||
* @Description: 分部部门汇总人数统计
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class PersonStatisticsCron extends BaseCronJob {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
//1.需要更新的数据List
|
||||
List<PersonStatisticsPo> list = new ArrayList<>();
|
||||
|
||||
//2.分部数据
|
||||
rs.executeQuery("select id from hrmsubcompany");
|
||||
while (rs.next()) {
|
||||
list.add(PersonStatisticsPo.builder().dataId(Util.getIntValue(rs.getString("id"))).type(1).build());
|
||||
}
|
||||
|
||||
//3.部门数据
|
||||
rs.executeQuery("select id from hrmdepartment");
|
||||
while (rs.next()) {
|
||||
list.add(PersonStatisticsPo.builder().dataId(Util.getIntValue(rs.getString("id"))).type(2).build());
|
||||
}
|
||||
|
||||
// 核心线程数
|
||||
int corePoolSize = 5;
|
||||
// 最大线程数
|
||||
int maxPoolSize = 10;
|
||||
// 设置每个子列表的大小
|
||||
int batchSize = 100;
|
||||
|
||||
List<List<PersonStatisticsPo>> splittedLists = splitList(list, batchSize);
|
||||
// 创建线程池
|
||||
ExecutorService executorService = ThreadUtil.newExecutor(corePoolSize, maxPoolSize);
|
||||
|
||||
// 遍历每个子列表,并提交给线程池执行
|
||||
for (List<PersonStatisticsPo> subList : splittedLists) {
|
||||
executorService.submit(() -> {
|
||||
// 在此处编写处理子列表的逻辑
|
||||
for (PersonStatisticsPo personStatisticsPo : subList) {
|
||||
// 处理逻辑
|
||||
buildCount(personStatisticsPo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 关闭线程池
|
||||
executorService.shutdown();
|
||||
// 等待线程池关闭
|
||||
while (!executorService.isTerminated()) {
|
||||
// 空循环等待线程池终止
|
||||
}
|
||||
|
||||
for (PersonStatisticsPo item : list) {
|
||||
if (item.getType() == 1) {
|
||||
rs.executeUpdate("update hrmsubcompanydefined set rstj = ? where subcomid = ?",item.getOnJob(),item.getDataId());
|
||||
}else {
|
||||
rs.executeUpdate("update hrmdepartmentdefined set rstj = ? where deptid = ?",item.getOnJob(),item.getDataId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private <T> List<List<T>> splitList(List<T> list, int batchSize) {
|
||||
List<List<T>> splittedLists = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += batchSize) {
|
||||
int endIndex = Math.min(i + batchSize, list.size());
|
||||
List<T> subList = list.subList(i, endIndex);
|
||||
splittedLists.add(subList);
|
||||
}
|
||||
return splittedLists;
|
||||
}
|
||||
|
||||
|
||||
private PersonStatisticsPo buildCount(PersonStatisticsPo ps) {
|
||||
RecordSet rs = new RecordSet();
|
||||
DepartmentComInfo dept = new DepartmentComInfo();
|
||||
SubCompanyComInfo subCompany = new SubCompanyComInfo();
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
list.add(ps.getDataId());
|
||||
StringBuilder onJob = new StringBuilder();
|
||||
|
||||
if (ps.getType() == 1) {
|
||||
subCompany.getSubCompanyLists(String.valueOf(ps.getDataId()), list);
|
||||
String value = StringUtils.join(list,",");
|
||||
onJob.append("select count(1) from hrmresource where status < 4 and subcompanyid1 in (").append(value).append(")");
|
||||
}else {
|
||||
dept.getAllChildDeptByDepId(list,String.valueOf(ps.getDataId()));
|
||||
String value = StringUtils.join(list,",");
|
||||
onJob.append("select count(1) as count from hrmresource where status < 4 and departmentid in (").append(value).append(")");
|
||||
}
|
||||
|
||||
rs.executeQuery(onJob.toString());
|
||||
rs.next();
|
||||
ps.setOnJob(Util.getIntValue(rs.getString("count"),0));
|
||||
|
||||
return ps;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue