|
|
@@ -6,6 +6,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
@@ -515,18 +516,49 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void checkCustomer(Set<CustomerExcelBo> boSet, Set<Integer> existRows) {
|
|
|
+ public void checkCustomer(Set<CustomerExcelBo> boSet, Set<Integer> existRows, Set<Integer> filterRows) {
|
|
|
List<User> list = null;
|
|
|
- User user = null;
|
|
|
for (CustomerExcelBo bo : boSet) {
|
|
|
- list = userMapper.checkUser("", bo.getIdentifyName(), "", Integer.parseInt(bo.getCustomerType()));
|
|
|
- if (list.size() > 0) {
|
|
|
- user = list.get(0);
|
|
|
- bo.setUid(user.getId());
|
|
|
+ CustomerExcelBo ceb = null;
|
|
|
+ for(Iterator<CustomerExcelBo> it = boSet.iterator();it.hasNext();){ //先自检
|
|
|
+ ceb = it.next();
|
|
|
+ if(bo.getCustomerType().equals(AFTConstants.USER_TYPE_PERSONAL)){ //个人
|
|
|
+ if(ceb.getMobile().equals(bo.getMobile()) && ceb.getCustomerType().equals(bo.getCustomerType())){
|
|
|
+ bo.setUid(ceb.getUid());
|
|
|
+ bo.setNewData(false);
|
|
|
+ filterRows.add(bo.getRowNumber());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else if(bo.getCustomerType().equals(AFTConstants.USER_TYPE_ORGANIZATION)){ //单位
|
|
|
+ if(ceb.getIdentifyName().equals(bo.getIdentifyName()) && ceb.getCustomerType().equals(bo.getCustomerType())){
|
|
|
+ bo.setUid(ceb.getUid());
|
|
|
+ bo.setNewData(false);
|
|
|
+ filterRows.add(bo.getRowNumber());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(bo.getUid())){ //是否已经存在
|
|
|
+ if(bo.getCustomerType().equals(AFTConstants.USER_TYPE_PERSONAL)){
|
|
|
+ list = userMapper.checkUser("", "", bo.getMobile(), Integer.parseInt(bo.getCustomerType()));
|
|
|
+ }else if(bo.getCustomerType().equals(AFTConstants.USER_TYPE_ORGANIZATION)){
|
|
|
+ list = userMapper.checkUser("", bo.getIdentifyName(), "", Integer.parseInt(bo.getCustomerType()));
|
|
|
+ }
|
|
|
+ if (list.size() > 0) {
|
|
|
+ bo.setUid(list.get(0).getId());
|
|
|
+ bo.setNewData(false);
|
|
|
+ if (userBusinessMapper.judgeBusiness(bo.getUid(), Integer.parseInt(bo.getBusinessGlossoryId()),"") > 0) {
|
|
|
+ existRows.add(bo.getRowNumber());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ bo.setUid(UUID.randomUUID().toString());
|
|
|
+ bo.setNewData(true);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
if (userBusinessMapper.judgeBusiness(bo.getUid(), Integer.parseInt(bo.getBusinessGlossoryId()),"") > 0) {
|
|
|
existRows.add(bo.getRowNumber());
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -536,14 +568,13 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements
|
|
|
Date now = new Date();
|
|
|
String uid = "";
|
|
|
for(CustomerExcelBo bo : boSet){
|
|
|
- if(StringUtils.isBlank(bo.getUid())){ //新建客户
|
|
|
- uid = UUID.randomUUID().toString();
|
|
|
+ uid = bo.getUid();
|
|
|
+ if(bo.isNewData()){ //新建客户
|
|
|
createUser(bo, uid, now);
|
|
|
createIdentity(bo, bo.getCustomerType(), uid);
|
|
|
createBusiness(bo, uid, now);
|
|
|
createContacts(bo, uid);
|
|
|
}else{ //新建业务
|
|
|
- uid = bo.getUid();
|
|
|
createBusiness(bo, uid, now);
|
|
|
if(organizationContactBookMapper.checkContacts(uid, bo.getMobile(), TokenManager.getAdminId())<=0){
|
|
|
createContacts(bo, uid);
|