refactor(entry): 新增编制校验

招需流程-增加编制校验动作流
This commit is contained in:
dxfeng 2025-08-07 14:17:36 +08:00
parent 94ebc74d50
commit dcba5c39f3
2 changed files with 98 additions and 34 deletions

View File

@ -1,22 +1,13 @@
package com.weaver.seconddev.entry.controller;
import com.alibaba.fastjson.JSON;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.seconddev.entry.service.EntryManageService;
import com.weaver.teams.hrapp.dto.est.HrComEstEmpDto;
import com.weaver.teams.hrapp.dto.est.HrComEstOrgValResDto;
import com.weaver.teams.hrapp.dto.est.param.HrComEstCheckParam;
import com.weaver.teams.hrapp.service.HrComEstService;
import com.weaver.teams.security.context.UserContext;
import com.weaver.teams.security.user.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -45,29 +36,4 @@ public class EntryManageController {
return entryManageService.uploadFiles(params);
}
@PostMapping("/testStaff")
private WeaResult<Map<String,Object>> testStaff(@RequestBody HrComEstCheckParam checkParam) {
//return entryManageService.testStaff(params);
User currentUser = UserContext.getCurrentUser();
log.error("checkParam==={}", JSON.toJSONString(checkParam));
log.error("currentUser==={}", JSON.toJSONString(currentUser));
Map<String,Object> map = new HashMap<>();
HrComEstOrgValResDto hrComEstOrgValResDto = hrComEstService.estValidate(currentUser.getTenantKey(), currentUser.getEmployeeId(), checkParam);
log.error("hrComEstOrgValResDto==={}", JSON.toJSONString(hrComEstOrgValResDto));
map.put("currentUser", JSON.toJSONString(currentUser));
map.put("checkParam", JSON.toJSONString(checkParam));
map.put("hrComEstOrgValResDto", JSON.toJSONString(hrComEstOrgValResDto));
return WeaResult.success(map);
}
public static void main(String[] args) {
HrComEstCheckParam checkParam = new HrComEstCheckParam();
List<HrComEstEmpDto> empList = new ArrayList<>();
HrComEstEmpDto emp = new HrComEstEmpDto();
emp.setNewDepartmentId(1151352978370437120L);
}
}

View File

@ -0,0 +1,98 @@
package com.weaver.seconddev.staff.action;
import cn.hutool.core.convert.Convert;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.portal.constant.ApplicationConfigConstant;
import com.weaver.seconddev.portal.util.PapiUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 招聘需求流程提交时根据年部门岗位招需人数三个条件判断是否超编超编前端提醒并阻止流程提交不超编流转流转
*
* @author:dxfeng
* @createTime: 2025/08/07
* @version: 1.0
*/
@Slf4j
@Service("StaffCheckAction")
public class StaffCheckAction implements EsbServerlessRpcRemoteInterface {
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
log.error("StaffCheckAction==params=={}", params);
// 部门id
Long departmentId = Convert.toLong(params.get("departmentId"));
// 岗位id
Long positionId = Convert.toLong(params.get("positionId"));
// 办公地点id
Long locationId = Convert.toLong(params.get("locationId"));
// 职称
Long jobCallId = Convert.toLong(params.get("jobCallId"));
// 职级
Long gradeId = Convert.toLong(params.get("gradeId"));
// 职等
Long jobsetLevelId = Convert.toLong(params.get("jobsetLevelId"));
// 入职日期
String hiredate = Convert.toStr(params.get("hiredate"));
if (StringUtils.isNotBlank(hiredate) && hiredate.length() == 7) {
hiredate = hiredate + "-01";
}
Date date = Convert.toDate(hiredate);
// 人员状态
Long personnelStatus = Convert.toLong(params.get("personnelStatus"));
// 需求人数
Integer requiredNumber = Convert.toInt(params.get("requiredNumber"), 0);
if (requiredNumber < 1) {
// 需求人数小于1,不做校验
return WeaResult.success();
}
String papiCode = PapiUtil.getPapiCode(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.CORP_ID, "A1a");
String papiToken = PapiUtil.getPapiToken(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.ORGANIZATION_APP_KEY, ApplicationConfigConstant.ORGANIZATION_APP_SECRET, papiCode);
List<JSONObject> empList = new ArrayList<>();
JSONObject jsonObject = new JSONObject();
// 赵普西
for (int i = 0; i < requiredNumber; i++) {
JSONObject obj = new JSONObject();
obj.put("departmentId", departmentId);
obj.put("positionId", positionId);
obj.put("locationId", locationId);
obj.put("jobCallId", jobCallId);
obj.put("gradeId", gradeId);
obj.put("jobsetLevelId", jobsetLevelId);
obj.put("hiredate", date);
obj.put("personnelStatus", personnelStatus);
empList.add(obj);
}
jsonObject.put("empList", empList);
jsonObject.put("source", "addEmp");
jsonObject.put("access_token", papiToken);
log.error("validate==jsonObject=={}", JSON.toJSONString(jsonObject));
String response = HttpRequest.post(ApplicationConfigConstant.APP_URL + "/papi/openapi/api/hr/hrapi/est/validate")
.header("Content-Type", "application/json")
.body(jsonObject.toJSONString())
.execute()
.body();
log.error("validate>>response===" + response);
JSONObject responseJson = JSONObject.parseObject(response);
JSONObject data = responseJson.getJSONObject("data");
if (data != null && !data.getBoolean("checkResult")) {
// 验证失败
return WeaResult.fail(data.getString("errContent"), true);
}
return WeaResult.success();
}
}