安科讯
Chengliang 9 months ago
parent 59e17ca9f5
commit 248c9ad2ba

@ -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 = "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,272 @@
package weaver.interfaces.akx.cronjob;
import com.alibaba.fastjson.JSON;
import com.weaver.formmodel.mobile.appio.exports.beans.SqlDataBean;
import com.weaver.formmodel.util.DateHelper;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.conn.StringUtil;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.*;
import java.util.stream.Collectors;
/**
* 宿
*
* @author:dxfeng
* @createTime: 2024/04/10
* @version: 1.0
*/
public class CalculateCostsJob extends BaseCronJob {
private String calculateDate;
private String modeId;
@Override
public void execute() {
String currentDate = DateUtil.getCurrentDate();
// 未指定计算月份,默认计算当前月份
if (StringUtils.isBlank(calculateDate)) {
calculateDate = currentDate;
}
// 需要计算的月份
String calculateMonth = calculateDate.substring(0, 7);
// 当前月份
String currentMonth = currentDate.substring(0, 7);
// 计算的开始时间
String startDay = DateUtil.getFirstDayOfMonth(calculateDate);
// 计算的结束时间
String endDay = DateUtil.getLastDayOfMonth(calculateDate);
// 当前月的最后一天取当前时间,非当前月的取指定月的最后一天
endDay = calculateMonth.equals(currentMonth) ? currentDate : endDay;
RecordSet rs = new RecordSet();
String updateSql = "update uf_rysdftz set ts = ?, sdf = ? where ry = ? and ld = ? and yf = ? ";
String insertSql = "insert into uf_rysdftz ( formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, modeuuid, ts, yf, cs, qy, ld, ry, sdf) values(" + modeId + ", 1, 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
try {
rs.writeLog("当前计算日期:" + calculateDate + ",水电费计算计划任务开始------");
// 查询入住日期<=当前日期,且转出日期>=当前日期,或未转出的数据
String sql = "select * from uf_rygl where rzsj <= ?";
rs.executeQuery(sql, calculateDate);
List<PersonnelManagement> personnelManagementList = new ArrayList<>();
while (rs.next()) {
String zcsj = rs.getString("zcsj");
if (StringUtils.isNotBlank(zcsj)) {
boolean equals = zcsj.substring(0, 7).equals(calculateDate);
if (!equals) {
continue;
}
}
PersonnelManagement personnelManagement = new PersonnelManagement();
personnelManagement.setLd(rs.getString("ld"));
personnelManagement.setYg(rs.getString("yg"));
personnelManagement.setRzsj(rs.getString("rzsj"));
personnelManagement.setZcsj(zcsj);
personnelManagementList.add(personnelManagement);
}
// 查询当月所有楼栋的水电费标准
Map<String, Double> costMap = new HashMap<>();
sql = "select * from uf_sdfbz where yf = ?";
rs.executeQuery(sql, calculateMonth);
while (rs.next()) {
costMap.put(rs.getString("ld"), rs.getDouble("sdfbz"));
}
// 计算当月的入住天数和费用
Map<String, Map<String, List<PersonnelManagement>>> managementMap = personnelManagementList.stream().collect(Collectors.groupingBy(PersonnelManagement::getYg, Collectors.groupingBy(PersonnelManagement::getLd)));
for (Map.Entry<String, Map<String, List<PersonnelManagement>>> entry : managementMap.entrySet()) {
String yg = entry.getKey();
Map<String, List<PersonnelManagement>> ldMap = entry.getValue();
for (Map.Entry<String, List<PersonnelManagement>> item : ldMap.entrySet()) {
String ld = item.getKey();
Double sdfbz = costMap.get(ld);
// 未查询到当前楼栋、当前月份的水电费标准,不做计算
if (null == sdfbz || -1 == sdfbz) {
rs.writeLog("当前楼栋[" + ld + "],未查询到[" + calculateMonth + "]月份的水电费标准,跳过本楼栋水电费计算");
continue;
}
List<PersonnelManagement> ldList = item.getValue();
// 计算入住的所有的天数
int currentMonthCount = 0;
for (PersonnelManagement management : ldList) {
String rzsj = management.getRzsj();
String zcsj = management.getZcsj();
currentMonthCount += calculateDays(rzsj, zcsj, startDay, endDay);
}
// 计算当前人员、当前楼栋的水电费,总入住天数*水电费标准
Double total = currentMonthCount * sdfbz;
// 查询当前人员,当前月份、当前楼栋,是否在水电费管理台账存在
sql = "select * from uf_rysdftz where ry = ? and ld = ? and yf = ? ";
rs.executeQuery(sql, yg, ld, calculateMonth);
if (rs.next()) {
// 做更新操作
List<String> paramList = new ArrayList<>();
paramList.add(String.valueOf(currentMonthCount));
paramList.add(String.valueOf(total));
paramList.add(yg);
paramList.add(ld);
paramList.add(calculateMonth);
rs.executeUpdate(updateSql, paramList);
rs.writeLog("updateSql" + updateSql + "------params=" + JSON.toJSONString(paramList));
} else {
String cs = "";
String qy = "";
sql = "select * from uf_ldwh where id = ?";
rs.executeQuery(sql, ld);
if (rs.next()) {
cs = rs.getString("cs");
qy = rs.getString("qy");
}
List<String> paramList = new ArrayList<>();
// modedatacreatedate
paramList.add(DateHelper.getCurrentDate());
// modedatacreatetime
paramList.add(DateHelper.getCurrentTime());
// modeuuid
String uuid = UUID.randomUUID().toString();
paramList.add(uuid);
// ts
paramList.add(String.valueOf(currentMonthCount));
// yf
paramList.add(calculateMonth);
// cs
paramList.add(cs);
// qy
paramList.add(qy);
// ld
paramList.add(ld);
// ry
paramList.add(yg);
// sdf
paramList.add(String.valueOf(total));
// 做插入操作
rs.executeUpdate(insertSql, paramList);
rs.writeLog("insertSql" + insertSql + "------params=" + JSON.toJSONString(paramList));
// 刷新权限
rs.executeQuery("select id from uf_rysdftz where modeuuid='" + uuid + "'");
if (rs.next()) {
//建模数据的id
int bid = Util.getIntValue(rs.getString("id"));
ModeRightInfo modeRightInfo = new ModeRightInfo();
modeRightInfo.setNewRight(true);
//新建的时候添加共享
modeRightInfo.editModeDataShare(1, Integer.parseInt(modeId), bid);
}
}
}
}
rs.writeLog("当前计算日期:" + calculateDate + ",水电费计算计划任务结束------");
} catch (Exception e) {
rs.writeLog("当前计算日期:" + calculateDate + ",水电费计算计划任务异常");
rs.writeLog(e);
}
}
/**
*
*
* @param rzsj
* @param zcsj
* @param startDay
* @param endDay
* @return
*/
private int calculateDays(String rzsj, String zcsj, String startDay, String endDay) {
String firstDate = rzsj;
// 比较入住时间和当月开始时间
int compStartDate = DateUtil.compDate(rzsj, startDay);
// 开始时间大于入职时间,取开始时间
if (compStartDate > 0) {
firstDate = startDay;
}
String lastDate = zcsj;
if (StringUtils.isBlank(zcsj)) {
lastDate = endDay;
}
int compEndDate = DateUtil.compDate(zcsj, endDay);
// 结束时间小于转出时间,取结束时间
if (compEndDate < 0) {
lastDate = endDay;
}
// 实际天数为相差的天数+1
return DateUtil.compDate(firstDate, lastDate) + 1;
}
/**
*
*/
private static class PersonnelManagement {
// 楼栋
private String ld;
// 员工
private String yg;
// 入住日期
private String rzsj;
// 转出日期
private String zcsj;
public String getLd() {
return ld;
}
public void setLd(String ld) {
this.ld = ld;
}
public String getYg() {
return yg;
}
public void setYg(String yg) {
this.yg = yg;
}
public String getRzsj() {
return rzsj;
}
public void setRzsj(String rzsj) {
this.rzsj = rzsj;
}
public String getZcsj() {
return zcsj;
}
public void setZcsj(String zcsj) {
this.zcsj = zcsj;
}
}
public String getCalculateDate() {
return calculateDate;
}
public void setCalculateDate(String calculateDate) {
this.calculateDate = calculateDate;
}
public String getModeId() {
return modeId;
}
public void setModeId(String modeId) {
this.modeId = modeId;
}
public static void main(String[] args) {
String startDate = "2024-03-01";
String endDate = "2024-03-31";
int i = DateUtil.compDate(startDate, endDate);
System.out.println(i);
}
}

@ -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;
}
}

@ -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