diff --git a/src/com/api/hzzx/web/RecruitDemandController.java b/src/com/api/hzzx/web/RecruitDemandController.java new file mode 100644 index 0000000..5409b48 --- /dev/null +++ b/src/com/api/hzzx/web/RecruitDemandController.java @@ -0,0 +1,12 @@ +package com.api.hzzx.web; + +import javax.ws.rs.Path; + +/** + * @author:dxfeng + * @createTime: 2025/03/25 + * @version: 1.0 + */ +@Path("/jcl/recruit/demand") +public class RecruitDemandController extends com.engine.hzzx.web.RecruitDemandController{ +} diff --git a/src/com/engine/hzzx/conn/DataUtil.java b/src/com/engine/hzzx/conn/DataUtil.java index a187dc3..039e46e 100644 --- a/src/com/engine/hzzx/conn/DataUtil.java +++ b/src/com/engine/hzzx/conn/DataUtil.java @@ -55,6 +55,22 @@ public class DataUtil { return formModeId; } + /** + * 根据表名,获取表单ID + * + * @param modeTable + * @return + */ + public static int getFormIdByTableName(String modeTable) { + int formId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from workflow_bill where tablename = ? ", modeTable); + if (rs.next()) { + formId = rs.getInt("id"); + } + return formId; + } + /** * 插入数据 * @@ -81,6 +97,32 @@ public class DataUtil { } } + /** + * 根据ID更新数据 + * + * @param dataMap + * @param tableName + */ + public static void updateDataById(Map dataMap, String tableName) { + List fieldList = new ArrayList<>(); + List dataList = new ArrayList<>(); + String id = Util.null2String(dataMap.get("id")); + dataMap.remove("id"); + + dataMap.forEach((key, value) -> { + fieldList.add(key + " = ? "); + dataList.add(value); + }); + dataList.add(id); + String updateSql = "update " + tableName + " set " + StringUtils.join(fieldList, ",") + " where id = ? "; + RecordSet rs = new RecordSet(); + rs.executeUpdate(updateSql, dataList); + if (StringUtils.isNotBlank(rs.getExceptionMsg())) { + throw new CustomizeRunTimeException(rs.getExceptionMsg()); + } + } + + /** * 构建建模表基本数据 diff --git a/src/com/engine/hzzx/entity/RecruitingPlan.java b/src/com/engine/hzzx/entity/RecruitingPlan.java new file mode 100644 index 0000000..897b748 --- /dev/null +++ b/src/com/engine/hzzx/entity/RecruitingPlan.java @@ -0,0 +1,42 @@ +package com.engine.hzzx.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2025/03/20 + * @version: 1.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class RecruitingPlan { + public RecruitingPlan(Integer departmentId) { + this.departmentId = departmentId; + } + + public RecruitingPlan(Integer departmentId, Integer onJobNumber) { + this.departmentId = departmentId; + this.onJobNumber = onJobNumber; + } + + public RecruitingPlan(Integer departmentId, Integer plannedNumber, Integer onJobNumber) { + this.departmentId = departmentId; + this.plannedNumber = plannedNumber; + this.onJobNumber = onJobNumber; + } + + private Integer departmentId; + private Integer plannedNumber; + private Integer onJobNumber; + private Integer totalNumber; + + public Integer getTotalNumber() { + return plannedNumber + onJobNumber; + } + +} diff --git a/src/com/engine/hzzx/service/RecruitDemandService.java b/src/com/engine/hzzx/service/RecruitDemandService.java new file mode 100644 index 0000000..9541b90 --- /dev/null +++ b/src/com/engine/hzzx/service/RecruitDemandService.java @@ -0,0 +1,19 @@ +package com.engine.hzzx.service; + +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2025/03/25 + * @version: 1.0 + */ +public interface RecruitDemandService { + + /** + * 获取招聘需求列表 + * + * @param params + * @return + */ + Map getRecruitDemandList(Map params); +} diff --git a/src/com/engine/hzzx/service/impl/RecruitDemandServiceImpl.java b/src/com/engine/hzzx/service/impl/RecruitDemandServiceImpl.java new file mode 100644 index 0000000..c4a818b --- /dev/null +++ b/src/com/engine/hzzx/service/impl/RecruitDemandServiceImpl.java @@ -0,0 +1,74 @@ +package com.engine.hzzx.service.impl; + +import com.engine.core.impl.Service; +import com.engine.hzzx.entity.RecruitingPlan; +import com.engine.hzzx.service.RecruitDemandService; +import org.apache.commons.collections.CollectionUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2025/03/25 + * @version: 1.0 + */ +public class RecruitDemandServiceImpl extends Service implements RecruitDemandService { + @Override + public Map getRecruitDemandList(Map params) { + RecordSet rs = new RecordSet(); + // 查询当前年度提交的数据 + rs.executeQuery("select * from uf_zpxqhztz where sqrq '" + DateUtil.getYear() + "'"); + List mainIds = new ArrayList<>(); + while (rs.next()) { + mainIds.add(rs.getString("id")); + } + + // 查询明细表数据 + List recruitingPlans = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(mainIds)) { + rs.executeQuery("select * from uf_zpxqhztz_dt1 where mainid in (" + String.join(",", mainIds) + ")"); + while (rs.next()) { + recruitingPlans.add(new RecruitingPlan(rs.getInt("zpbm"), rs.getInt("xqrs"), 0)); + } + } + // 遍历recruitingPlans 汇总相同部门下的总招聘人数 + // 创建一个Map来保存部门及其对应的总招聘人数 + Map departmentSum = new HashMap<>(); + + // 遍历recruitingPlans列表 + for (RecruitingPlan plan : recruitingPlans) { + int department = plan.getDepartmentId(); + int required = plan.getPlannedNumber(); + if (required < 0) { + required = 0; + } + + // 将需求人数累加到对应部门的统计中 + departmentSum.put( + department, + departmentSum.getOrDefault(department, 0) + required + ); + } + + // 汇总部门数据 + List resultList = new ArrayList<>(); + departmentSum.forEach((department, requiredTotal) -> { + // 查询当年年度统计的年末在岗人数 + int onJobNumber = 0; + rs.executeQuery("select nmzgrs from uf_nmgbmzgrs where nd = '" + DateUtil.getYear() + "' and bm = " + department); + if (rs.next()) { + onJobNumber = rs.getInt("nmzgrs"); + } + resultList.add(new RecruitingPlan(department, onJobNumber, requiredTotal)); + }); + + Map resultMap = new HashMap<>(); + resultMap.put("details", resultList); + return resultMap; + } +} diff --git a/src/com/engine/hzzx/web/RecruitDemandController.java b/src/com/engine/hzzx/web/RecruitDemandController.java new file mode 100644 index 0000000..677dc95 --- /dev/null +++ b/src/com/engine/hzzx/web/RecruitDemandController.java @@ -0,0 +1,39 @@ +package com.engine.hzzx.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.hzzx.service.RecruitDemandService; +import com.engine.hzzx.service.impl.RecruitDemandServiceImpl; +import com.engine.hzzx.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.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2025/03/25 + * @version: 1.0 + */ +public class RecruitDemandController { + public RecruitDemandService getService(User user) { + return ServiceUtil.getService(RecruitDemandServiceImpl.class, user); + } + + @GET + @Path("/getRecruitDemandList") + @Produces(MediaType.APPLICATION_JSON) + public String getRecruitDemandList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getService(user)::getRecruitDemandList, params); + + } +} diff --git a/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java b/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java index 4e24e5e..e25ab30 100644 --- a/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java +++ b/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java @@ -43,7 +43,7 @@ public class TrainingApplicationAction implements Action { DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo(); DetailTable[] detailTables = detailTableInfo.getDetailTable(); for (int i = 0; i < detailTables.length; i++) { - String detailTableName = MODE_TABLE_NAME + "_" + (i + 1); + String detailTableName = MODE_TABLE_NAME + "_dt" + (i + 1); DetailTable table = detailTables[i]; Row[] rows = table.getRow(); for (Row row : rows) { diff --git a/src/weaver/interfaces/hzzx/cronjob/RecordUserCountJob.java b/src/weaver/interfaces/hzzx/cronjob/RecordUserCountJob.java new file mode 100644 index 0000000..0dbca69 --- /dev/null +++ b/src/weaver/interfaces/hzzx/cronjob/RecordUserCountJob.java @@ -0,0 +1,141 @@ +package weaver.interfaces.hzzx.cronjob; + +import com.engine.hzzx.conn.DataUtil; +import com.engine.hzzx.entity.RecruitingPlan; +import com.engine.hzzx.exception.CustomizeRunTimeException; +import org.apache.commons.collections.CollectionUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.*; + +/** + * @author:dxfeng + * @createTime: 2025/03/20 + * @version: 1.0 + */ +public class RecordUserCountJob extends BaseCronJob { + private static final String MAIN_TABLE = "uf_nmgbmzgrs"; + private static final String OPERATE_ID = "1"; + + RecordSet rs = new RecordSet(); + + @Override + public void execute() { + try { + String sql = "select id from hrmdepartment where ISNULL(SUPDEPID,0)=0 and ISNULL(CANCELED,0)=0 "; + rs.executeQuery(sql); + List recruitingPlanList = new ArrayList<>(); + while (rs.next()) { + fillDepartmentInfo(rs.getInt("id"), recruitingPlanList); + } + + // 遍历recruitingPlanList,插入明细表数据 + for (RecruitingPlan plan : recruitingPlanList) { + insertMainData(plan, DateUtil.getCurrentDate()); + } + + + } catch (Exception e) { + throw new CustomizeRunTimeException(e.getMessage()); + } + } + + /** + * 遍历部门,查询部门下在岗人数 + * + * @param departmentId + * @param recruitingPlanList + * @return + */ + private int fillDepartmentInfo(Integer departmentId, List recruitingPlanList) { + if (departmentId == null || departmentId < 0) { + return 0; + } + // 查询当前部门下的在岗人数 + int userCount = countUsersByDeptId(departmentId); + + List childDepartmentIdList = getChildDepartmentId(departmentId); + if (CollectionUtils.isNotEmpty(childDepartmentIdList)) { + for (Integer childDepartmentId : childDepartmentIdList) { + userCount += fillDepartmentInfo(childDepartmentId, recruitingPlanList); + } + } + recruitingPlanList.add(new RecruitingPlan(departmentId, userCount)); + return userCount; + } + + + /** + * 插入主表数据 + * + * @param plan + * @return + */ + private String insertMainData(RecruitingPlan plan,String year) { + rs.executeQuery("select id from " + MAIN_TABLE + " where nd = ? and bm = ? ",year , plan.getDepartmentId()); + if(rs.next()){ + Map updateData = new HashMap<>(); + DataUtil.buildModeUpdateFields(updateData, OPERATE_ID); + updateData.put("id", rs.getString("id")); + updateData.put("nmzgrs",plan.getOnJobNumber() + ""); + } + + // 插入基本数据 + Map insertData = new HashMap<>(); + DataUtil.buildModeInsertFields(insertData, OPERATE_ID); + String uuid = UUID.randomUUID().toString(); + insertData.put("modeuuid", uuid); + int formModeId = DataUtil.getModeIdByTableName(MAIN_TABLE); + insertData.put("formmodeid", String.valueOf(formModeId)); + insertData.put("nd", year); + insertData.put("bm", plan.getDepartmentId() + ""); + insertData.put("nmzgrs", plan.getOnJobNumber() + ""); + + DataUtil.insertData(insertData, MAIN_TABLE); + int id = DataUtil.refreshRight(uuid, MAIN_TABLE, formModeId, OPERATE_ID); + if (id > 0) { + return String.valueOf(id); + } + return ""; + } + + /** + * 查询子部门 + * + * @param departmentId + * @return + */ + private List getChildDepartmentId(Integer departmentId) { + List departmentIdList = new ArrayList<>(); + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from HrmDepartment where supdepid = ?", departmentId); + while (rs.next()) { + departmentIdList.add(rs.getInt("id")); + } + return departmentIdList; + } + + + /** + * 查询部门下在岗人数 + * + * @param departmentId + * @return + */ + private int countUsersByDeptId(Integer departmentId) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select count(id) from hrmresource where departmentid = ?", departmentId); + if (rs.next()) { + return rs.getInt(1); + } + return 0; + } + + private int countPlanedNum(Integer departmentId) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select count(id) from uf_zpxqhztzaz where zpbm = ? and sqrq like '%" + DateUtil.getYear() + "%' ", departmentId); + return 0; + } +} diff --git a/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java b/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java index fff0b1a..3352fc4 100644 --- a/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java +++ b/src/weaver/interfaces/hzzx/cronjob/SyncBeiSenInfoJob.java @@ -266,6 +266,7 @@ public class SyncBeiSenInfoJob extends BaseCronJob { objectId = UUID.randomUUID().toString(); } int formModeId = DataUtil.getModeIdByTableName(EMPLOYEE_TABLE); + int formId = DataUtil.getFormIdByTableName(EMPLOYEE_TABLE); // 构建插入数据 insertData.put("xm", employee.getName()); @@ -276,7 +277,8 @@ public class SyncBeiSenInfoJob extends BaseCronJob { String politicalStr = EmployeeTrans.getPoliticalStr(employee.getPoliticalStatus()); rs.writeLog("政治面貌Str==" + politicalStr); if (StringUtils.isNotBlank(politicalStr)) { - String zzmm = DataUtil.getSelectValue(String.valueOf(formModeId), "zzmm", politicalStr); + rs.writeLog("formId==" + formId); + String zzmm = DataUtil.getSelectValue(String.valueOf(formId), "zzmm", politicalStr); rs.writeLog("政治面貌Id==" + zzmm); insertData.put("zzmm", zzmm); } @@ -296,7 +298,7 @@ public class SyncBeiSenInfoJob extends BaseCronJob { insertData.put("xl", educationLevelId); } // 学校 - // TODO insertData.put("xx", employee.getLastSchool()); + insertData.put("xx", employee.getLastSchool()); // 专业 insertData.put("zy", employee.getMajor()); // 工作年限