收款处理-SAP凭证接口
This commit is contained in:
parent
815073e4d2
commit
b00b5d1d10
|
|
@ -15,7 +15,7 @@ import shjh.jhzj7.fi.fi.plugin.form.info.ClaimFieldsInfo;
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态表单插件-【认领处理单】————已作废,全部逻辑界面规则配置
|
* 动态表单插件-【认领处理单】
|
||||||
* @author LiGuiQiang
|
* @author LiGuiQiang
|
||||||
*/
|
*/
|
||||||
public class ClaimBillFormPlugin extends AbstractFormPlugin implements Plugin {
|
public class ClaimBillFormPlugin extends AbstractFormPlugin implements Plugin {
|
||||||
|
|
|
||||||
|
|
@ -223,48 +223,24 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin {
|
||||||
JSONObject root = JSONObject.parseObject(response);
|
JSONObject root = JSONObject.parseObject(response);
|
||||||
JSONObject data = root.getJSONObject("data");
|
JSONObject data = root.getJSONObject("data");
|
||||||
JSONObject data2 = data.getJSONObject("data");
|
JSONObject data2 = data.getJSONObject("data");
|
||||||
JSONArray rows = data2.getJSONArray("LoanItems");
|
JSONArray loanItems = data2.getJSONArray("LoanItems");
|
||||||
|
JSONArray voucherItems = data2.getJSONArray("VoucherItems");
|
||||||
DynamicObjectCollection entry = this.getModel().getEntryEntity(ENTRY_KEY);
|
DynamicObjectCollection entry = this.getModel().getEntryEntity(ENTRY_KEY);
|
||||||
entry.clear();
|
entry.clear();
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
for (int i = 0; i < loanItems.size(); i++) {
|
||||||
JSONObject top = (JSONObject) rows.get(i);
|
JSONObject top = (JSONObject) loanItems.get(i);
|
||||||
JSONArray loanDetailInfo = top.getJSONArray("LoanDetailInfo");
|
JSONArray loanDetailInfo = top.getJSONArray("LoanDetailInfo");
|
||||||
JSONObject detail = (JSONObject) loanDetailInfo.get(0);
|
for (int j = 0; j < loanDetailInfo.size(); j++) {
|
||||||
entry.addNew();
|
JSONObject detail = (JSONObject) loanDetailInfo.get(j);
|
||||||
setPaymentApiValues(top, detail, i);
|
entry.addNew();
|
||||||
|
setPaymentApiValues(top, detail, i ,voucherItems );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("预付单数据解析异常: " + e.getMessage(), e);
|
logger.error("预付单数据解析异常: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 预付单赋值
|
|
||||||
*
|
|
||||||
* @param top json头参数
|
|
||||||
* @param detail json分录参数
|
|
||||||
* @param i
|
|
||||||
*/
|
|
||||||
private void setPaymentApiValues(JSONObject top, JSONObject detail, int i) {
|
|
||||||
try {
|
|
||||||
this.getModel().setValue("shjh_billno", top.getString("CompanyCode"), i);
|
|
||||||
this.getModel().setValue("shjh_prepaymentnum", top.getString("RequestCode"), i);
|
|
||||||
this.getModel().setValue("shjh_purchasenum", detail.getString("PoOrderNo"), i);
|
|
||||||
this.getModel().setValue("shjh_purchaselinenum", detail.getString("PoOrderColNo"), i);
|
|
||||||
this.getModel().setValue("shjh_billsubject", detail.getString("RequestName"), i);
|
|
||||||
this.getModel().setValue("shjh_prepaymentdate", top.getString("RequestDate"), i);
|
|
||||||
this.getModel().setValue("shjh_paymentamount", top.getBigDecimal("RequestAmt"), i);
|
|
||||||
this.getModel().setValue("shjh_documentamount", top.getBigDecimal("AvailableAmt"), i);
|
|
||||||
this.getModel().setValue("shjh_verificationnum", top.getString("StrColumn20"), i);
|
|
||||||
this.getModel().setValue("shjh_fiscalyear", top.getString("GLDate").substring(0, 4), i);
|
|
||||||
this.getModel().setValue("shjh_billheaderid", detail.getString("BillHeaderID"), i);
|
|
||||||
this.getModel().setValue("shjh_detailid", detail.getString("DetailID"), i);
|
|
||||||
this.getModel().setValue("shjh_usercode", top.getString("RequestUserCode"), i);
|
|
||||||
this.getModel().setValue("shjh_deptcode", top.getString("RequestDeptCode"), i);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("预付单赋值异常: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 借款单数据解析
|
* 借款单数据解析
|
||||||
|
|
@ -278,37 +254,81 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin {
|
||||||
JSONObject data = root.getJSONObject("data");
|
JSONObject data = root.getJSONObject("data");
|
||||||
JSONObject data2 = data.getJSONObject("data");
|
JSONObject data2 = data.getJSONObject("data");
|
||||||
JSONArray rows = data2.getJSONArray("LoanItems");
|
JSONArray rows = data2.getJSONArray("LoanItems");
|
||||||
|
JSONArray voucherItems = data2.getJSONArray("VoucherItems");
|
||||||
DynamicObjectCollection entry = this.getModel().getEntryEntity(ENTRY_KEY);
|
DynamicObjectCollection entry = this.getModel().getEntryEntity(ENTRY_KEY);
|
||||||
entry.clear();
|
entry.clear();
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
JSONObject top = (JSONObject) rows.get(i);
|
JSONObject top = (JSONObject) rows.get(i);
|
||||||
entry.addNew();
|
entry.addNew();
|
||||||
setLoanApiValues(top, i);
|
setLoanApiValues(top, i,voucherItems);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("借款单数据解析异常: " + e.getMessage(), e);
|
logger.error("借款单数据解析异常: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预付单赋值
|
||||||
|
*
|
||||||
|
* @param top json头参数
|
||||||
|
* @param detail json分录参数
|
||||||
|
* @param i
|
||||||
|
*/
|
||||||
|
private void setPaymentApiValues(JSONObject top, JSONObject detail, int i ,JSONArray voucherItems) {
|
||||||
|
try {
|
||||||
|
this.getModel().setValue("shjh_prepaymentnum", detail.getString("RequestCode"), i);
|
||||||
|
this.getModel().setValue("shjh_purchasenum", detail.getString("PoOrderNo"), i);
|
||||||
|
this.getModel().setValue("shjh_purchaselinenum", detail.getString("PoOrderColNo"), i);
|
||||||
|
this.getModel().setValue("shjh_billsubject", detail.getString("RequestName"), i);
|
||||||
|
this.getModel().setValue("shjh_prepaymentdate", top.getString("RequestDate"), i);
|
||||||
|
this.getModel().setValue("shjh_paymentamount", detail.getBigDecimal("RequestAmt"), i);
|
||||||
|
this.getModel().setValue("shjh_documentamount", detail.getBigDecimal("AvailableAmt"), i);
|
||||||
|
this.getModel().setValue("shjh_detailid", detail.getString("DetailID"), i);
|
||||||
|
setPublicValues(top,i,voucherItems);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("预付单赋值异常: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 借款单赋值
|
* 借款单赋值
|
||||||
*
|
*
|
||||||
* @param top
|
* @param top
|
||||||
* @param i
|
* @param i
|
||||||
*/
|
*/
|
||||||
private void setLoanApiValues(JSONObject top,int i) {
|
private void setLoanApiValues(JSONObject top,int i,JSONArray voucherItems) {
|
||||||
try {
|
try {
|
||||||
this.getModel().setValue("shjh_billno", top.getString("CompanyCode"), i);
|
|
||||||
this.getModel().setValue("shjh_loannum", top.getString("RequestCode"), i);
|
this.getModel().setValue("shjh_loannum", top.getString("RequestCode"), i);
|
||||||
this.getModel().setValue("shjh_loanamount", top.getBigDecimal("RequestAmt"), i);
|
this.getModel().setValue("shjh_loanamount", top.getBigDecimal("RequestAmt"), i);
|
||||||
this.getModel().setValue("shjh_loanbalance", top.getBigDecimal("AvailableAmt"), i);
|
this.getModel().setValue("shjh_loanbalance", top.getBigDecimal("AvailableAmt"), i);
|
||||||
this.getModel().setValue("shjh_verificationnum", top.getString("StrColumn20"), i);
|
setPublicValues(top,i,voucherItems);
|
||||||
this.getModel().setValue("shjh_fiscalyear", top.getString("GLDate").substring(0, 4), i);
|
} catch (Exception e) {
|
||||||
|
logger.error("借款单赋值异常: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPublicValues(JSONObject top,int i,JSONArray voucherItems) {
|
||||||
|
try {
|
||||||
|
this.getModel().setValue("shjh_billno", top.getString("CompanyCode"), i);//公司编号
|
||||||
|
this.getModel().setValue("shjh_verificationnum", top.getString("StrColumn20"), i);//核销单凭证号
|
||||||
|
this.getModel().setValue("shjh_fiscalyear", top.getString("GLDate").substring(0, 4), i);//会计年度
|
||||||
this.getModel().setValue("shjh_billheaderid", top.getString("ID"), i);
|
this.getModel().setValue("shjh_billheaderid", top.getString("ID"), i);
|
||||||
this.getModel().setValue("shjh_usercode", top.getString("RequestUserCode"), i);
|
this.getModel().setValue("shjh_usercode", top.getString("RequestUserCode"), i);
|
||||||
this.getModel().setValue("shjh_deptcode", top.getString("RequestDeptCode"), i);
|
this.getModel().setValue("shjh_deptcode", top.getString("RequestDeptCode"), i);
|
||||||
|
String id = top.getString("ID");
|
||||||
|
for (int i1 = 0; i1 < voucherItems.size(); i1++) {
|
||||||
|
JSONObject voucherItem = (JSONObject)voucherItems.get(i1);
|
||||||
|
if (voucherItem.getString("BillHeaderID").equals(id)){
|
||||||
|
this.getModel().setValue("shjh_coaitemfullname", voucherItem.getString("COAItemFullName"), i);
|
||||||
|
this.getModel().setValue("shjh_coaitemcode", voucherItem.getString("COAItemCode"), i);
|
||||||
|
this.getModel().setValue("shjh_coaitemname", voucherItem.getString("COAItemName"), i);
|
||||||
|
this.getModel().setValue("shjh_reasoncode", voucherItem.getString("ReasonCode"), i);
|
||||||
|
this.getModel().setValue("shjh_reasoncodename", voucherItem.getString("ReasonCodeName"), i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("借款单赋值异常: " + e.getMessage(), e);
|
logger.error("赋值异常: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class RecBillAddEntryPushPlugin extends AbstractBillPlugIn implements RowClickEventListener,Plugin {
|
public class RecBillAddEntryPushPlugin extends AbstractBillPlugIn implements RowClickEventListener,Plugin {
|
||||||
|
|
||||||
private final static Log logger = LogFactory.getLog(RecBillAddTopPushPlugin.class);
|
private final static Log logger = LogFactory.getLog(RecBillAddEntryPushPlugin.class);
|
||||||
|
|
||||||
private static final String ENTITY_REC_BILL = "cas_recbill";
|
private static final String ENTITY_REC_BILL = "cas_recbill";
|
||||||
private static final String TARGET_NAME="shjh_supplementpush";
|
private static final String TARGET_NAME="shjh_supplementpush";
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||||
|
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.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据操作插件
|
||||||
|
* 收款处理提交自动带出资金计划科目
|
||||||
|
*/
|
||||||
|
public class RecBillSubmitOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(RecBillSubmitOperation.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||||
|
super.afterExecuteOperationTransaction(e);
|
||||||
|
//付款单提交之后 付款标识为被动付款,并且资金计划科目为空,从配置表(shjh_pay_account)携带资金计划科目
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
for (DynamicObject bill : dataEntities) {
|
||||||
|
bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"cas_recbill");
|
||||||
|
DynamicObject planClass = bill.getDynamicObject("shjh_planclass");
|
||||||
|
if (null == planClass) {
|
||||||
|
//根据配置表携带资金计划科目
|
||||||
|
bill.set("shjh_planclass", xdMembersubject(bill));
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{bill});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DynamicObject xdMembersubject(DynamicObject bill){
|
||||||
|
//收款单,系统自动根据配置表(shjh_pay_account)带出资金计划科目
|
||||||
|
QFilter qFilter = new QFilter("shjh_biztype", QCP.equals,"B");//业务类型:收款
|
||||||
|
//公司范围_多选基础资料
|
||||||
|
DynamicObject openorg = bill.getDynamicObject("openorg");
|
||||||
|
if (null != openorg) {
|
||||||
|
Long orgid = openorg.getLong("id");
|
||||||
|
QFilter q1 = new QFilter("shjh_companys.fbasedataid", QCP.equals, orgid);
|
||||||
|
qFilter = qFilter.and(q1);
|
||||||
|
}
|
||||||
|
//业务大类
|
||||||
|
DynamicObject shjhBizbig = bill.getDynamicObject("shjh_bizebig");
|
||||||
|
if (null != shjhBizbig) {
|
||||||
|
Long shjhBizbigid = shjhBizbig.getLong("id");
|
||||||
|
QFilter q2 = new QFilter("shjh_bizbig.fbasedataid", QCP.equals, shjhBizbigid);
|
||||||
|
qFilter = qFilter.and(q2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//业务小类
|
||||||
|
DynamicObject shjhbizsmall = bill.getDynamicObject("shjh_bizsmall");
|
||||||
|
if (null != shjhbizsmall) {
|
||||||
|
Long shjhbizsmallid = shjhbizsmall.getLong("id");
|
||||||
|
QFilter q3 = new QFilter("shjh_bizsmall.fbasedataid", QCP.equals, shjhbizsmallid);
|
||||||
|
qFilter = qFilter.and(q3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//成本中心 shjh_costcenter
|
||||||
|
DynamicObject shjhCostcenter = bill.getDynamicObject("shjh_costcenter");
|
||||||
|
if (null != shjhCostcenter) {
|
||||||
|
Long costcenterid = shjhCostcenter.getLong("id");
|
||||||
|
QFilter q4 = new QFilter("shjh_cc.fbasedataid", QCP.equals, costcenterid);
|
||||||
|
qFilter = qFilter.and(q4);
|
||||||
|
}
|
||||||
|
|
||||||
|
//原因码 shjh_reasoncode
|
||||||
|
//会计科目 shjh_coaitemcode
|
||||||
|
DynamicObjectCollection entrys = bill.getDynamicObjectCollection("entry");//付款明细
|
||||||
|
if (!entrys.isEmpty()) {
|
||||||
|
DynamicObject entry = entrys.get(0);
|
||||||
|
DynamicObject shjhYym = entry.getDynamicObject("shjh_yym");
|
||||||
|
if (null != shjhYym) {
|
||||||
|
Long yymid = shjhYym.getLong("id");
|
||||||
|
QFilter q5 = new QFilter("shjh_yym.fbasedataid", QCP.equals, yymid);
|
||||||
|
qFilter = qFilter.and(q5);
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject shjhSapkjkm = entry.getDynamicObject("shjh_accountsap");
|
||||||
|
if (null != shjhSapkjkm) {
|
||||||
|
Long kjkmid = shjhSapkjkm.getLong("id");
|
||||||
|
QFilter q6 = new QFilter("shjh_kjkm.fbasedataid", QCP.equals, kjkmid);
|
||||||
|
qFilter = qFilter.and(q6);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject[] accounts = BusinessDataServiceHelper.load("shjh_pay_account", "id,shjh_membersubject", qFilter.toArray());
|
||||||
|
if (accounts.length > 1) {
|
||||||
|
// 根据生效日期,失效日期区间,判断当前时间满足的数据
|
||||||
|
Date currentDate = new Date();
|
||||||
|
QFilter startDateFilter = new QFilter("shjh_begindate", QCP.less_equals, currentDate);
|
||||||
|
QFilter endDateFilter = new QFilter("shjh_enddate", QCP.large_equals, currentDate);
|
||||||
|
QFilter newFilter = qFilter.and(startDateFilter).and(endDateFilter);
|
||||||
|
accounts = BusinessDataServiceHelper.load("shjh_pay_account", "id", newFilter.toArray());
|
||||||
|
}
|
||||||
|
if (accounts.length > 0) {
|
||||||
|
// 处理找到符合条件的账户
|
||||||
|
DynamicObject account = accounts[0];
|
||||||
|
account = BusinessDataServiceHelper.loadSingle(account.getPkValue(), "shjh_pay_account");
|
||||||
|
return account.getDynamicObject("shjh_membersubject");
|
||||||
|
} else {
|
||||||
|
log.info("没有找到符合条件的资金计划科目");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,442 @@
|
||||||
|
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
|
import kd.bos.entity.ExtendedDataEntity;
|
||||||
|
import kd.bos.entity.formula.RowDataModel;
|
||||||
|
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
|
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||||
|
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||||
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||||
|
import kd.bos.entity.validate.AbstractValidator;
|
||||||
|
import kd.bos.entity.validate.ErrorLevel;
|
||||||
|
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.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
import shjh.jhzj7.fi.fi.plugin.form.info.RecFieldsInfo;
|
||||||
|
import shjh.jhzj7.fi.fi.utils.ApiUtils;
|
||||||
|
import shjh.jhzj7.fi.fi.utils.EsbUtils;
|
||||||
|
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||||
|
import shjh.jhzj7.fi.fi.utils.SysUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static shjh.jhzj7.fi.fi.utils.SapUtils.sap_accounVoucher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据操作插件
|
||||||
|
* 收款单推送SAP凭证
|
||||||
|
*/
|
||||||
|
public class RecPushVoucherOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||||
|
|
||||||
|
private final static Log logger = LogFactory.getLog(RecPushVoucherOperation.class);
|
||||||
|
|
||||||
|
private static final String INTERFACE_ID ="FinancialTransactionVoucher";//识别被调接口并进行路由-凭证推送
|
||||||
|
|
||||||
|
private static final String RECEIVER_ID ="SAP";//定义的发送者
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作标识
|
||||||
|
*/
|
||||||
|
private static final String KEY_PUSH_VOUCHER= "pushvoucher";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作执行前,准备加载单据数据之前,触发此事件
|
||||||
|
*
|
||||||
|
* @remark 插件可以在此事件中,指定需要加载的字段
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
e.getFieldKeys().add(PushVoucherValidator.KEY_VOUCHER_NUM);
|
||||||
|
e.getFieldKeys().add(PushVoucherValidator.KEY_BILL_STATUS);
|
||||||
|
e.getFieldKeys().add(PushVoucherValidator.KEY_BILL_NUMBER);
|
||||||
|
e.getFieldKeys().add(PushVoucherValidator.KEY_IS_PUSH_SAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行操作校验前,触发此事件
|
||||||
|
*
|
||||||
|
* @remark 插件可以在此事件,调整预置的操作校验器;或者增加自定义操作校验器
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||||
|
super.onAddValidators(e);
|
||||||
|
//添加自定义校验器:1.单据状态=已收款 2.收款明细!=空 3.是否已推送SAP=false 4.SAP凭证号=空
|
||||||
|
e.addValidator(new RebReversalFiOperation.ReversalValidator());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义校验器
|
||||||
|
*/
|
||||||
|
static class PushVoucherValidator extends AbstractValidator {
|
||||||
|
/**
|
||||||
|
* 单据编码
|
||||||
|
*/
|
||||||
|
public final static String KEY_BILL_NUMBER = "billno";
|
||||||
|
/**
|
||||||
|
* 单据状态
|
||||||
|
*/
|
||||||
|
public final static String KEY_BILL_STATUS = "billstatus";
|
||||||
|
/**
|
||||||
|
* SAP凭证号字段标识
|
||||||
|
*/
|
||||||
|
public final static String KEY_VOUCHER_NUM = "shjh_vouchernum";
|
||||||
|
/**
|
||||||
|
* 是否已推送SAP
|
||||||
|
*/
|
||||||
|
public final static String KEY_IS_PUSH_SAP ="shjh_vouchernum";
|
||||||
|
/**
|
||||||
|
* 是否已生成凭证
|
||||||
|
*/
|
||||||
|
public final static String KEY_IS_VOUCHER ="isvoucher";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
//取数模型
|
||||||
|
RowDataModel rowDataModel = new RowDataModel(this.entityKey, this.getValidateContext().getSubEntityType());
|
||||||
|
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||||
|
if (dataEntities != null && dataEntities.length >= 1) {
|
||||||
|
for (ExtendedDataEntity dataEntity : dataEntities) {
|
||||||
|
if (dataEntity != null) {
|
||||||
|
rowDataModel.setRowContext(dataEntity.getDataEntity());
|
||||||
|
String billNo = (String) rowDataModel.getValue(KEY_BILL_NUMBER);
|
||||||
|
String type = (String) rowDataModel.getValue(KEY_BILL_STATUS);
|
||||||
|
if (!"D".equals(type)){
|
||||||
|
this.addErrorMessage(dataEntity, "【" + billNo + "】未付款,无法推送。");
|
||||||
|
}
|
||||||
|
String voucherNum = (String) rowDataModel.getValue(KEY_VOUCHER_NUM);
|
||||||
|
boolean result = (boolean) rowDataModel.getValue(KEY_IS_PUSH_SAP);
|
||||||
|
if (!voucherNum.isEmpty()||result) {
|
||||||
|
this.addErrorMessage(dataEntity, "【" + billNo + "】已推送SAP,请勿重复推送。");
|
||||||
|
}
|
||||||
|
boolean isVoucher = (boolean) rowDataModel.getValue(KEY_IS_VOUCHER);
|
||||||
|
if (!isVoucher) {
|
||||||
|
this.addErrorMessage(dataEntity, "【" + billNo + "】未生成金蝶凭证,无法推送。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||||
|
//TODO:调用SAP预付款单接口
|
||||||
|
String operationKey = e.getOperationKey();
|
||||||
|
if (StringUtils.equals(KEY_PUSH_VOUCHER, operationKey)) {
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
if (dataEntities != null && dataEntities.length >= 1) {
|
||||||
|
for (DynamicObject dataEntity : dataEntities) {
|
||||||
|
DynamicObject recBill = BusinessDataServiceHelper.loadSingle(dataEntity.getLong("id"), "cas_recbill");
|
||||||
|
if (null != recBill) {
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
//抬头,参考《IS_HEADER》
|
||||||
|
data.put("IS_HEADER", getIS_HEADER(recBill));
|
||||||
|
//详细,参考《IT_ITEM》
|
||||||
|
data.put("IT_ITEM", getIT_ITEM(recBill));
|
||||||
|
//收款类型=推预付款、员工还款需要传清账数据
|
||||||
|
String receivingType = recBill.getString("receivingtype.number");
|
||||||
|
if ("103".equals(receivingType)||"109".equals(receivingType)) {
|
||||||
|
//清账数据,参考《IT_CLEAR》,仅清账需要输入
|
||||||
|
data.put("IT_CLEAR", getIT_CLEAR(recBill));
|
||||||
|
}
|
||||||
|
String type = recBill.getString(RecFieldsInfo.PAYER_TYPE);
|
||||||
|
long id = recBill.getLong("payer");
|
||||||
|
if (null!=type&&id!=0L){
|
||||||
|
Boolean disposableCusOrSup = SysUtils.isDisposableCusOrSup(id, type);
|
||||||
|
if (disposableCusOrSup){
|
||||||
|
//一次性供应商或客户信息(仅需要填写)
|
||||||
|
data.put("IS_CUSTOMERCPD", getIS_CUSTOMERCPD(recBill));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sap_accounVoucher(data,recBill.getString("billno"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取SAP凭证头信息
|
||||||
|
* @param recBill 收款单动态对象
|
||||||
|
* @return 包含凭证头信息的JSONObject
|
||||||
|
*/
|
||||||
|
private JSONObject getIS_HEADER(DynamicObject recBill) {
|
||||||
|
JSONObject IS_HEADER = new JSONObject();
|
||||||
|
|
||||||
|
// 使用线程安全的日期格式化
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
// 公司代码
|
||||||
|
IS_HEADER.put("BUKRS", recBill.getString("org.number"));
|
||||||
|
|
||||||
|
// 凭证类型(留空)
|
||||||
|
IS_HEADER.put("BLART", "");
|
||||||
|
|
||||||
|
// 凭证日期
|
||||||
|
Date bizDate = recBill.getDate("bizdate");
|
||||||
|
IS_HEADER.put("BLDAT", bizDate != null ? format.format(bizDate) : "");
|
||||||
|
|
||||||
|
// 过账日期(修正了原代码中错误的条件判断)
|
||||||
|
Date payeeDate = recBill.getDate("payeedate");
|
||||||
|
IS_HEADER.put("BUDAT", payeeDate != null ? format.format(payeeDate) : "");
|
||||||
|
|
||||||
|
// 币种
|
||||||
|
DynamicObject currency = recBill.getDynamicObject("currency");
|
||||||
|
String isoCode = currency != null ? currency.getString("number") : "";
|
||||||
|
IS_HEADER.put("WAERS", JhzjUtils.getCurrencyCode(isoCode));
|
||||||
|
|
||||||
|
// 参考凭证号
|
||||||
|
IS_HEADER.put("XBLNR", recBill.getString("billno"));
|
||||||
|
|
||||||
|
// 凭证抬头文本
|
||||||
|
IS_HEADER.put("BKTXT", recBill.getString("payername"));
|
||||||
|
|
||||||
|
// 固定值
|
||||||
|
IS_HEADER.put("USNAM", "资金系统");
|
||||||
|
|
||||||
|
// 以下字段初始化为空
|
||||||
|
IS_HEADER.put("KUNNR", ""); // 客户编号
|
||||||
|
IS_HEADER.put("LIFNR", ""); // 供应商编号
|
||||||
|
IS_HEADER.put("ZUONR", ""); // 分配编号
|
||||||
|
|
||||||
|
return IS_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取SAP凭证行项目信息
|
||||||
|
* @param recBill 收款单动态对象
|
||||||
|
* @return 包含行项目信息的JSONArray
|
||||||
|
*/
|
||||||
|
private JSONArray getIT_ITEM(DynamicObject recBill) {
|
||||||
|
JSONArray IT_ITEM = new JSONArray();
|
||||||
|
|
||||||
|
// 1. 获取客户/供应商编号
|
||||||
|
String payerType = recBill.getString("payertype");
|
||||||
|
String cusOrSupNumber = getCustomerOrSupplierNumber(payerType, recBill);
|
||||||
|
|
||||||
|
// 2. 获取原因码和SAP行项目文本
|
||||||
|
String RSTGR = "";
|
||||||
|
String SGTXT = "";
|
||||||
|
DynamicObjectCollection entrys = recBill.getDynamicObjectCollection("entry");
|
||||||
|
if (entrys != null && !entrys.isEmpty()) {
|
||||||
|
DynamicObject entry = entrys.get(0);
|
||||||
|
DynamicObject shjhYym = entry.getDynamicObject("shjh_yym");
|
||||||
|
RSTGR = shjhYym != null ? shjhYym.getString("number") : "";
|
||||||
|
SGTXT = entry.getString("shjh_sapline");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 获取成本中心
|
||||||
|
String KOSTL = "";
|
||||||
|
DynamicObject shjhCostcenter = recBill.getDynamicObject("shjh_costcenter");
|
||||||
|
if (shjhCostcenter != null) {
|
||||||
|
KOSTL = shjhCostcenter.getString("number");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 获取利润中心
|
||||||
|
String PRCTR = "";
|
||||||
|
DynamicObject shjhPc = recBill.getDynamicObject("shjh_profitcenter");
|
||||||
|
if (shjhPc != null) {
|
||||||
|
PRCTR = shjhPc.getString("number");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 查询关联的凭证信息
|
||||||
|
DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle("gl_voucher",
|
||||||
|
"id,sourcebill,entries,entries.account,entries.debitlocal,entries.creditlocal,entries.entrydc",
|
||||||
|
new QFilter("sourcebill", QCP.equals, recBill.getPkValue()).toArray());
|
||||||
|
|
||||||
|
if (gl_voucher != null) {
|
||||||
|
DynamicObjectCollection entries = gl_voucher.getDynamicObjectCollection("entries");
|
||||||
|
if (entries != null && !entries.isEmpty()) {
|
||||||
|
for (DynamicObject entry : entries) {
|
||||||
|
JSONObject IT_ITEMS = new JSONObject();
|
||||||
|
|
||||||
|
// 设置客户/供应商编号
|
||||||
|
switch (payerType) {
|
||||||
|
case "bd_customer":
|
||||||
|
IT_ITEMS.put("KUNNR", cusOrSupNumber);
|
||||||
|
break;
|
||||||
|
case "bd_supplier":
|
||||||
|
IT_ITEMS.put("LIFNR", cusOrSupNumber);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置科目
|
||||||
|
DynamicObject account = entry.getDynamicObject("account");
|
||||||
|
if (account != null) {
|
||||||
|
IT_ITEMS.put("HKONT", account.getString("number"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理金额
|
||||||
|
BigDecimal debitlocal = (BigDecimal) entry.get("debitlocal");
|
||||||
|
BigDecimal creditlocal = (BigDecimal) entry.get("creditlocal");
|
||||||
|
String entrydc = (String) entry.get("entrydc");
|
||||||
|
|
||||||
|
if (debitlocal != null && creditlocal != null && entrydc != null) {
|
||||||
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
switch (entrydc) {
|
||||||
|
case "1": // 借方
|
||||||
|
amount = debitlocal;
|
||||||
|
break;
|
||||||
|
case "-1": // 贷方
|
||||||
|
amount = creditlocal.negate();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.warn("无效的分录方向: " + entrydc);
|
||||||
|
}
|
||||||
|
IT_ITEMS.put("DMBTR", amount.toString());
|
||||||
|
} else {
|
||||||
|
logger.warn("凭证分录金额或方向为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置其他字段
|
||||||
|
IT_ITEMS.put("SGTXT", SGTXT);
|
||||||
|
IT_ITEMS.put("RSTGR", RSTGR);
|
||||||
|
IT_ITEMS.put("KOSTL", KOSTL);
|
||||||
|
IT_ITEMS.put("PRCTR", PRCTR);
|
||||||
|
|
||||||
|
IT_ITEM.add(IT_ITEMS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IT_ITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款清账凭证
|
||||||
|
* @param recBill
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private JSONArray getIT_CLEAR(DynamicObject recBill){
|
||||||
|
JSONArray IT_CLEAR = new JSONArray();
|
||||||
|
JSONObject IT_CLEARS = new JSONObject();
|
||||||
|
IT_CLEARS.put("BUKRS",recBill.getString("org.number"));//公司代码
|
||||||
|
IT_CLEARS.put("BELNR",recBill.getString("shjh_vouchernum"));//会计凭证编号
|
||||||
|
IT_CLEARS.put("GJAHR",recBill.getString("shjh_sapfiscalyear"));//会计年度
|
||||||
|
IT_CLEARS.put("BUZEI",recBill.getString("shjh_sapline"));//行编号
|
||||||
|
IT_CLEARS.put("KUNNR","");//客户编号
|
||||||
|
IT_CLEARS.put("LIFNR","");//供应商编号
|
||||||
|
IT_CLEARS.put("HKONT","");//总账科目
|
||||||
|
IT_CLEARS.put("UMSKZ","");//特殊总帐标识
|
||||||
|
IT_CLEARS.put("DMBTR","");//未清金额
|
||||||
|
IT_CLEARS.put("DMBTR1","");//清账金额
|
||||||
|
IT_CLEARS.put("DMBTR2","");//剩余金额
|
||||||
|
IT_CLEARS.put("ERLKZ","");//已完成的未清项标识符
|
||||||
|
IT_CLEAR.add(IT_CLEARS);
|
||||||
|
|
||||||
|
return IT_CLEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONArray getIS_CUSTOMERCPD(DynamicObject recBill) {
|
||||||
|
JSONArray IS_CUSTOMERCPD = new JSONArray();
|
||||||
|
|
||||||
|
// 提取公共字段(只需获取一次)
|
||||||
|
String city = recBill.getString("shjh_city"); // 城市
|
||||||
|
String bankAcct = recBill.getString("payeracctbanknum"); // 银行账号
|
||||||
|
String countryName = recBill.getString("shjh_country"); // 国家名称
|
||||||
|
|
||||||
|
// 国家代码转换(公共逻辑提取到外部)
|
||||||
|
String countryCode = null;
|
||||||
|
if (countryName != null) {
|
||||||
|
// 根据国家名称查询国家编码
|
||||||
|
DynamicObject countryObject = BusinessDataServiceHelper.loadSingle(
|
||||||
|
"bd_country",
|
||||||
|
new QFilter("name", QCP.equals, countryName).toArray()
|
||||||
|
);
|
||||||
|
if (countryObject != null) {
|
||||||
|
countryCode = countryObject.getString("number"); // 获取国家编码
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否客户拆分
|
||||||
|
if (recBill.getBoolean(RecFieldsInfo.CUSTOMER_SPLIT)) {
|
||||||
|
// 处理拆分客户情况(分录级别)
|
||||||
|
DynamicObjectCollection entries = recBill.getDynamicObjectCollection("entry");
|
||||||
|
if (entries != null) {
|
||||||
|
for (DynamicObject entry : entries) {
|
||||||
|
JSONObject customerData = new JSONObject();
|
||||||
|
customerData.put("NAME", entry.getString("shjh_entrycustomer")); // 分录客户名称
|
||||||
|
customerData.put("CITY", city);
|
||||||
|
if (countryCode != null) {
|
||||||
|
customerData.put("COUNTRY", countryCode);
|
||||||
|
}
|
||||||
|
customerData.put("BANK_ACCT", bankAcct);
|
||||||
|
IS_CUSTOMERCPD.add(customerData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 处理非拆分情况(单据级别)
|
||||||
|
JSONObject customerData = new JSONObject();
|
||||||
|
customerData.put("NAME", recBill.getString("payername")); // 付款人名称
|
||||||
|
customerData.put("CITY", city);
|
||||||
|
if (countryCode != null) {
|
||||||
|
customerData.put("COUNTRY", countryCode);
|
||||||
|
}
|
||||||
|
customerData.put("BANK_ACCT", bankAcct);
|
||||||
|
IS_CUSTOMERCPD.add(customerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IS_CUSTOMERCPD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据付款方类型获取客户或供应商编号
|
||||||
|
* @param payerType 付款方类型 ("bd_customer" 或 "bd_supplier")
|
||||||
|
* @param recBill 收款单动态对象
|
||||||
|
* @return 客户/供应商编号,如果找不到则返回空字符串
|
||||||
|
*/
|
||||||
|
private String getCustomerOrSupplierNumber(String payerType, DynamicObject recBill) {
|
||||||
|
// 验证输入参数
|
||||||
|
if (payerType == null || recBill == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确定基础资料类型
|
||||||
|
String objectType = null;
|
||||||
|
switch (payerType) {
|
||||||
|
case "bd_customer":
|
||||||
|
case "bd_supplier":
|
||||||
|
objectType = payerType; // 直接使用传入的类型,避免重复赋值
|
||||||
|
break;
|
||||||
|
// 可在此添加其他类型的处理
|
||||||
|
default:
|
||||||
|
return ""; // 非支持类型直接返回空
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取付款方ID
|
||||||
|
String payerIdStr = recBill.getString("payer");
|
||||||
|
if (payerIdStr == null || payerIdStr.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 加载客户/供应商对象
|
||||||
|
DynamicObject payerObject = BusinessDataServiceHelper.loadSingle(
|
||||||
|
Long.valueOf(payerIdStr),
|
||||||
|
objectType
|
||||||
|
);
|
||||||
|
|
||||||
|
// 返回编号字段
|
||||||
|
return payerObject != null ? payerObject.getString("number") : "";
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 处理payerId转换异常
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
package shjh.jhzj7.fi.fi.plugin.task;
|
|
||||||
|
|
||||||
import kd.bos.context.RequestContext;
|
|
||||||
import kd.bos.dataentity.OperateOption;
|
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
|
||||||
import kd.bos.dataentity.utils.StringUtils;
|
|
||||||
import kd.bos.entity.operate.result.OperationResult;
|
|
||||||
import kd.bos.exception.KDException;
|
|
||||||
import kd.bos.orm.query.QCP;
|
|
||||||
import kd.bos.orm.query.QFilter;
|
|
||||||
import kd.bos.schedule.api.MessageHandler;
|
|
||||||
import kd.bos.schedule.executor.AbstractTask;
|
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
||||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
||||||
import kd.sdk.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 收款入账中心-按规则自动生成收款单
|
|
||||||
*
|
|
||||||
* @author LiGuiQiang
|
|
||||||
*/
|
|
||||||
public class ReceiptGenerationTask extends AbstractTask implements Plugin {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MessageHandler getMessageHandle() {
|
|
||||||
return super.getMessageHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
|
||||||
//查询【收款入账中心】
|
|
||||||
//【待确认】receredtype
|
|
||||||
//【收款金额不等于0】creditamount
|
|
||||||
//【收款认领通知为空】claimnoticebillno
|
|
||||||
QFilter qFilter = new QFilter("receredtype", QCP.equals, "0");
|
|
||||||
qFilter.and("creditamount", QCP.not_equals, BigDecimal.ZERO);
|
|
||||||
qFilter.and("claimnoticebillno", QCP.equals, "");
|
|
||||||
qFilter.and("billno", QCP.equals, "20250211-0000000094");
|
|
||||||
DynamicObject[] collection = BusinessDataServiceHelper.load("bei_intelrec", "id", qFilter.toArray());
|
|
||||||
if (collection.length != 0) {
|
|
||||||
Object[] idArray = new Object[collection.length];
|
|
||||||
for (int i = 0; i < collection.length; i++) {
|
|
||||||
DynamicObject dynamicObject = collection[i];
|
|
||||||
Object id = dynamicObject.get("id");
|
|
||||||
idArray[i] = id;
|
|
||||||
}
|
|
||||||
for (Object o : idArray) {
|
|
||||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(o, "bei_intelrec");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSupportReSchedule() {
|
|
||||||
return super.isSupportReSchedule();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -10,15 +10,17 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统信息工具栏
|
* 获取系统信息工具栏
|
||||||
|
*
|
||||||
* @author LiGuiQiang
|
* @author LiGuiQiang
|
||||||
*/
|
*/
|
||||||
public class SysUtils {
|
public class SysUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户工号
|
* 获取当前用户工号
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getUserNumber(){
|
public static String getUserNumber() {
|
||||||
Long userId = UserServiceHelper.getCurrentUserId();
|
Long userId = UserServiceHelper.getCurrentUserId();
|
||||||
ArrayList<Long> list = new ArrayList<>();
|
ArrayList<Long> list = new ArrayList<>();
|
||||||
list.add(userId);
|
list.add(userId);
|
||||||
|
|
@ -30,20 +32,40 @@ public class SysUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前操作人部门编码
|
* 获取当前操作人部门编码
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getUserDeptNumber(){
|
public static String getUserDeptNumber() {
|
||||||
String deptNumber=null;
|
String deptNumber = null;
|
||||||
long userId = UserServiceHelper.getCurrentUserId();
|
long userId = UserServiceHelper.getCurrentUserId();
|
||||||
long deptId = UserServiceHelper.getUserMainOrgId(userId);
|
long deptId = UserServiceHelper.getUserMainOrgId(userId);
|
||||||
if (deptId!=0L){
|
if (deptId != 0L) {
|
||||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(deptId, "bos_adminorg");
|
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(deptId, "bos_adminorg");
|
||||||
if (null!=dynamicObject){
|
if (null != dynamicObject) {
|
||||||
deptNumber=dynamicObject.getString("number");
|
deptNumber = dynamicObject.getString("number");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deptNumber;
|
return deptNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断一次性客户||供应商
|
||||||
|
* @param id 客户||供应商id
|
||||||
|
* @param type 类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Boolean isDisposableCusOrSup(Long id, String type) {
|
||||||
|
boolean result=false;
|
||||||
|
if ("bd_customer".equals(type) || "bd_supplier".equals(type)) {
|
||||||
|
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(id, type);
|
||||||
|
if (null != dynamicObject) {
|
||||||
|
String groupNumber = dynamicObject.getString("group.number");
|
||||||
|
if ("D300".equals(groupNumber) || "D301".equals(groupNumber)) {
|
||||||
|
result=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue