人员和科目接口优化

This commit is contained in:
yuxueliang0813 2025-03-11 18:27:32 +08:00
parent 8f7248f6c4
commit f72ae66203
6 changed files with 109 additions and 127 deletions

View File

@ -31,7 +31,6 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
//实现用户没有登录的时候跳转认证中心的登录地址
//第一步认证中心的登录地址注意拼接参数和回调地址转义,注意正式地址切换
// backUrl = https://fm-test.jahwa.com.cn/ierp/auth/callbackTrdSSO.do?tenantNo=ierp-uatenv&sandboxNo=2102993326188790784;
logger.info("测试环境回调地址:"+backUrl);
callBackUrl = backUrl;
StringBuffer ssoURL = new StringBuffer();
ssoURL.append(ssologinUrl);
@ -48,6 +47,7 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
ssoURL.append(new Date().getTime());
try {
hsresponse.sendRedirect(ssoURL.toString());
logger.info("认证中心登录地址:"+ssoURL.toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -76,6 +76,7 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
private String getWorkerNumberOrUseName(HttpServletRequest hsrequest){
//第二步SSO认证系统会携带临时code浏览器重定向至应用方回调地址直接从请求中获取code
String tempCode = hsrequest.getParameter("code");
logger.info("认证中心code"+tempCode);
if(StringUtils.isEmpty(tempCode)){
return null;
}
@ -96,6 +97,8 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
}
try {
String linkPostjson = HttpClientUtils.post(ssoURL.toString(),null,null);
logger.info("认证中心Token post"+ssoURL.toString());
logger.info("认证中心Token result"+linkPostjson);
if (StringUtils.isNotEmpty(linkPostjson)) {
JSONObject jsonObject = JSONObject.parseObject(linkPostjson);
String accessToken = jsonObject.getString("access_token");
@ -106,6 +109,7 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
ssoURL.append("/esc-sso/oauth2.0/profile?access_token=");
ssoURL.append(accessToken);
linkPostjson = HttpClientUtils.get(ssoURL.toString());
logger.info("认证中心用户信息:"+linkPostjson);
if (StringUtils.isNotEmpty(linkPostjson)) {
jsonObject = JSONObject.parseObject(linkPostjson);
return jsonObject.getString("id");

View File

@ -1,5 +1,6 @@
package shjh.jhzj7.fi.fi.plugin.operate;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB;
@ -13,7 +14,9 @@ import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@ -23,7 +26,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
private static final String updateDetailSave = "update tk_shjh_clear_acctdetail set fbillstatus='A' where fid=?;";
private static final String updateDetailReject = "update tk_shjh_clear_acctdetail set fbillstatus='E' where fid=?;";
private static final String updateClearBillSave = "update tk_shjh_clear_account set fbillstatus='A' where fbillstatus='B' and fid=?;";
// private static final String updateClearBillSave = "update tk_shjh_clear_account set fbillstatus='A' where fbillstatus='B' and fid=?;";
private static final String clearBillName = "shjh_clear_account";//清账单
private static final String userName = "bos_user";//用户
@ -74,7 +77,9 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
e.setCancel(true);
}
}else if("reject".equals(eok)){
JhzjUtils.sendWEIXINQY(null,null,null,null);
List<Long> receivers = new ArrayList<>();
receivers.add(RequestContext.get().getCurrUserId());
JhzjUtils.sendWEIXINQY(null,null,receivers);
//驳回校验
if(!"B".equals(prinfo.getString("billstatus"))){
//清账明细单单据状态=已提交才允许点击驳回按钮

View File

@ -41,6 +41,8 @@ public class JhzjUtils {
public static final Long GROUPID = 100000l;//组织根节点ID
public static final Long CNY = 1l;//人民币-币别ID
private static final ILocaleString msgtag = new LocaleString("消息提醒");
private static final String groupId = "default_netctrl";//单据网络互斥默认分组
private static final Log logger = LogFactory.getLog(JhzjUtils.class);
@ -95,37 +97,31 @@ public class JhzjUtils {
/**
* 组装入参给指定人员发企微消息
* @param email 邮箱地址
* @param title1 邮件主题
* @param content1 邮件内容
* @param operation 上游操作触发
* @param title 消息主题
* @param content 消息内容
* @param receivers 信息接收人
*/
public static void sendWEIXINQY(String email, String title1, String content1,String operation){
public static void sendWEIXINQY(String title, String content, List<Long> receivers){
//构建消息体发送
MessageInfo message = new MessageInfo();
//信息title
ILocaleString title = new LocaleString("测试消息主题");
message.setMessageTitle(title);
//信息主体
ILocaleString content = new LocaleString("消息主体内容,请登录资金系统处理业务");
message.setMessageContent(content);
//信息 title
message.setMessageTitle(new LocaleString("测试消息主题"));
//信息主体 content
message.setMessageContent(new LocaleString("消息主体内容,请登录资金系统处理业务"));
//信息接收人
ArrayList<Long> receivers = new ArrayList<>();
receivers.add(RequestContext.get().getCurrUserId());
message.setUserIds(receivers);
//信息标签
ILocaleString tag = new LocaleString("消息提醒");
message.setTag(tag.getLocaleValue_zh_CN());
message.setMessageTag(tag);
//信息发送人
message.setTag(msgtag.getLocaleValue_zh_CN());
message.setMessageTag(msgtag);
//信息发送人-当前操作人
message.setSenderId(RequestContext.get().getCurrUserId());
message.setType("notice_wx");//消息类型的编号
StringBuilder notifyType = new StringBuilder();
// notifyType.append(MessageChannels.EMAIL).append(",");
// notifyType.append(MessageChannels.EMAIL.getNumber()).append(",");
notifyType.append(MessageChannels.WEIXINQY.getNumber());
message.setNotifyType(notifyType.toString());
long result = MessageCenterServiceHelper.sendMessage(message);
logger.info("微信消息返回"+result);//2163947346411418624
logger.info("微信消息返回"+result);
}
/**

View File

@ -22,7 +22,6 @@ import kd.bos.openapi.common.custom.annotation.ApiRequestBody;
import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.basedata.BaseDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
@ -81,15 +80,12 @@ public class AspAccountControler {
// String level;//层级
// String yefx;//余额方向 借1 -1
// String acctsx;//科目金额类属性 现金银行现金等价物
String bbhs;//币别核算 不核算外币 核算所有外币 指定核算币别需要指定币别ISO
// String bbhs;//币别核算 不核算外币 核算所有外币 指定核算币别需要指定币别ISO
// String descurrencynum;//指定币别编号
String acctType;//科目类型 资产负债类 损益类
String descurrencynum;//指定币别编号
DynamicObject acctInfo;
DynamicObject acctTypeInfo;
JSONObject json_body;
DynamicObjectCollection docbb;
DynamicObject bbInfo;
String bbiso;
Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系
Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联
@ -99,13 +95,11 @@ public class AspAccountControler {
for (int i = 0; i < detailsJson.size(); i++) {
json_body = detailsJson.getJSONObject(i);
number = json_body.getString("code");
// json_body = baseMaps.get(number);
// companynum = company_body.getString("companynum");//公司编号
name = json_body.getString("name");
acctType = json_body.getString("type");
bbhs = json_body.getString("acctcurrency");
descurrencynum = json_body.getString("descurrencynum");
if(EsbUtils.isEmpty(number) || EsbUtils.isEmpty(name) || EsbUtils.isEmpty(acctType) || EsbUtils.isEmpty(bbhs)){
// bbhs = json_body.getString("acctcurrency");
// descurrencynum = json_body.getString("descurrencynum");
if(EsbUtils.isEmpty(number) || EsbUtils.isEmpty(name) || EsbUtils.isEmpty(acctType)){
log.error(String.format("会计科目接口入参为空异常:%s", json_body.toJSONString()));
itemInfo = new JSONObject();
itemInfo.put("code",number);
@ -113,42 +107,25 @@ public class AspAccountControler {
itemsJson.add(itemInfo);
continue;
}
if("descurrency".equals(bbhs) && EsbUtils.isEmpty(descurrencynum)){
log.error(String.format("指定币别核算但是币别编号为空:%s", json_body.toJSONString()));
itemInfo = new JSONObject();
itemInfo.put("code",number);
itemInfo.put("error","指定币别核算但是币别编号为空");
itemsJson.add(itemInfo);
continue;
}
// if("descurrency".equals(bbhs) && EsbUtils.isEmpty(descurrencynum)){
// log.error(String.format("指定币别核算但是币别编号为空:%s", json_body.toJSONString()));
// itemInfo = new JSONObject();
// itemInfo.put("code",number);
// itemInfo.put("error","指定币别核算但是币别编号为空");
// itemsJson.add(itemInfo);
// continue;
// }
//根据科目编号和集团ID查找对应科目是否已存在
acctInfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",number),
new QFilter("createorg.id","=", JhzjUtils.GROUPID)});
// acctInfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",number)});
if(acctInfo != null){
//处理科目更新逻辑此时能修改哪些字段名称 币别核算 核算维度 是否可用
if("0".equals(json_body.getString("status"))){
//处理科目更新逻辑此时能修改哪些字段名称 是否可用
if("0".equals(json_body.getString("status")) || !name.equals(acctInfo.getString("name"))){
acctInfo.set("enable", 0);//科目禁用处理
acctInfo.set("name", name);
acctInfo.set("fullname", name);
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
}
acctInfo.set("name", name);
acctInfo.set("fullname", name);
acctInfo.set("acctcurrency", bbhs);
// acctInfo.set("useorg", 2116762463713107968l);//核算组织
//如果是指定核算币别
if("descurrency".equals(bbhs)){
//处理具体币别分录数据根据逗号进行分割
docbb = acctInfo.getDynamicObjectCollection("currencyentry");
docbb.clear();
String[] dess = descurrencynum.split(",");
for (int j = 0; j < dess.length; j++) {
bbiso = dess[j];
bbInfo = BusinessDataServiceHelper.loadSingleFromCache(bbName,new QFilter[]{new QFilter("number","=",bbiso)});
if(bbInfo != null){
docbb.addNew().set("currency",bbInfo.getLong("id"));
}
}
}
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
}else{
acctTypeInfo = BusinessDataServiceHelper.loadSingleFromCache(acctTypeName,new QFilter[]{new QFilter("number","=",acctType)});
if(acctTypeInfo == null){
@ -159,15 +136,6 @@ public class AspAccountControler {
itemsJson.add(itemInfo);
continue;
}
// hsorgInfo = getOrgInfo(companynum);
// if(hsorgInfo == null){
// log.error(String.format("公司编号在金蝶中未找到对应组织:%s", companynum));
// itemInfo = new JSONObject();
// itemInfo.put("code",number);
// itemInfo.put("error","公司编号在金蝶中未找到对应组织:"+companynum);
// itemsJson.add(itemInfo);
// continue;
// }
//不存在做新增 根据实体名称创建动态对象
acctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
acctInfo.set("accounttable", EsbUtils.ACCTABLE);//科目表fid上正式时注意此ID
@ -185,21 +153,8 @@ public class AspAccountControler {
// acctInfo.set("org", hsorgInfo.getLong("id"));//管理组织
//科目类型
acctInfo.set("accounttype", acctTypeInfo);
//币别核算--外币核算类型
acctInfo.set("acctcurrency", bbhs);//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
//如果是指定核算币别
if("descurrency".equals(bbhs)){
//处理具体币别分录数据根据逗号进行分割
docbb = acctInfo.getDynamicObjectCollection("currencyentry");
String[] dess = descurrencynum.split(",");
for (int j = 0; j < dess.length; j++) {
bbiso = dess[j];
bbInfo = BusinessDataServiceHelper.loadSingleFromCache(bbName,new QFilter[]{new QFilter("number","=",bbiso)});
if(bbInfo != null){
docbb.addNew().set("currency",bbInfo.getLong("id"));
}
}
}
//币别核算--外币核算类型--集团科目新增时默认为allcurrency
acctInfo.set("acctcurrency", "allcurrency");//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
acctInfo.set("ctrlstrategy", "1");//控制策略 5全局共享 7私有 1逐级分配
acctInfo.set("control", "nocontrol");//受控系统 nocontrol 应付 应收 资产
//损益类型
@ -283,7 +238,7 @@ public class AspAccountControler {
}
checkitementryInfo = null;
}
if(checkitementryInfo == null || dochswd.size() == 0){
if(checkitementryInfo == null || dochswd.isEmpty()){
checkitementryInfo = dochswd.addNew();
checkitementryInfo.set("asstactitem",hsxmInfo);
checkitementryInfo.set("isdetail", true);//明细
@ -337,17 +292,34 @@ public class AspAccountControler {
if(hsorgInfo == null){
continue;
}
//复制对象修改其中的某些属性比如id和组织id
newAcctInfo = copydo(oldAcctInfo,hsorgInfo);
//复制对象修改其中的某些属性比如id和组织id新增币别相关属性
newAcctInfo = copydo(oldAcctInfo,hsorgInfo,json_body);
}else{
//修改币别相关属性
newAcctInfo.set("acctcurrency", json_body.getString("acctcurrency"));
//如果是指定核算币别
// if("descurrency".equals(json_body.getString("acctcurrency"))){
// //处理具体币别分录数据根据逗号进行分割
// docbb = newAcctInfo.getDynamicObjectCollection("currencyentry");
// docbb.clear();
// String[] dess = descurrencynum.split(",");
// for (int j = 0; j < dess.length; j++) {
// bbiso = dess[j];
// bbInfo = BusinessDataServiceHelper.loadSingleFromCache(bbName,new QFilter[]{new QFilter("number","=",bbiso)});
// if(bbInfo != null){
// docbb.addNew().set("currency",bbInfo.getLong("id"));
// }
// }
// }
}
baseMaps.put(acctnum+compnum, newAcctInfo);
}
return baseMaps;
}
private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo){
private DynamicObject copydo(DynamicObject olddo, DynamicObject hsorgInfo, JSONObject json_body){
DynamicObject newAcctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
newAcctInfo.set("accounttable", EsbUtils.ACCTABLE);//科目表fid上正式时注意此ID
newAcctInfo.set("accounttable", EsbUtils.ACCTABLE);//TODO 科目表fid上正式时注意此ID
newAcctInfo.set("number", olddo.getString("number"));
newAcctInfo.set("name", olddo.getString("name"));
newAcctInfo.set("longnumber", olddo.getString("longnumber"));
@ -357,16 +329,20 @@ public class AspAccountControler {
//科目类型
newAcctInfo.set("accounttype", olddo.getDynamicObject("accounttype"));
//币别核算--外币核算类型
newAcctInfo.set("acctcurrency", olddo.getString("acctcurrency"));//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
newAcctInfo.set("acctcurrency", json_body.getString("acctcurrency"));//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
//如果是指定核算币别
if("descurrency".equals(olddo.getString("acctcurrency"))){
if("descurrency".equals(json_body.getString("acctcurrency")) && !EsbUtils.isEmpty(json_body.getString("descurrencynum"))){
//处理具体币别分录数据根据逗号进行分割
DynamicObjectCollection olddocbb = olddo.getDynamicObjectCollection("currencyentry");
DynamicObjectCollection newdocbb = newAcctInfo.getDynamicObjectCollection("currencyentry");
DynamicObject oldentryinfo;
for (int j = 0; j < olddocbb.size(); j++) {
oldentryinfo = olddocbb.get(j);
newdocbb.addNew().set("currency",oldentryinfo.getDynamicObject("currency").getLong("id"));
DynamicObjectCollection docbb = newAcctInfo.getDynamicObjectCollection("currencyentry");
String[] dess = json_body.getString("descurrencynum").split(",");
String bbiso;
DynamicObject bbInfo;
for (int j = 0; j < dess.length; j++) {
bbiso = dess[j];
bbInfo = BusinessDataServiceHelper.loadSingleFromCache(bbName,new QFilter[]{new QFilter("number","=",bbiso)});
if(bbInfo != null){
docbb.addNew().set("currency",bbInfo.getLong("id"));
}
}
}
//损益类型

View File

@ -8,6 +8,9 @@ import com.drew.lang.annotations.NotNull;
import kd.bos.api.client.ApiResult;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.id.ID;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.openapi.common.custom.annotation.ApiController;
@ -41,6 +44,7 @@ public class PersonControler implements Serializable {
private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank
private static final Log log = LogFactory.getLog(PersonControler.class);
private static final String apimenthod = "/person_sync";
private static final String insertMmapping = "insert into t_bas_immapping(FID,FOPENID,FUSERID,FIMTYPEID) values (?,?,?,3);";
/**
* @param bizParam 入参json格式数据
@ -214,7 +218,7 @@ public class PersonControler implements Serializable {
// itemInfo.put("message","");
//更新人员对应客户的银行信息
handlePersonForCustomer(result);
//TODO 处理人员金蝶id和企微id的对应关系
//处理人员金蝶id和企微id的对应关系
handlePersonImmapping(result);
}
}
@ -255,14 +259,12 @@ public class PersonControler implements Serializable {
private void handlePersonImmapping(UserParam ups){
/*
* 这里可以使用企业微信同步用户也可以直接在系统库中t_bas_immapping表插入数据需要苍穹中用户的主键和微信中用户的openId可以在苍穹的系统库使用sql
insert into t_bas_immapping (fid, FIMTYPEID, FOPENID) value (主键, 类型暂时随便给值也可以, '微信公众号用户的openId');
insert into t_bas_immapping (fid, FIMTYPEID, FOPENID) value (主键, 类型3, '微信公众号用户的openId');
update t_bas_immapping SET FUSERID = (select fid from t_sec_user where fphone = '用户手机号') where fid = '用户手机号';
如果没有同步用户即t_bas_immapping表中查不到数据则会跳转到苍穹登陆界面用户输入信息之后苍穹会自动在t_bas_immapping中获取openid并存储
* 此逻辑在kd.bos.login.thirdauth.app.tencent.WxgzhLoginAfter中目前标准代码存在bug多系统对接对于同一个fuserid会替换openid
* 导致单点登录到别的系统失败多系统对接需要修改总部标准代码或者联系总部出私包解决
* select fid,FIMTYPEID,FOPENID,FUSERID from t_bas_immapping
* */
*/
//insert into t_bas_immapping(fid,FIMTYPEID,FOPENID,FUSERID) values (1992929292121,3,'690',2116742421407602688)
DB.update(DBRoute.of("sys"), insertMmapping, new Object[]{ID.genLongId(),ups.getDataMap().get("shjh_oaid"),ups.getId()});
}
private void handlePersonForCustomer(UserParam ups){

View File

@ -54,11 +54,7 @@ public class AccountModel implements Serializable {
private String name;
@ApiParam(value="类型",position=3)
private String type;
@ApiParam(value="币别核算",position=4)
private String acctcurrency;
@ApiParam(value="指定币别编号",position=5)
private String descurrencynum;
@ApiParam(value="使用状态",position=6)
@ApiParam(value="使用状态",position=4)
private String status;
public String getCode() {
@ -85,22 +81,6 @@ public class AccountModel implements Serializable {
this.type = type;
}
public String getAcctcurrency() {
return acctcurrency;
}
public void setAcctcurrency(String acctcurrency) {
this.acctcurrency = acctcurrency;
}
public String getDescurrencynum() {
return descurrencynum;
}
public void setDescurrencynum(String descurrencynum) {
this.descurrencynum = descurrencynum;
}
public String getStatus() {
return status;
}
@ -118,6 +98,10 @@ public class AccountModel implements Serializable {
private String companynum;
@ApiParam(value="公司层面使用状态",position=3)
private String companystatus;
@ApiParam(value="币别核算",position=4)
private String acctcurrency;
@ApiParam(value="指定币别编号",position=5)
private String descurrencynum;
public String getCode() {
return code;
@ -142,6 +126,21 @@ public class AccountModel implements Serializable {
public void setCompanystatus(String companystatus) {
this.companystatus = companystatus;
}
public String getAcctcurrency() {
return acctcurrency;
}
public void setAcctcurrency(String acctcurrency) {
this.acctcurrency = acctcurrency;
}
public String getDescurrencynum() {
return descurrencynum;
}
public void setDescurrencynum(String descurrencynum) {
this.descurrencynum = descurrencynum;
}
}
@ApiModel