|
|
@@ -5,6 +5,7 @@ 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.CommonManager;
|
|
|
import com.uas.eis.manager.CustomerManager;
|
|
|
import com.uas.eis.utils.Constant;
|
|
|
import com.uas.eis.utils.DateUtil;
|
|
|
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Component;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -33,6 +35,8 @@ public class CustomerTask {
|
|
|
private BaseDao baseDao;
|
|
|
@Autowired
|
|
|
private CustomerManager customerManager;
|
|
|
+ @Autowired
|
|
|
+ private CommonManager commonManager;
|
|
|
|
|
|
@Scheduled(cron = "0 0/15 * * * ?")
|
|
|
public void syncCustomers() {
|
|
|
@@ -122,7 +126,7 @@ public class CustomerTask {
|
|
|
|
|
|
@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");
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from (select distinct cui_code from customerUpdInfo where CUI_UPDATEDATE is null and nvl(cui_type,' ')='普通变更' and trunc(cui_date)=trunc(sysdate)) left join customer on cui_code=cu_code where nvl(cu_name,' ')<>' ' order by cu_id");
|
|
|
while (rs.next()){
|
|
|
try {
|
|
|
Customer customer = new Customer();
|
|
|
@@ -135,13 +139,85 @@ public class CustomerTask {
|
|
|
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)");
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_updatestatus='已更新',cui_updatedate=sysdate where nvl(cui_type,' ')='普通变更' and 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)");
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='"+baseResult.getErrorMessage()+"' where nvl(cui_type,' ')='普通变更' and 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)");
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='"+e.getMessage()+"' where nvl(cui_type,' ')='普通变更' and cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ logger.info("异常信息:"+e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步人员资料crm唯一id
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
+ public void syncEmployeeFXXKID() {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select em_id,em_name,em_code from employee where nvl(EM_FXXKID,' ')=' ' and nvl(EM_ISSYNCFXXKID,0)=-1 order by em_id");
|
|
|
+ while (rs.next()){
|
|
|
+ try {
|
|
|
+ List<String> field_values = new ArrayList<>();
|
|
|
+ field_values.add(rs.getGeneralString("em_name"));
|
|
|
+ CrmQueryResult crmQueryResult = commonManager.queryCommon("name", field_values, "EQ", "name", true, 50, "PersonnelObj", true);
|
|
|
+ int errorCode = crmQueryResult.getErrorCode();
|
|
|
+ if(errorCode == 0) {
|
|
|
+ Map<String, Object> data = crmQueryResult.getData();
|
|
|
+ List<Map<String, Object>> dataList = (List<Map<String, Object>>) data.get("dataList");
|
|
|
+ Object user_id = dataList.get(0).get("user_id");
|
|
|
+ if(user_id!=null){
|
|
|
+ baseDao.execute("update employee set em_fxxkid='"+user_id+"' where em_id="+rs.getGeneralInt("em_id"));
|
|
|
+ baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'人员资料纷享销客主键下载成功','人员资料纷享销客主键下载','"+rs.getGeneralString("em_code")+"')");
|
|
|
+ }else{
|
|
|
+ baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','人员资料纷享销客主键下载','"+rs.getGeneralString("em_code")+"')");
|
|
|
+ logger.info("异常信息:crm不存在该人员资料");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','人员资料纷享销客主键下载','"+rs.getGeneralString("em_code")+"')");
|
|
|
+ logger.info("异常信息:"+crmQueryResult.getErrorMessage());
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+e.getMessage()+"','人员资料纷享销客主键下载','"+rs.getGeneralString("em_code")+"')");
|
|
|
+ logger.info("异常信息:"+e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 变更负责人
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 23 * * ?")
|
|
|
+ public void syncChangeSellerCustomers() {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from (select distinct cui_code from customerUpdInfo where CUI_UPDATEDATE is null and nvl(cui_type,' ')='变更负责人' and trunc(cui_date)=trunc(sysdate)) left join customer on cui_code=cu_code left join employee on cu_sellercode=em_code where nvl(cu_name,' ')<>' ' order by cu_id");
|
|
|
+ String dataObjectApiName="AccountObj";
|
|
|
+ while (rs.next()){
|
|
|
+ try {
|
|
|
+ if(rs.getGeneralString("em_fxxkid")!=null && !"".equals(rs.getGeneralString("em_fxxkid")) && rs.getGeneralString("cu_fxxkid")!=null && !"".equals(rs.getGeneralString("cu_fxxkid"))){
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ List<String> emfxxidList = new ArrayList<>();
|
|
|
+ emfxxidList.add(rs.getGeneralString("em_fxxkid"));
|
|
|
+ map.put("ownerId",emfxxidList);
|
|
|
+ map.put("objectDataId",rs.getGeneralString("cu_fxxkid"));
|
|
|
+ list.add(map);
|
|
|
+ BaseResult baseResult = commonManager.changeOwnerCommon(list, dataObjectApiName);
|
|
|
+ int errorCode = baseResult.getErrorCode();
|
|
|
+ if(errorCode == 0){
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_updatestatus='已更新',cui_updatedate=sysdate where nvl(cui_type,' ')='变更负责人' and cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ }else{
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='"+baseResult.getErrorMessage()+"' where nvl(cui_type,' ')='变更负责人' and cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ logger.info("异常信息:"+baseResult.getErrorMessage());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='客户对应业务员对应人员表中纷享销客ID为空或客户资料纷享销客ID为空' where nvl(cui_type,' ')='变更负责人' and cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
+ logger.info("异常信息:客户对应业务员对应人员表中纷享销客ID为空或客户资料纷享销客ID为空");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ baseDao.execute("update customerUpdInfo set cui_error='"+e.getMessage()+"' where nvl(cui_type,' ')='变更负责人' and cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
|
|
|
logger.info("异常信息:"+e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
}
|