员工银行账号信息同步至客户中,仅新增
This commit is contained in:
parent
24870a2075
commit
97cc2960f4
|
|
@ -0,0 +1,75 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.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.orm.query.QCP;
|
||||
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 shjh.jhzj7.fi.fi.utils.EsbUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 定时任务 员工银行账号信息同步至客户中,仅新增
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class PersonCustomerBankTask extends AbstractTask implements Plugin {
|
||||
|
||||
private static final String entityName = "bos_user";//系统库 表名 t_sec_user
|
||||
private static final String cusEntityName = "bd_customer";//系统库 表名 T_BD_Customer
|
||||
private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
|
||||
QFilter qFilter = new QFilter("shjh_acctnum", QCP.not_equals, "");//收款账号 不为空
|
||||
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id,number,name,shjh_acctnum,shjh_skyh,shjh_xxyh", qFilter.toArray());
|
||||
|
||||
for (DynamicObject userinfo : collection) {
|
||||
handlePersonForCustomer(userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePersonForCustomer(DynamicObject ups){
|
||||
String cusnumber = (String) ups.get("number");//客户编号-即是 人员的编号
|
||||
DynamicObject currentCus = BusinessDataServiceHelper.loadSingle(cusEntityName,new QFilter[]{new QFilter("number","=",cusnumber)});
|
||||
if(currentCus != null){
|
||||
String acctnum = (String) ups.get("shjh_acctnum");//收款账号
|
||||
if(EsbUtils.isEmpty(acctnum)){
|
||||
return;
|
||||
}
|
||||
DynamicObjectCollection doc_bank = currentCus.getDynamicObjectCollection("entry_bank");
|
||||
if(!doc_bank.isEmpty()){
|
||||
//只处理新增
|
||||
return;
|
||||
}
|
||||
String cusname = (String) ups.get("name");//姓名
|
||||
String skyh = (String) ups.get("shjh_skyh");//收款银行
|
||||
String xxyh = (String) ups.get("shjh_xxyh");//详细分机银行
|
||||
DynamicObject bankinfo;
|
||||
if(doc_bank.isEmpty()){
|
||||
bankinfo = doc_bank.addNew();
|
||||
}else{
|
||||
bankinfo = doc_bank.get(0);
|
||||
}
|
||||
bankinfo.set("bankaccount",acctnum);//银行账号
|
||||
bankinfo.set("accountname",cusname);//账户名称
|
||||
//根据详细分机银行 查找对应的行名行号
|
||||
DynamicObject bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,name",new QFilter[]{new QFilter("name","=",xxyh)});
|
||||
if(bebankinfo != null){
|
||||
bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找
|
||||
}
|
||||
bankinfo.set("currency", JhzjUtils.CNY);//币别 默认人民币
|
||||
bankinfo.set("isdefault_bank",true);
|
||||
SaveServiceHelper.save(new DynamicObject[]{currentCus});
|
||||
}
|
||||
//客户还未生成,需要在客户生成时,从人员处获取银行账号
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue