数仓用友定时任务集成相关代码首次提交

This commit is contained in:
yuxueliang0813 2024-09-06 11:28:07 +08:00
parent 1556290c72
commit f9af43a4d3
8 changed files with 1318 additions and 0 deletions

View File

@ -0,0 +1,171 @@
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.org.model.OrgParam;
import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.org.OrgViewType;
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.*;
/**
* 后台任务插件 yxl 20240830
*/
public class DobeDWorgTask extends AbstractTask implements Plugin {
private static final String entityName = "bos_org";//系统库 表名 t_org_org
private static Log log = LogFactory.getLog(DobeDWorgTask.class);
private static final String dw_menthod = "mdm_arog";
@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("",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查询总数据量
//解析接口返回值,与系统数据比较
handleOrg(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("",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);
handleOrg(json_body);
}
}
}
private void handleOrg(JSONObject json_body) {
JSONArray detailsJson = json_body.getJSONArray("data");
// List<OrgParam> paramList = new ArrayList<>();
OrgParam param = null;
DynamicObject parentOrg = null;
DynamicObject currentOrg = null;
String orgNumber = null;
String orgName = null;
String orgID = null;
String parentId = null;
for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i);
orgNumber = json_body.getString("org_code");
orgName = json_body.getString("org_name");
orgID = json_body.getString("org_id");
// String orgLevel = json_body.getString("org_level");//组织层级
parentId = json_body.getString("org_parentid");
if(DobeDWUtils.isEmpty(orgID) || DobeDWUtils.isEmpty(orgNumber) || DobeDWUtils.isEmpty(orgName)
|| DobeDWUtils.isEmpty(parentId)){
//如果组织ID和组织编码 名称是空的,则跳过此记录
log.info(String.format("组织入参为空异常:%s", json_body.toJSONString()));
continue;
}
//根据组织ID查找系统现有数据是否存在,这种写法会抛异常,需要关注原因
currentOrg = QueryServiceHelper.queryOne(entityName,"id,number,name",new QFilter[]{new QFilter("fyzjorgid","=",orgID)});
if(currentOrg != null){
//已存在,做更新
if(orgNumber.equals(currentOrg.getString("number")) && orgName.equals(currentOrg.getString("name"))){
//编号和名称都没有变化,无需更新
continue;
}
param = new OrgParam();
param.setId(currentOrg.getLong("id"));
param.setName(orgName);
param.setNumber(orgNumber);
OrgUnitServiceHelper.update(param);
if (!param.isSuccess()) {
log.info(String.format("组织修改异常:%s", param.getMsg()));
}
}else{
//根据父级ID获取父级组织对象,组织的主数据id存在于星瀚组织的fyzjorgid字段中
parentOrg = QueryServiceHelper.queryOne(entityName,"id,number,name",new QFilter[]{new QFilter("fyzjorgid","=",parentId)});
if(parentOrg == null){
log.info(String.format("根据数仓组织父级ID未在金蝶中找到对应组织:%s", parentId));
continue;
}
/* 新增单个视图方案的组织 */
param = new OrgParam();
param.setParentId(parentOrg.getLong("id"));//上级组织的金蝶ID
param.setName(orgName);
param.setYzjOrgId(orgID);//云之家组织内码字段,用于保存组织的外部ID
param.setNumber(orgNumber);
param.setOrgPatternId(4);//组织形态ID,默认ID为4L(部门)1为公司;当前组织是公司还是部门需要有字段可以体现
// param.setCustomOrgId(Long.parseLong(orgID));//组织自定义ID,用于保存第三方系统的ID,并非额外字段保存,而是直接更新id字段
param.setDuty(OrgViewType.Admin);//组织属性-行政组织
//设置组织属性-单个视图
// Map<String, Object> proMap = new HashMap<>();
// proMap.put("uniformsocialcreditcode", "add0001");//统一社会信用代码
// param.setPropertyMap(proMap);//组织关联属性map
// paramList.add(param);
// 设置多视图参数
// TreeMap<String, OrgDutyView> multiViewMap = new TreeMap<>();
// OrgDutyView dutyView = new OrgDutyView();
// dutyView.setParentId(0L);//上级组织的金蝶ID
// multiViewMap.put(OrgViewType.ControlUnit, dutyView);
// param.setMultiViewMap(multiViewMap);//多职能参数 支持一次更新多种业务视图方案;键为视图方案编码(参照本页参数说明的OrgViewType),值为OrgDutyView对象
// paramList.add(param);
// 执行并判断结果,如下是微服务模式调用,会提示服务找不到
// IOrgService orgService = ServiceFactory.getService(OrgService.class);
// orgService.add(paramList);
OrgUnitServiceHelper.add(param);
if (!param.isSuccess()) {
log.info(String.format("组织新增异常:%s", param.getMsg()));
}
}
}
}
// for (OrgParam result : paramList) {
// // 根据操作结果提示用户或执行其他处理
// if (!result.isSuccess()) {
// log.info(String.format("组织保存异常:%s", result.getMsg()));
// }
// }
}

View File

@ -0,0 +1,185 @@
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.QFilter;
import kd.bos.permission.model.UserParam;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.QueryServiceHelper;
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 20240830
*/
public class DobeDWpersonTask extends AbstractTask implements Plugin {
private static final String entityName = "bos_user";//系统库 表名 t_sec_user
private static Log log = LogFactory.getLog(DobeDWpersonTask.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 usertype = null;
String phone = null;
String email = null;
String deptid = null;
String jobposition = null;
List<UserParam> addList = new ArrayList<>();
List<UserParam> updateList = new ArrayList<>();
UserParam user = null;
DynamicObject currentUser = 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");
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)){
log.info(String.format("人员入参为空异常:%s", json_body.toJSONString()));
continue;
}
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);
dataMap.put("number", number);//人员编码,即是工号
dataMap.put("name", name);//姓名
dataMap.put("username", number);//数仓的工号作为星瀚的用户名
dataMap.put("usertype", "1");//用户类型 1-职员
dataMap.put("phone", phone);//手机号
dataMap.put("email", email);//电子邮箱
dataMap.put("source", "dw");//数据来源于数仓
// dataMap.put("fuid", userID);//云之家账号内码
// dataMap.put("idcard", "");//身份证
// 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(addList.size() > 0){
UserServiceHelper.add(addList);
//判断执行结果
for (UserParam result : addList) {
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()));
}
}
}
}
}

View File

@ -0,0 +1,350 @@
package shkd.repc.recon.opplugin;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.*;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.sdk.plugin.Plugin;
import okhttp3.*;
import shkd.utils.DobeDWUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* 单据操作插件
*/
public class YongyouBIPOperation extends AbstractOperationServicePlugIn implements Plugin {
private static Log log = LogFactory.getLog(YongyouBIPOperation.class);
// 授权模式,客户端模式为client,密码模式为:password
private static final String grant_type = "client_credentials";
//第三方应用id,对应系统中的app_id
private static final String client_id = "OA";
// 第三方应用秘钥,对请求加签使用
private static final String client_secret = "9c462d924f6e42f4996b";
//访问的BIP系统的账套code
private static final String biz_center = "01";
//加密等级
private static final String secret_level = "L0";
//公钥,加解密使用
private static final String pubKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0IwYK6tDUauBggUzzfBed9l5gP+iYCCbqWNbH5YQ0E+L+d8Q8nSCU7iwy88z/JhRiXqZJi77h5W3dVvP5jwLISYzrNq7g/jcQIZgKhAzWt2NpcojKAUk/RkKjrAlIshDf1RVdGmfkZCgo3MZfnhSKQHCVniEY2yjgYeIrq5xiHW+Bk5cEhYHKDsZsGQ/1yp9YnWJUOInTB2cxebwW3yYeCN6y7NQczywSwSrrFgzvfo3iDgTPSzA+VXuGRfisTxxDHkcT5sM2KeWvQhgNFKPtgKOU9jrv3UA+EkxRl76VWDG7XQomez/gYGlAyc6dahYv13SrLWGdIjnBgCcovEJ5wIDAQAB";
//认证接口地址
private static final String tokenUrl = "http://106.14.25.83:8090/nccloud/opm/accesstoken";
//付款单新增接口
private static final String payUrl = "http://106.14.25.83:8090/nccloud/api/arap/arap/paybill/insertandcommit";
/**
* 操作执行,加载单据数据包之前,触发此事件;在单据列表上执行单据操作,传入的是单据内码;
* 系统需要先根据传入的单据内码,加载单据数据包,其中只包含操作要用到的字段,然后再执行操作;
* 在加载单据数据包之前,操作引擎触发此事件;插件需要在此事件,添加需要用到的字段;
* 否则,系统加载的单据数据包,可能没有插件要用到的字段值,从而引发中断
*/
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
}
/**
* 构建好操作校验器之后,执行校验之前,触发此事件;
* 插件可以在此事件,增加自定义操作校验器,或者去掉内置的校验器
*/
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
}
/**
* 操作校验通过之后,开启事务之前,触发此事件;
* 插件可以在此事件,对通过校验的数据,进行整理
*/
@Override
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
super.beforeExecuteOperationTransaction(e);
}
/**
* 操作校验通过,开启了事务,准备把数据提交到数据库之前触发此事件;
* 可以在此事件,进行数据同步处理
*/
@Override
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
super.beginOperationTransaction(e);
}
/**
* 单据数据已经提交到数据库之后,事务未提交之前,触发此事件;
* 可以在此事件,进行数据同步处理;
*/
@Override
public void endOperationTransaction(EndOperationTransactionArgs e) {
super.endOperationTransaction(e);
}
/**
* 操作事务提交失败,事务回滚之后触发此事件;
* 该方法在事务异常后执行,插件可以在此事件,对没有事务保护的数据更新进行补偿
*/
@Override
public void rollbackOperation(RollbackOperationArgs e) {
super.rollbackOperation(e);
}
/**
* 操作执行完毕,事务提交之后,触发此事件;
* 插件可以在此事件,处理操作后续事情,与操作事务无关
*/
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
//audit审核通过后,判断当前是合同付款申请单还是无文本合同
if(!"save".equals(e.getOperationKey())){
DynamicObject[] dos = e.getDataEntities();
DynamicObject payrequestinfo = null;
for (int i = 0; i < dos.length; i++) {
payrequestinfo = dos[i];
if("recon_payreqbill".equals(payrequestinfo.getDataEntityType().getName())){
//判断实体名称为合同付款申请单
handleForBIP(e.getOperationKey(),payrequestinfo,false);
}else if("recon_connotextbill".equals(payrequestinfo.getDataEntityType().getName())){
//无文本合同
handleForBIP(e.getOperationKey(),payrequestinfo,true);
}
// payrequestinfo.getDynamicObjectType().getAlias();//获取数据库表名
}
}
//unaudit
}
private String getInvoiceNumber(DynamicObject payrequestinfo, boolean isnotext){
if(isnotext){
//无文本合同,拼接对应发票编号
}else{
//合同付款申请单,拼接对应发票编号
}
return null;
}
private String getAccountingOpinion(DynamicObject payrequestinfo){
//根据单据id查找审批流程中会计部的审批意见,多人时合并输出意见?
return null;
}
private String[] getCompanyDeptNumber(String bizDept){
//根据用款部门的编号获得对应关系表中的财务公司编号和部门编号
String[] result = new String[2];
return result;
}
private Map<String, String> zzPayData(String eventName, DynamicObject payrequestinfo, boolean isnotext){
Map<String, String> payData = new HashMap<>();
String[] companyDept = getCompanyDeptNumber(payrequestinfo.getDynamicObject("usedepart").getString("number"));
payData.put("pk_org",companyDept[0]);//财务公司组织编码,根据当前单据的用款部门获得对应关系表中的财务公司和部门
payData.put("pk_tradetype","D3");//交易类型,传编码例:D3-采购付款单
payData.put("billdate",DobeDWUtils.getDateString(payrequestinfo.getDate("bizdate")));//业务日期,YYYY-MM-DD
String ap_recaccount = null;//收款银行账户编码
//无文本合同的个人垫付时,是业务员
boolean isgrdf = isnotext && payrequestinfo.getBoolean("grdf");
if(isgrdf){
payData.put("objtype","3");//往来对象(0-客户 1-供应商 2-部门 3-业务员)
ap_recaccount = "";
}else{
payData.put("objtype","0");//往来对象(0-客户 1-供应商 2-部门 3-业务员)
ap_recaccount = "";
}
String supplierNum = payrequestinfo.getDynamicObject("supplier").getString("number");
// payData.put("supplier",);//供应商编码 非必传
payData.put("customer",supplierNum);//客户编码 即使是供应商也传入到该字段
payData.put("pk_dept",companyDept[1]);//部门编码(通过公司主体明细表找部门编码)
if(isgrdf){
payData.put("pk_psndoc","");//业务员编码 人员工号 个人业务的时候,3-业务员 必传
}else{
payData.put("pk_psndoc","");//非个人业务 不传
}
payData.put("pk_currtype","CNY");//币种,传编码CNY
payData.put("pk_busitype","AP01");//业务流程,传编码 AP01(生产可能有变化)
//付款银行账户编码(德必),传编码例:31001562700050031883-上海德必文化创意产业发展(集团)股份有限公司
payData.put("ap_payaccoun","");//如何取值?-从数仓获取的组织对应关系中获取默认付款银行账号
payData.put("ap_recaccount",ap_recaccount);//收款银行账户编码(客商),传编码例:3101040160000098225-上海达洋消防保安工程有限公司
payData.put("pk_balatype","07");//结算方式编码,传编码例:07-网银
BigDecimal bcsqje = payrequestinfo.getBigDecimal("");//单据上的本次申请金额
payData.put("money","");//原币金额 取含税金额
payData.put("rate","1.00000000");//组织本币汇率,默认1.00000000
payData.put("local_money",bcsqje.toString());//组织本币金额 含税金额,xxxxx.00000000
payData.put("grouprate","1.00000000");//集团本币汇率,默认1.00000000
payData.put("grouplocal",bcsqje.toString());//集团本币金额 含税金额,xxxxx.00000000
payData.put("globalrate","1.00000000");//全局本币汇率 默认1.00000000
payData.put("globallocal",bcsqje.toString());//全局本币金额 含税金额,xxxxx.00000000
payData.put("pu_org","");//业务组织编码 转换成对应财务的编码
payData.put("pu_deptid","");//业务部门编码 转换成对应财务的编码
// payData.put("pu_psndoc","");//业务人员编码 业务人员和制单人是否同一个?先注释
String creator = payrequestinfo.getDynamicObject("handler").getString("number");
payData.put("billmaker",creator);//制单人编码 制单人工号
payData.put("billstatus","1");//默认1 审批通过
payData.put("approvestatus","1");//默认1 审批通过
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");//单据来源系统编码 非必传
if(isnotext){
payData.put("def1","无合同");//自定义项1 流程类型:有合同 无合同
}else{
payData.put("def1","有合同");//自定义项1 流程类型:有合同 无合同
}
payData.put("def2",payrequestinfo.getString("billno"));//自定义项2 付款申请单的单号(全局唯一才行)
payData.put("def3","否");//自定义项3 是否分摊,传字符 例:是,否
payData.put("def4",getInvoiceNumber(payrequestinfo, isnotext));//自定义项4 发票号码拼接数据,传字符 数电票(增值税专用发票):24512000000077221149
payData.put("def5",null);//自定义项5 付款申请单的备注,后续作为的凭证摘要,字段长度最大为30
payData.put("def6","");//自定义项6 0A接口预留字段1
payData.put("def7","");//自定义项7 0A接口预留字段2
payData.put("def8","");//自定义项8 0A接口预留字段3
//------以下是表体组装-------------
JSONArray jas = new JSONArray();
JSONObject items = new JSONObject();
// items.put("contractno",payrequestinfo.getDynamicObject("contractbill"));//合同号
items.put("scomment",null);//摘要 按照现在NC57逻辑先来,涉及银企互联支付,原来是15个字符(7个中文)的样子
if(isgrdf){
items.put("objtype","3");//往来对象(0-客户 1-供应商 2-部门 3-业务员)
}else{
items.put("objtype","0");//往来对象(0-客户 1-供应商 2-部门 3-业务员)
}
// items.put("supplier",);//供应商编码 非必传
items.put("customer",supplierNum);//客户编码 供应商的数据也传入这里
items.put("pk_dept",companyDept[1]);//部门编码(通过公司主体明细表找部门编码)
if(isgrdf){
}
items.put("pk_psndoc","");//业务员编码 人员工号 同表头
items.put("pk_recpaytype","001");//付款业务类型,传编码例:001-货款
items.put("prepay","0");//付款性质(0=应付款;1=预付款;)
items.put("pk_currtype","CNY");//币种,传编码CNY
items.put("money_de","");//贷方原币金额 含税金额,xxxxx.00000000
items.put("rate","1.00000000");//组织本币汇率,默认1.00000000
items.put("local_money_de","");//组织本币金额 含税金额,xxxxx.00000000
items.put("grouprate","1.00000000");//集团本币汇率,默认1.00000000
items.put("groupdebit","");//集团本币金额 含税金额,xxxxx.00000000
items.put("globalrate","1.00000000");//全局本币汇率 默认1.00000000
items.put("globaldebit","");//全局本币金额 含税金额,xxxxx.00000000
items.put("taxcodeid","");//税码编码 应该不用传;联调再看;
items.put("taxrate","");//税率
items.put("local_tax_de","");//税额
items.put("notax_de","");//贷方无税金额,除税金额
items.put("pu_org",companyDept[0]);//业务组织编码 同表头公司编码
items.put("pu_deptid","");//业务部门编码 费用承担部门编码,转换成财务组织编码
items.put("pk_subjcode","");//收支项目编码 费用项目,例:660224-管理费用-服务费 会计科目(一个)
items.put("ap_payaccount","");//付款银行账户编码 同表头
items.put("ap_recaccount",ap_recaccount);//收款银行账户编码
items.put("pk_balatype","07");//结算方式编码,传编码例:07-网银
items.put("def5","");//费用类别,传编码 无抵暂支业务,先传空
items.put("def6","");//抵暂支状态,传字符,现在应该有 0 1 -1 三种状态?
items.put("def7","");//原暂支金额,xxxxx.00000000?
items.put("def8","");//抵暂支金额,xxxxx.00000000?
jas.add(items);
payData.put("items",jas.toJSONString());//表头关联表体
return payData;
}
private void handleForBIP(String eventName, DynamicObject payrequestinfo, boolean isnotext){
OkHttpClient client = new OkHttpClient();
//认证接口,得到accesstoken
Request request = new Request.Builder().url(tokenUrl)
.post(createAccessTokenBody())
.header("Content-Type", "application/x-www-form-urlencoded")
.build();
String accesstoken = null;
try {
Response response = client.newCall(request).execute();
JSONObject json_reuslt = JSON.parseObject(response.body().string());
accesstoken = json_reuslt.getString("accessToken");
} catch (Exception e) {
log.error(String.format("用友认证接口异常:%s", e.getMessage()));
throw new RuntimeException(e);
}
if(DobeDWUtils.isEmpty(accesstoken)){
log.error("用友认证接口返回的accessToken为空");
}
//处理合同付款申请单的审核推送用友bip,组装付款入参
Map<String, String> payData = zzPayData(eventName,payrequestinfo,false);
//付款单新增接口,上一步的accesstoken作为header
request = new Request.Builder().url(payUrl)
.post(createFormRequestBody(payData))
.header("Content-Type", "application/x-www-form-urlencoded")
.header("accessToken", accesstoken)
.build();
String yynum = null;//用友单据编号
try {
Response response = client.newCall(request).execute();
JSONObject json_reuslt = JSON.parseObject(response.body().string());
if(!"true".equals(json_reuslt.getString("success"))){
log.error(String.format("用友付款接口处理失败,具体原因:%s", json_reuslt.getString("message")));
//此时除了日志打印,还需要补偿机制,应该加入MQ走后续定时触发?
}
yynum = json_reuslt.getJSONObject("data").getString("billno");
} catch (Exception e) {
log.error(String.format("用友付款接口异常:%s", e.getMessage()));
throw new RuntimeException(e);
}
if(DobeDWUtils.isEmpty(yynum)){
log.error("用友付款接口返回的billno为空");
}else{
//推送用友bip成功后,反写合同付款申请单的用友付款单id字段值
String sql = "UPDATE t_xxx SET field=? WHERE fid=?;";
DB.update(DBRoute.of("scm"), sql, new Object[]{yynum, payrequestinfo.getLong("id")});
}
}
private void handleWithOutContract(String eventName, DynamicObject payrequestinfo){
//处理无文本合同的审核推送用友bip
String yyid = null;//用友单据id
//推送用友bip成功后,反写无文本合同的用友付款单id字段值
String sql = "UPDATE t_recon_connotextbill SET fyyid=? WHERE fid=?;";
DB.update(DBRoute.of("scm"), sql, new Object[]{yyid, payrequestinfo.getLong("id")});
}
private RequestBody createFormRequestBody(Map<String, String> formData) {
FormBody.Builder builder = new FormBody.Builder();
for (Map.Entry<String, String> entry : formData.entrySet()) {
// if("items".equals(entry.getKey())){
// Map<String, String> itemsData = (Map<String, String>) entry.getValue();
// itemsData.toString();
// }else{
// }
builder.add(entry.getKey(), entry.getValue());
}
return builder.build();
}
private RequestBody createAccessTokenBody() {
FormBody.Builder builder = new FormBody.Builder();
builder.add("grant_type", grant_type)
.add("client_id", client_id)
.add("client_secret", client_secret)
.add("biz_center", biz_center)
.add("secret_level", secret_level)
.add("pubKey", pubKey);
return builder.build();
}
}

View File

@ -0,0 +1,126 @@
package shkd.repc.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.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
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.Map;
/**
* 后台任务插件
*/
public class DobeDWaccountTask extends AbstractTask implements Plugin {
private static Log log = LogFactory.getLog(DobeDWaccountTask.class);
private static final String entityName = "recos_projcostaccount";//项目成本科目实体 供应链库 表名 t_recos_pcostaccount
private static final String accEntity = "costaccountentry";//科目分录实体 供应链库 表名 t_recos_costaccount
private static final String projectEntity = "repmd_projectbill";//项目实体 表名 t_repmd_projectbill
private static final String dw_menthod = "";
@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("",1))
.header("Content-Type", "application/json")
.header("Authorization", DobeDWUtils.appCode)
.build();
String resultData = null;
try {
Response 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查询总数据量
//解析接口返回值,与系统数据比较
String projectnumber = json_body.getString("projectnumber");
DynamicObject projectinfo = QueryServiceHelper.queryOne(projectEntity,"id,billno",new QFilter[]{new QFilter("billno","=",projectnumber)});
if(projectinfo == null){
}
JSONArray detailsJson = json_body.getJSONArray("data");
String acctid = null;
String number = null;
String name = null;
String longnumber = null;
String longname = null;
String ciaccountflag = null;
String apportionway = null;
String taxrate = null;
String isleaf = null;
String level = null;
DynamicObject acctinfo = null;
for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i);
acctid = json_body.getString("accid");//科目id
number = json_body.getString("number");//科目编号
name = json_body.getString("name");//科目名称
longnumber = json_body.getString("longnumber");//科目长编号
longname = json_body.getString("longname");//科目长名称
ciaccountflag = json_body.getString("ciaccountflag");//科目类别 非建安科目and建安科目
apportionway = json_body.getString("apportionway");//分摊方式
taxrate = json_body.getString("taxrate");//税率
isleaf = json_body.getString("isleaf");//是否叶子节点
level = json_body.getString("level");//科目级次
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name) || DobeDWUtils.isEmpty(isleaf)
|| DobeDWUtils.isEmpty(level)){
//如果组织ID和组织编码 名称是空的,则跳过此记录
log.info(String.format("成本科目入参为空异常:%s", json_body.toJSONString()));
continue;
}
//根据科目id查找是否已存在
acctinfo = BusinessDataServiceHelper.loadSingle(accEntity,new QFilter[]{new QFilter("caentry_srcid","=",acctid)});
if(acctinfo == null){
//不存在,做新增 根据实体名称创建动态对象
acctinfo = BusinessDataServiceHelper.newDynamicObject(accEntity);
acctinfo.set("caentry_srcid", acctid);//源ID 用于存储数仓的科目id
acctinfo.set("caentry_number", number);
acctinfo.set("caentry_name", name);
acctinfo.set("caentry_longnumber", longnumber);
acctinfo.set("caentry_ciaccountflag", ciaccountflag);//科目类别 建安1 非建安0
acctinfo.set("caentry_apportionway", null);//分摊方式 基础资料
acctinfo.set("caentry_fullname", longname);
acctinfo.set("caentry_taxrate", taxrate);
acctinfo.set("caentry_isleaf", isleaf);
acctinfo.set("caentry_level", level);
acctinfo.set("caentry_project", projectinfo.getLong("id"));//项目
acctinfo.set("caentry_enable", true);//默认 启用
acctinfo.set("caentry_isimportaccount", true);//是否导入科目
SaveServiceHelper.save(new DynamicObject[]{acctinfo});
}else{
//已存在,做更新 编号、名称、长编号、名称、科目类别等
acctinfo.set("caentry_number", number);
acctinfo.set("caentry_name", name);
acctinfo.set("caentry_longnumber", longnumber);
acctinfo.set("caentry_fullname", longname);
acctinfo.set("caentry_taxrate", taxrate);
acctinfo.set("caentry_isleaf", isleaf);
acctinfo.set("caentry_level", level);
SaveServiceHelper.update(acctinfo);
}
}
}
}

View File

@ -0,0 +1,106 @@
package shkd.repc.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.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
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.Map;
/**
* 后台任务插件
*/
public class DobeDWorgRelationTask extends AbstractTask implements Plugin {
private static Log log = LogFactory.getLog(DobeDWorgRelationTask.class);
private static final String entityName = "qeug_recon_orgrelation";//供应链库 表名
private static final String dw_menthod = "";
@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("",1))
.header("Content-Type", "application/json")
.header("Authorization", DobeDWUtils.appCode)
.build();
String resultData = null;
try {
Response 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查询总数据量
//解析接口返回值,与系统数据比较
JSONArray detailsJson = json_body.getJSONArray("data");
DynamicObject orginfo = null;
String orgNumber = null;
String orgName = null;
String companyNumber = null;
String companyName = null;
String deptNumber = null;
String deptName = null;
for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i);
orgNumber = json_body.getString("orgNumber");
orgName = json_body.getString("orgName");
companyNumber = json_body.getString("companyNumber");
companyName = json_body.getString("companyName");
deptNumber = json_body.getString("deptNumber");
deptName = json_body.getString("deptName");
if(DobeDWUtils.isEmpty(orgNumber) || DobeDWUtils.isEmpty(companyNumber) || DobeDWUtils.isEmpty(deptNumber)){
log.info(String.format("组织对应关系接口入参为空异常:%s", json_body.toJSONString()));
continue;
}
//根据组织编号查找系统现有数据是否存在 "id,number,name,qeug_companynumber,qeug_companyname,qeug_deptnumber,qeug_deptname",
orginfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",orgNumber)});
if(orginfo != null){
//QueryServiceHelper.queryOne查出来的对象不是DynamicObject 而是平铺对象plainobject 此对象不能在后续代码中进行修改和更新;
orginfo.set("name", orgName);
orginfo.set("qeug_companynumber", companyNumber);
orginfo.set("qeug_companyname", companyName);
orginfo.set("qeug_deptnumber", deptNumber);
orginfo.set("qeug_deptname", deptName);
SaveServiceHelper.update(orginfo);
}else{
//不存在,做新增 根据实体名称创建动态对象
orginfo = BusinessDataServiceHelper.newDynamicObject(entityName);
orginfo.set("number", orgNumber);
orginfo.set("name", orgName);
orginfo.set("qeug_companynumber", companyNumber);
orginfo.set("qeug_companyname", companyName);
orginfo.set("qeug_deptnumber", deptNumber);
orginfo.set("qeug_deptname", deptName);
orginfo.set("enable", 1);
orginfo.set("creator", 1L);//创建人默认指定为超管
//保存数据:直接保存入库,不走操作校验
SaveServiceHelper.save(new DynamicObject[]{orginfo});
}
}
}
}

View File

@ -0,0 +1,137 @@
package shkd.repc.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.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
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.Date;
import java.util.Map;
/**
* 后台任务插件
*/
public class DobeDWprojectTask extends AbstractTask implements Plugin {
private static final String entityName = "repmd_projectbill";//表名 t_repmd_projectbill
private static Log log = LogFactory.getLog(DobeDWprojectTask.class);
private static final String dw_menthod = "htt";
@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("",1))
.header("Content-Type", "application/json")
.header("Authorization", DobeDWUtils.appCode)
.build();
String resultData = null;
try {
Response 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查询总数据量
//解析接口返回值,与系统数据比较
JSONArray detailsJson = json_body.getJSONArray("data");
String fbillno = null;//项目编号
String fbillname = null;//项目名称
String fprojectstageid = null;//项目阶段 repmd_projectstages t_repmd_projectstage
String fversionnum = null;//版本号
String fisleaf = null;//是否叶子节点
String faddress = null;//项目地址
String forgid = null;//所属组织
String ffiorgid = null;//核算组织
String fparentid = null;//上级项目id
DynamicObject orginfo = null;
DynamicObject projectinfo = null;
DynamicObject projectstageinfo = null;
for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i);
fbillno = json_body.getString("fbillno");
fbillname = json_body.getString("fbillname");
fversionnum = json_body.getString("fversionnum");
fisleaf = json_body.getString("fisleaf");
forgid = json_body.getString("forgid");
fprojectstageid = json_body.getString("fprojectstageid");
fparentid = json_body.getString("fparentid");
if(DobeDWUtils.isEmpty(fbillno) || DobeDWUtils.isEmpty(fbillname) || DobeDWUtils.isEmpty(forgid)){
log.info(String.format("项目接口入参为空异常:%s", json_body.toJSONString()));
continue;
}
//根据项目编号查找是否已存在
projectinfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("billno","=",fbillno)});
//项目阶段表名:t_repmd_projectstage
projectstageinfo = QueryServiceHelper.queryOne("repmd_projectstages","id,number",new QFilter[]{new QFilter("number","=",fprojectstageid)});
if(projectinfo != null){
//已存在,做更新 名称 阶段 版本号等信息;组织、编号、是否叶子节点不能更新;需要前台操作
projectinfo.set("billname", fbillname);
if(projectstageinfo != null){
projectinfo.set("projectstage", projectstageinfo.getLong("id"));//项目阶段
}
projectinfo.set("versionnum", fversionnum);
projectinfo.set("billstatus", "A");//单据状态 A保存 B已提交 C已审核
projectinfo.set("showflag", true);//是否列表显示
projectinfo.set("enable", 1);//是否启用
projectinfo.set("islatestversion", true);//是否最新版
projectinfo.set("mainprojectid", projectinfo.getLong("id"));//主项目ID
// projectinfo.set("billno", fbillno);
// projectinfo.set("org", );
// projectinfo.set("isleaf", fisleaf);
SaveServiceHelper.update(projectinfo);
}else{
//不存在,做新增 根据实体名称创建动态对象
projectinfo = BusinessDataServiceHelper.newDynamicObject(entityName);
projectinfo.set("billno", fbillno);
projectinfo.set("longnumber", fbillno);//长编码
projectinfo.set("billname", fbillname);
projectinfo.set("fullname", fbillname);//项目全称
if(!DobeDWUtils.isEmpty(fparentid)){
projectinfo.set("parent", null);//上级项目id
projectinfo.set("parentname", null);//上级项目名称
}
projectinfo.set("bizdate", new Date());//业务日期
projectinfo.set("showflag", true);//是否列表显示
if(projectstageinfo != null){
projectinfo.set("projectstage", projectstageinfo.getLong("id"));//项目阶段
}
projectinfo.set("versionnum", fversionnum);
orginfo = QueryServiceHelper.queryOne("bos_org","id,number,name",new QFilter[]{new QFilter("fyzjorgid","=",forgid)});
if(orginfo != null){
projectinfo.set("org", orginfo.getLong("id"));//项目所属组织
projectinfo.set("purchaseorg", orginfo.getLong("id"));//项目采购组织同所属组织
}else{
log.info(String.format("数仓传入的项目所属组织在金蝶中找不到:%s", forgid));
}
projectinfo.set("isleaf", fisleaf);
projectinfo.set("enable", 1);//是否启用
projectinfo.set("billstatus", "A");//单据状态 A保存 B已提交 C已审核
projectinfo.set("creator", 1L);//创建人默认指定为超管
//保存数据:直接保存入库,不走操作校验
SaveServiceHelper.save(new DynamicObject[]{projectinfo});
}
}
}
}

View File

@ -0,0 +1,55 @@
package shkd.repc.task;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.exception.KDException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.Map;
/**
* 后台任务插件
*/
public class YongyouBIPTask extends AbstractTask implements Plugin {
private static Log log = LogFactory.getLog(YongyouBIPTask.class);
// 授权模式,客户端模式为client,密码模式为:password
private static final String grant_type = "client_credentials";
//第三方应用id,对应系统中的app_id
private static final String client_id = "OA";
// 第三方应用秘钥,对请求加签使用
private static final String client_secret = "9c462d924f6e42f4996b";
//访问的BIP系统的账套code
private static final String biz_center = "01";
//加密等级
private static final String secret_level = "L0";
//公钥,加解密使用
private static final String pubKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0IwYK6tDUauBggUzzfBed9l5gP+iYCCbqWNbH5YQ0E+L+d8Q8nSCU7iwy88z/JhRiXqZJi77h5W3dVvP5jwLISYzrNq7g/jcQIZgKhAzWt2NpcojKAUk/RkKjrAlIshDf1RVdGmfkZCgo3MZfnhSKQHCVniEY2yjgYeIrq5xiHW+Bk5cEhYHKDsZsGQ/1yp9YnWJUOInTB2cxebwW3yYeCN6y7NQczywSwSrrFgzvfo3iDgTPSzA+VXuGRfisTxxDHkcT5sM2KeWvQhgNFKPtgKOU9jrv3UA+EkxRl76VWDG7XQomez/gYGlAyc6dahYv13SrLWGdIjnBgCcovEJ5wIDAQAB";
//认证接口地址
private static final String tokenUrl = "http://106.14.25.83:8090/nccloud/opm/accesstoken";
//付款金额查询接口
private static final String payUrl = "http://106.14.25.83:8090/nccloud/api/arap/arap/paybill/insertandcommit";
//合同付款申请单的实体名称
private static final String payrequestEntity = "recon_payreqbill";
//费用登记的实体名称
private static final String notextEntity = "recon_connotextbill";
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
//查找合同付款申请单已审核未付款的单子
DynamicObjectCollection docs = QueryServiceHelper.query(payrequestEntity,"id,number,name",new QFilter[]{new QFilter("billstatus","=","C")});
DynamicObject currentinfo = null;
for (int i = 0; i < docs.size(); i++) {
currentinfo = docs.get(i);
}
//查找无文本合同已审核未付款的单子
}
}

View File

@ -0,0 +1,188 @@
package shkd.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.ByteString;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DobeDWUtils {
//数仓相关的工具类 数仓接口url和appcode在此申明
public static final String appCode = "AppCode 895894e0-73de-40a9-9b1f-e87fe35a13fd";
public static final String dwUrl = "http://106.14.120.215:8080/webroot/service/publish/7e9d818c-43c0-47cf-ad4c-40c66b92bb34/";
public static final MediaType MTJSON = MediaType.get("application/json");
public static boolean isEmpty(String value) {
return value == null || value.trim().length() <= 0;
}
public static String getDateString(Date billDate){
//创建一个SimpleDateFormat对象,定义目标日期格式
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd");
//格式化Date对象为新的字符串格式
return targetFormat.format(billDate);
}
public static int getQueryCount(int totalNum){
//根据入参 计算总查询次数
//先判断大小,如果小于固定条数300,则返回1
if(300 >= totalNum){
return 1;
}
//再取余数,如果余数大于零,则返回1+商
int ys = totalNum % 300;
if(ys > 0){
return totalNum / 300 + 1;
}else{
return totalNum / 300;
}
}
public static RequestBody createRequestBody(String params, int pageNum) {
JSONObject json_body = new JSONObject();
JSONObject json_detail = new JSONObject();
json_detail.put("pageSize","300");//一页总条数固定为300
json_detail.put("pageNum",pageNum);
json_body.put("paging",json_detail);
if("person".equals(params)){
JSONArray ps = new JSONArray();
JSONObject psjson = new JSONObject();
psjson.put("name","entry_type");
psjson.put("value","");
ps.add(psjson);
psjson = new JSONObject();
psjson.put("name","employ_status");
psjson.put("value","");
ps.add(psjson);
psjson = new JSONObject();
psjson.put("name","s_date");
psjson.put("value","");
ps.add(psjson);
psjson = new JSONObject();
psjson.put("name","e_date");
psjson.put("value","");
ps.add(psjson);
json_body.put("params",ps);
}else{
json_body.put("params","[]");
}
return RequestBody.create(ByteString.encodeUtf8(json_body.toJSONString()), MTJSON);
}
public static String getTestOrgString(){
JSONObject json_body = new JSONObject();
json_body.put("totalNum","1");
JSONObject json_detail = new JSONObject();
json_detail.put("org_code","test001-01");
json_detail.put("org_name","test接口修改组织");
json_detail.put("org_id","1234567890");
json_detail.put("org_parentid","111110101011");
json_detail.put("org_shortname","test修改");
JSONArray array = new JSONArray();
array.add(json_detail);
// JSONObject json_detail1 = new JSONObject();
// json_detail1.put("org_code","test002");
// json_detail1.put("org_name","test接口新增组织2");
// json_detail1.put("org_id","1234567891");
// json_detail1.put("org_parentid","111110101011");
// json_detail1.put("org_shortname","test2");
// array.add(json_detail1);
json_body.put("data",array);
return json_body.toJSONString();
}
public static String getTestProject(){
JSONObject json_body = new JSONObject();
json_body.put("totalNum","1");
JSONObject json_detail = new JSONObject();
json_detail.put("fbillno","test0667");
json_detail.put("fbillname","test接口项目");
json_detail.put("fversionnum","gs006");
json_detail.put("forgid","111110101011");
json_detail.put("fisleaf","1");
json_detail.put("fprojectstageid","拿地阶段");
JSONArray array = new JSONArray();
array.add(json_detail);
// JSONObject json_detail1 = new JSONObject();
// json_detail1.put("org_code","test002");
// json_detail1.put("org_name","test接口新增组织2");
// json_detail1.put("org_id","1234567891");
// json_detail1.put("org_parentid","111110101011");
// json_detail1.put("org_shortname","test2");
// array.add(json_detail1);
json_body.put("data",array);
return json_body.toJSONString();
}
public static String getTestOrgRelation(){
JSONObject json_body = new JSONObject();
json_body.put("totalNum","1");
JSONObject json_detail = new JSONObject();
json_detail.put("orgNumber","test0667");
json_detail.put("orgName","test接口修改组织66");
json_detail.put("companyNumber","gs006");
json_detail.put("companyName","接口测试财务公司6");
json_detail.put("deptNumber","caiwudept2");
json_detail.put("deptName","财务部门2");
JSONArray array = new JSONArray();
array.add(json_detail);
// JSONObject json_detail1 = new JSONObject();
// json_detail1.put("org_code","test002");
// json_detail1.put("org_name","test接口新增组织2");
// json_detail1.put("org_id","1234567891");
// json_detail1.put("org_parentid","111110101011");
// json_detail1.put("org_shortname","test2");
// array.add(json_detail1);
json_body.put("data",array);
return json_body.toJSONString();
}
public static String getTestUserString(){
JSONObject json_body = new JSONObject();
json_body.put("totalNum","1");
JSONObject json_detail = new JSONObject();
json_detail.put("user_id", "1234567800");//人员id
json_detail.put("user_code", "10000001");//人员编码
json_detail.put("user_name", "张三三");//姓名
json_detail.put("username", "用户名");//用户名
json_detail.put("usertype", "1");//用户类型1:
json_detail.put("employ_status", "0");//在职状态
json_detail.put("mobile_phone", "13800000011");//手机号
json_detail.put("email", "email11@kingdee.com");//电子邮箱
json_detail.put("idcard", "");//身份证
json_detail.put("birthday", "1993-8-8");//生日
json_detail.put("gender", "1");//性别1男 0女
json_detail.put("department_id", "1234567890");
json_detail.put("jobposition", "项目经理");
JSONArray array = new JSONArray();
array.add(json_detail);
// JSONObject json_detail1 = new JSONObject();
// json_detail1.put("org_code","test002");
// json_detail1.put("org_name","test接口新增组织2");
// json_detail1.put("org_id","1234567891");
// json_detail1.put("org_parentid","111110101011");
// json_detail1.put("org_shortname","test2");
// array.add(json_detail1);
json_body.put("data",array);
return json_body.toJSONString();
}
}