|
|
@@ -1,6 +1,8 @@
|
|
|
package com.uas.eis.task;
|
|
|
|
|
|
+import com.uas.eis.beans.result.BaseResult;
|
|
|
import com.uas.eis.beans.result.CrmQueryResult;
|
|
|
+import com.uas.eis.beans.result.Customer;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.dao.SqlRowList;
|
|
|
import com.uas.eis.manager.CustomerManager;
|
|
|
@@ -65,22 +67,22 @@ public class CustomerTask {
|
|
|
Object cu_sellercode = baseDao.getFieldDataByCondition("employee", "max(em_code) em_code", "em_name='" + dataList.get(i).get("relevant_team__r") + "'");
|
|
|
Long create_time = Long.parseLong(new BigDecimal(dataList.get(i).get("create_time").toString()).toPlainString());
|
|
|
Long last_modified_time = Long.parseLong(new BigDecimal(dataList.get(i).get("last_modified_time").toString()).toPlainString());
|
|
|
- String cuKind = getValueField(dataList, i, "account_type", "客户类型");
|
|
|
- String wbsk_user = getValueField(dataList, i, "UDSSel1__c", "收款方式");//外部收款方式
|
|
|
+ String cuKind = getDisplayField(dataList, i, "account_type", "客户类型");
|
|
|
+ String wbsk_user = getDisplayField(dataList, i, "UDSSel1__c", "收款方式");//外部收款方式
|
|
|
Object[] pa_data = baseDao.getFieldsDataByCondition("Payments", new String[]{"pa_id","pa_code"}, "pa_name='" + wbsk_user + "'");//获取收款方式编号
|
|
|
String paID = pa_data[0] == null ? "" : pa_data[0].toString();
|
|
|
String paCode = pa_data[1] == null ? "" : pa_data[1].toString();
|
|
|
- String cu_level = getValueField(dataList, i, "account_level", "客户级别");
|
|
|
- String cu_turnSAP = getValueField(dataList, i, "field_RYzRf__c", "是否转正式客户在SAP内建档");
|
|
|
- String cu_currency = getValueField(dataList, i, "field_e2HeP__c", "货币");
|
|
|
- String cu_recordType = getValueField(dataList, i, "record_type", "业务类型");
|
|
|
- String cu_industry = getValueField(dataList, i, "field_00Ijp__c", "所属行业");
|
|
|
+ String cu_level = getDisplayField(dataList, i, "account_level", "客户级别");
|
|
|
+ String cu_turnSAP = getDisplayField(dataList, i, "field_RYzRf__c", "是否转正式客户在SAP内建档");
|
|
|
+ String cu_currency = getDisplayField(dataList, i, "field_e2HeP__c", "货币");
|
|
|
+ String cu_recordType = getDisplayField(dataList, i, "record_type", "业务类型");
|
|
|
+ String cu_industry = getDisplayField(dataList, i, "field_00Ijp__c", "所属行业");
|
|
|
String cu_code = baseDao.sGetMaxNumber("PreCustomer", 2);
|
|
|
//field_giBJk__c:收货人 UDSText5__c:送货地址 UDSText1__c:法定代表人 UDSText2__c:注册资金
|
|
|
String sql="insert into PreCustomer(cu_id,cu_code,cu_name,cu_shortname,cu_add2,cu_sellercode,cu_sellername,cu_servicecode,cu_servicename,cu_kind," +
|
|
|
"cu_contact,cu_add1,cu_lawman,cu_regamount,cu_rate,cu_wbsk_user,cu_paymentid,cu_paymentscode,cu_payments,cu_level,cu_industry,cu_mainbusiness,cu_turnSAP,cu_currency,cu_taxrate," +
|
|
|
"cu_dealstatus,cu_Shipmentamount,cu_receivable,cu_businessRegister,cu_recordType," +
|
|
|
- "cu_mobile,cu_email,cu_recordman,cu_recorddate,cu_lastdate,cu_auditstatus,cu_auditstatuscode,CU_FXXKID)" +
|
|
|
+ "cu_mobile,cu_email,cu_recordman,cu_recorddate,cu_lastdate,cu_auditstatus,cu_auditstatuscode,cu_remark,CU_FXXKID)" +
|
|
|
"values(PRECUSTOMER_SEQ.nextval,'"+cu_code+"','"+name+"','"+dataList.get(i).get("UDSText3__c")+"','"+ dataList.get(i).get("address")+"'," +
|
|
|
"'"+(cu_sellercode==null?"":cu_sellercode)+"','"+getNotNull(dataList,i,"relevant_team__r")+"','"+em_code+"','"+dataList.get(i).get("field_w9e4q__c")+"','"+cuKind+"'," +
|
|
|
"'"+getNotNull(dataList,i,"field_giBJk__c")+"','"+getNotNull(dataList,i,"UDSText5__c")+"'," +
|
|
|
@@ -90,7 +92,7 @@ public class CustomerTask {
|
|
|
"'"+getNotNull(dataList,i,"field_Ezg0w__c")+"','"+getNotNull(dataList,i,"field_59oLF__c")+"','"+getNotNull(dataList,i,"biz_reg_name")+"','"+cu_recordType+"',"+
|
|
|
"'"+dataList.get(i).get("tel")+"','"+dataList.get(i).get("email")+"'," +
|
|
|
"'"+dataList.get(i).get("created_by")+"',"+DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(create_time)))+"," +
|
|
|
- DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(last_modified_time)))+",'已审核','AUDITED','"+_id+"')";
|
|
|
+ DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(last_modified_time)))+",'已审核','AUDITED','"+getNotNull(dataList,i,"remark")+"','"+_id+"')";
|
|
|
baseDao.execute(sql);
|
|
|
m++;
|
|
|
}catch (Exception e){
|
|
|
@@ -113,7 +115,35 @@ public class CustomerTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private String getValueField(List<Map<String, Object>> dataList, int i, String Field, String APINAME){
|
|
|
+ @Scheduled(cron = "0 0 23 * * ?")
|
|
|
+ public void syncUpdateCustomers() {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from (select distinct cui_code from customerUpdInfo where trunc(cui_date)=trunc(sysdate)) left join precustomer on cui_code=cu_code where nvl(cu_name,' ')<>' ' order by cu_id");
|
|
|
+ while (rs.next()){
|
|
|
+ try {
|
|
|
+ Customer customer = new Customer();
|
|
|
+ String valueField = getValueField("客户资料", "客户级别", rs.getGeneralString("cu_level"));
|
|
|
+ customer.setDataObjectApiName("AccountObj");
|
|
|
+ customer.set_id(rs.getGeneralString("cu_fxxkid"));
|
|
|
+ customer.setName(rs.getGeneralString("cu_name"));
|
|
|
+ customer.setAccount_level(valueField);
|
|
|
+ customer.setField_w9e4q__c(rs.getGeneralString("cu_servicename"));
|
|
|
+ BaseResult baseResult = customerManager.updateCustomer(customer);
|
|
|
+ int errorCode = baseResult.getErrorCode();
|
|
|
+ if(errorCode == 0){
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_updatestatus='已更新',cui_updatedate=sysdate where cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ }else{
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='"+baseResult.getErrorMessage()+"' where cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ logger.info("异常信息:"+baseResult.getErrorMessage());
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='"+e.getMessage()+"' where cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ logger.info("异常信息:"+e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDisplayField(List<Map<String, Object>> dataList, int i, String Field, String APINAME){
|
|
|
String ValueField ="";
|
|
|
Object account_type = dataList.get(i).get(Field);
|
|
|
if(account_type !=null && !"".equals(account_type.toString())){
|
|
|
@@ -123,6 +153,15 @@ public class CustomerTask {
|
|
|
return ValueField;
|
|
|
}
|
|
|
|
|
|
+ private String getValueField(String MODULEAPINAME, String APINAME, String DISPLAYFIELD){
|
|
|
+ String result ="";
|
|
|
+ if(DISPLAYFIELD !=null && !"".equals(DISPLAYFIELD)){
|
|
|
+ Object VALUEFIELD = baseDao.getFieldDataByCondition("comboData", "VALUEFIELD", "MODULEAPINAME='" + MODULEAPINAME + "' and APINAME='"+APINAME+"' and DISPLAYFIELD='"+DISPLAYFIELD+"'");
|
|
|
+ result = VALUEFIELD==null? "" :VALUEFIELD.toString();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private String getNotNull(List<Map<String, Object>> dataList, int i, String Field){
|
|
|
return (dataList.get(i).get(Field)==null?"":dataList.get(i).get(Field)).toString();
|
|
|
}
|