人员新增和修改定时任务分开
This commit is contained in:
parent
35037a686c
commit
d563681bac
|
@ -29,10 +29,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 后台任务插件 yxl 20240830
|
||||
* 人员新增后台任务插件 yxl 20240830
|
||||
*/
|
||||
public class DobeDWpersonTask extends AbstractTask implements Plugin {
|
||||
private static final String entityName = "bos_user";//系统库 表名 t_sec_user
|
||||
private static final String personEntityName = "qeug_recon_personbank";//供应链库 人员收款银行账户 表名 tk_qeug_recon_personbank
|
||||
private static Log log = LogFactory.getLog(DobeDWpersonTask.class);
|
||||
private static final String dw_menthod = "mdm_user";
|
||||
|
||||
|
@ -84,7 +85,8 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
|
|||
//处理离职人员
|
||||
QFilter exprtFilter = new QFilter("number", QCP.not_in, exprtNumber);
|
||||
QFilter dwFilter = new QFilter("source", QCP.equals, "dw");
|
||||
DynamicObject[] dos = BusinessDataServiceHelper.load("bos_user","id,enable,isforbidden",new QFilter[]{exprtFilter.and(dwFilter)});
|
||||
QFilter enableFilter = new QFilter("enable", QCP.equals, "1");
|
||||
DynamicObject[] dos = BusinessDataServiceHelper.load("bos_user","id,enable,isforbidden",new QFilter[]{exprtFilter.and(dwFilter).and(enableFilter)});
|
||||
if(dos.length > 0){
|
||||
DynamicObject currentUser = null;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
|
@ -100,7 +102,7 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
|
|||
private void handleUser(JSONObject json_body,List<String> exprtNumber) {
|
||||
//解析接口返回值,与系统数据比较
|
||||
JSONArray detailsJson = json_body.getJSONArray("data");
|
||||
String userID = null;
|
||||
// String userID = null;
|
||||
String number = null;
|
||||
String name = null;
|
||||
// String usertype = null;
|
||||
|
@ -110,30 +112,31 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
|
|||
String jobposition = null;
|
||||
|
||||
List<UserParam> addList = new ArrayList<>();
|
||||
List<UserParam> updateList = new ArrayList<>();
|
||||
// List<UserParam> updateList = new ArrayList<>();
|
||||
UserParam user = null;
|
||||
DynamicObject currentUser = null;
|
||||
DynamicObject personbank = null;
|
||||
DynamicObject deptOrg = null;
|
||||
Map<String, Object> dataMap = null;
|
||||
for (int i = 0; i < detailsJson.size(); i++) {
|
||||
json_body = detailsJson.getJSONObject(i);
|
||||
userID = json_body.getString("user_id");
|
||||
// userID = json_body.getString("user_id");
|
||||
number = json_body.getString("user_code");//工号,作为唯一值?
|
||||
name = json_body.getString("user_name");
|
||||
email = json_body.getString("email");
|
||||
phone = json_body.getString("mobile_phone");
|
||||
deptid = json_body.getString("department_id");//部门id
|
||||
jobposition = json_body.getString("jobposition");//职位
|
||||
if(DobeDWUtils.isEmpty(userID) || DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name)){
|
||||
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name)){
|
||||
log.info(String.format("人员入参为空异常:%s", json_body.toJSONString()));
|
||||
continue;
|
||||
}
|
||||
exprtNumber.add(number);
|
||||
currentUser = QueryServiceHelper.queryOne(entityName,"id,number,name",new QFilter[]{new QFilter("number","=",number)});
|
||||
user = new UserParam();//常用或者重要的参数,详情请查看参数对象UserParam
|
||||
dataMap = new HashMap<>();
|
||||
if(currentUser == null){
|
||||
//user.setCustomUserId(123456780L);
|
||||
// currentUser = QueryServiceHelper.queryOne(entityName,"id,number,name",new QFilter[]{new QFilter("number","=",number)});
|
||||
if(!QueryServiceHelper.exists(entityName,new QFilter[]{new QFilter("number","=",number)})){
|
||||
//根据工号来查询是否存在此用户,不存在时,新增用户
|
||||
user = new UserParam();//常用或者重要的参数,详情请查看参数对象UserParam
|
||||
dataMap = new HashMap<>();
|
||||
//user.setCustomUserId(123456780L); 外部系统的id作为本系统的id
|
||||
dataMap.put("number", number);//人员编码,即是工号
|
||||
dataMap.put("name", name);//姓名
|
||||
dataMap.put("username", number);//数仓的工号作为星瀚的用户名
|
||||
|
@ -146,40 +149,37 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
|
|||
// dataMap.put("birthday", "1993-8-8");//生日
|
||||
// dataMap.put("gender", "1");//性别1男 0女
|
||||
user.setDataMap(dataMap);
|
||||
//处理部门和职位
|
||||
addList.add(user);
|
||||
}else{
|
||||
//修改 姓名、是否启用、手机、邮箱、职位、部门等情况
|
||||
user.setId(currentUser.getLong("id"));
|
||||
//employ_statusname 待入职、试用、正式、非正式 目前无法处理离职人员
|
||||
// dataMap.put("enable", json_body.getString("employ_status"));//是否启用
|
||||
// if(!Boolean.parseBoolean(json_body.getString("employ_status"))){
|
||||
// dataMap.put("isforbidden", true);//作为用户 是否禁用 禁用后不可登录系统
|
||||
// }else{
|
||||
// dataMap.put("isforbidden", false);
|
||||
// }
|
||||
dataMap.put("name", name);//姓名
|
||||
dataMap.put("phone", phone);//手机号
|
||||
dataMap.put("email", email);//电子邮箱
|
||||
user.setDataMap(dataMap);
|
||||
updateList.add(user);
|
||||
}
|
||||
//处理部门和职位
|
||||
if(!DobeDWUtils.isEmpty(deptid)){
|
||||
deptOrg = QueryServiceHelper.queryOne("bos_org","id,number,name",new QFilter[]{new QFilter("fyzjorgid","=",deptid)});
|
||||
if(deptOrg != null){
|
||||
List<Map<String, Object>> posList = new ArrayList<>();
|
||||
Map<String, Object> entryentity = new HashMap<>();
|
||||
entryentity.put("dpt", deptOrg.getLong("id"));//设置部门ID
|
||||
entryentity.put("position", jobposition);//职位名称
|
||||
entryentity.put("isincharge", false);//是否负责人
|
||||
entryentity.put("ispartjob", false);//是否兼职
|
||||
entryentity.put("seq", 1);//职位顺序号 1
|
||||
posList.add(entryentity);
|
||||
dataMap.put("entryentity", posList);
|
||||
}else{
|
||||
log.info(String.format("数仓的部门在金蝶中未找到对应组织:%s", deptid));
|
||||
//处理部门和职位
|
||||
if(!DobeDWUtils.isEmpty(deptid)){
|
||||
deptOrg = QueryServiceHelper.queryOne("bos_org","id,number,name",new QFilter[]{new QFilter("fyzjorgid","=",deptid)});
|
||||
if(deptOrg != null){
|
||||
List<Map<String, Object>> posList = new ArrayList<>();
|
||||
Map<String, Object> entryentity = new HashMap<>();
|
||||
entryentity.put("dpt", deptOrg.getLong("id"));//设置部门ID
|
||||
//职位名称 为空时,默认为编外人员
|
||||
if(DobeDWUtils.isEmpty(jobposition)){
|
||||
entryentity.put("position", "编外人员");//职位名称
|
||||
}else{
|
||||
entryentity.put("position", jobposition);//职位名称
|
||||
}
|
||||
entryentity.put("isincharge", false);//是否负责人
|
||||
entryentity.put("ispartjob", false);//是否兼职
|
||||
entryentity.put("seq", 1);//职位顺序号 1
|
||||
posList.add(entryentity);
|
||||
dataMap.put("entryentity", posList);
|
||||
}else{
|
||||
log.info(String.format("数仓的部门在金蝶中未找到对应组织:%s", deptid));
|
||||
}
|
||||
}
|
||||
//处理新增人员收款银行账户
|
||||
// personbank = BusinessDataServiceHelper.newDynamicObject(personEntityName);
|
||||
// personbank.set("number",number);
|
||||
// personbank.set("name",name);
|
||||
// personbank.set("qeug_banknumber",name);//银行账户
|
||||
// personbank.set("qeug_bankname",name);//开户银行
|
||||
// //保存数据:直接保存入库,不走操作校验
|
||||
// SaveServiceHelper.save(new DynamicObject[]{personbank});
|
||||
}
|
||||
}
|
||||
if(addList.size() > 0){
|
||||
|
@ -191,14 +191,14 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(updateList.size() > 0){
|
||||
UserServiceHelper.update(updateList);
|
||||
//判断执行结果
|
||||
for (UserParam result : updateList) {
|
||||
if (!result.isSuccess()) {
|
||||
log.info(String.format("人员修改异常:%s", result.getMsg()));
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(updateList.size() > 0){
|
||||
// UserServiceHelper.update(updateList);
|
||||
// //判断执行结果
|
||||
// for (UserParam result : updateList) {
|
||||
// if (!result.isSuccess()) {
|
||||
// log.info(String.format("人员修改异常:%s", result.getMsg()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package shkd.bamp.base.task;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.permission.model.UserParam;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import shkd.utils.DobeDWUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 人员修改后台任务插件 yxl 20240910
|
||||
*/
|
||||
public class DobeDWpersonUpdateTask extends AbstractTask implements Plugin {
|
||||
private static final String entityName = "bos_user";//系统库 表名 t_sec_user
|
||||
private static final String personEntityName = "qeug_recon_personbank";//供应链库 人员收款银行账户 表名 tk_qeug_recon_personbank
|
||||
private static Log log = LogFactory.getLog(DobeDWpersonUpdateTask.class);
|
||||
private static final String dw_menthod = "mdm_user";
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder().url(DobeDWUtils.dwUrl+dw_menthod)
|
||||
.post(DobeDWUtils.createRequestBody("person",1))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", DobeDWUtils.appCode)
|
||||
.build();
|
||||
|
||||
String resultData = null;
|
||||
Response response = null;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
resultData = response.body().string();
|
||||
// log.info("人员接口返回结果:\n{}", resultData);
|
||||
} catch (IOException e) {
|
||||
log.info(String.format("人员接口异常:%s", e.getMessage()));
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject json_body = JSON.parseObject(resultData);
|
||||
//接口返回的数据进行了分页
|
||||
int totalNum = json_body.getIntValue("totalNum");//分页-SQL查询总数据量
|
||||
handleUser(json_body);
|
||||
int queryCount = DobeDWUtils.getQueryCount(totalNum);
|
||||
if(queryCount > 1){
|
||||
//查询次数不止一次,需要分页查询
|
||||
for (int i = 2; i <= queryCount; i++) {
|
||||
request = new Request.Builder().url(DobeDWUtils.dwUrl+dw_menthod)
|
||||
.post(DobeDWUtils.createRequestBody("person",i))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", DobeDWUtils.appCode)
|
||||
.build();
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
resultData = response.body().string();
|
||||
// log.info("人员接口返回结果:\n{}", resultData);
|
||||
} catch (IOException e) {
|
||||
log.info(String.format("人员接口异常:%s", e.getMessage()));
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
json_body = JSON.parseObject(resultData);
|
||||
handleUser(json_body);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleUser(JSONObject json_body) {
|
||||
//解析接口返回值,与系统数据比较
|
||||
JSONArray detailsJson = json_body.getJSONArray("data");
|
||||
// String userID = null;
|
||||
String number = null;
|
||||
String name = null;
|
||||
String phone = null;
|
||||
String email = null;
|
||||
String deptid = null;
|
||||
String jobposition = null;
|
||||
|
||||
List<UserParam> updateList = new ArrayList<>();
|
||||
UserParam user = null;
|
||||
DynamicObject currentUser = null;
|
||||
DynamicObject deptOrg = null;
|
||||
DynamicObject personbank = null;
|
||||
Map<String, Object> dataMap = null;
|
||||
for (int i = 0; i < detailsJson.size(); i++) {
|
||||
json_body = detailsJson.getJSONObject(i);
|
||||
// userID = json_body.getString("user_id");
|
||||
number = json_body.getString("user_code");//工号,作为唯一值?
|
||||
name = json_body.getString("user_name");
|
||||
email = json_body.getString("email");
|
||||
phone = json_body.getString("mobile_phone");
|
||||
deptid = json_body.getString("department_id");//部门id
|
||||
jobposition = json_body.getString("jobposition");//职位
|
||||
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name)){
|
||||
log.info(String.format("人员入参为空异常:%s", json_body.toJSONString()));
|
||||
continue;
|
||||
}
|
||||
currentUser = QueryServiceHelper.queryOne(entityName,"id,number,name",new QFilter[]{new QFilter("number","=",number)});
|
||||
if(currentUser != null){
|
||||
user = new UserParam();//常用或者重要的参数,详情请查看参数对象UserParam
|
||||
dataMap = new HashMap<>();
|
||||
//修改 姓名、是否启用、手机、邮箱、职位、部门等情况
|
||||
user.setId(currentUser.getLong("id"));
|
||||
dataMap.put("name", name);//姓名
|
||||
dataMap.put("phone", phone);//手机号
|
||||
dataMap.put("email", email);//电子邮箱
|
||||
user.setDataMap(dataMap);
|
||||
updateList.add(user);
|
||||
//处理部门和职位
|
||||
if(!DobeDWUtils.isEmpty(deptid)){
|
||||
deptOrg = QueryServiceHelper.queryOne("bos_org","id,number,name",new QFilter[]{new QFilter("fyzjorgid","=",deptid)});
|
||||
if(deptOrg != null){
|
||||
List<Map<String, Object>> posList = new ArrayList<>();
|
||||
Map<String, Object> entryentity = new HashMap<>();
|
||||
entryentity.put("dpt", deptOrg.getLong("id"));//设置部门ID
|
||||
//职位名称 为空时,默认为编外人员
|
||||
if(DobeDWUtils.isEmpty(jobposition)){
|
||||
entryentity.put("position", "编外人员");//职位名称
|
||||
}else{
|
||||
entryentity.put("position", jobposition);//职位名称
|
||||
}
|
||||
entryentity.put("isincharge", false);//是否负责人
|
||||
entryentity.put("ispartjob", false);//是否兼职
|
||||
entryentity.put("seq", 1);//职位顺序号 1
|
||||
posList.add(entryentity);
|
||||
dataMap.put("entryentity", posList);
|
||||
}else{
|
||||
log.info(String.format("数仓的部门在金蝶中未找到对应组织:%s", deptid));
|
||||
}
|
||||
}
|
||||
//处理人员收款银行账户的修改
|
||||
// personbank = BusinessDataServiceHelper.loadSingle(personEntityName,new QFilter[]{new QFilter("number","=",number)});
|
||||
// if(personbank != null){
|
||||
// if(!name.equals(personbank.getString("name"))){
|
||||
// //姓名、银行账户、开户银行任意一个不相同则更新
|
||||
// personbank.set("name",name);
|
||||
// personbank.set("qeug_banknumber",name);//银行账户
|
||||
// personbank.set("qeug_bankname",name);//开户银行
|
||||
// SaveServiceHelper.update(personbank);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
if(updateList.size() > 0){
|
||||
UserServiceHelper.update(updateList);
|
||||
//判断执行结果
|
||||
for (UserParam result : updateList) {
|
||||
if (!result.isSuccess()) {
|
||||
log.info(String.format("人员修改异常:%s", result.getMsg()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -195,7 +195,7 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
|||
// String auditor = payrequestinfo.getDynamicObject("auditor").getString("number");
|
||||
// payData.put("approver",auditor);//审核人编码 审核人工号
|
||||
payData.put("approvedate",DobeDWUtils.getDateString(payrequestinfo.getDate("auditDate")));//审核日期 YYYY-MM-DD
|
||||
payData.put("src_syscode","kingdee");//单据来源系统编码 非必传
|
||||
// payData.put("src_syscode","ISC");//单据来源系统编码 非必传
|
||||
if(isnotext){
|
||||
payData.put("def1","无合同");//自定义项1 流程类型:有合同 无合同
|
||||
}else{
|
||||
|
@ -305,8 +305,11 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
|||
//付款单新增接口,上一步的accesstoken作为header
|
||||
Request request = new Request.Builder().url(DobeDWUtils.payUrl)
|
||||
.post(createFormRequestBody(payData))
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||
.header("access_Token", accesstoken)
|
||||
.header("Content-Type", "application/json;charset=utf-8")
|
||||
.header("access_token", accesstoken)
|
||||
.header("repeat_check", "Y")
|
||||
.header("ucg_flag", "Y")
|
||||
.header("client_id", DobeDWUtils.clientid)
|
||||
.build();
|
||||
String yynum = null;//用友单据编号
|
||||
try {
|
||||
|
|
|
@ -27,14 +27,14 @@ public class DobeDWUtils {
|
|||
public static final String bizcenter = "01";
|
||||
//公钥,加解密使用
|
||||
public static final String pubKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtifU2Nm6/lwYybVGNMzmn/UvOmtjqs9tuesdchx0pK6HsiubCRiFKr/TFGLHhBKJ3TXtH4gwJLkGrMJRdTicWHOCAwcU9hmM+XsHCF4FQ4UWcWA73Ha9qR3SC1tSxwDw8n2/uHUKtKzlOGuJQnzL5hBN7DnDU4M7FqEZ+ctG71ufkjytY1TKVoHfThRTAP1ouSNo3gM/pMwjISTkFH5vY7twdu9IW09+S5/uo8C+pw7BahDpOv5z7F1yWDEnw1sdwNdqPFV2DsB1JS3GfLe9P3ZACeR+lcD3KrwBsQky3oZsg3y6NsDqOpzoLk9pToFzmci1GMfCKoc4MzVF9fq7XQIDAQAB";
|
||||
//接口IP地址
|
||||
//用友接口IP地址
|
||||
public static final String yyip = "106.14.25.83";
|
||||
//接口端口
|
||||
//用友接口端口
|
||||
public static final String yyport = "9999";
|
||||
//用友付款单新增接口
|
||||
public static final String payUrl = "http://106.14.25.83:9999/nccloud/api/arap/arap/paybill/insertandcommit";
|
||||
public static final String payUrl = "http://106.14.25.83:9999/nccloud/api/arap/paybill/insertandcommit";
|
||||
//付款金额查询接口
|
||||
private static final String payQueryUrl = "http://106.14.25.83:8090/nccloud/api/arap/arap/paybill/insertandcommit";
|
||||
public static final String payQueryUrl = "http://106.14.25.83:8090/nccloud/api/arap/paybill/insertandcommit";
|
||||
|
||||
public static boolean isEmpty(String value) {
|
||||
return value == null || value.trim().length() <= 0;
|
||||
|
|
Loading…
Reference in New Issue