|
@@ -8,10 +8,7 @@ import com.dgtly.sync.domain.MetaDiySalesorgtree;
|
|
|
import com.dgtly.sync.domain.MetaEmployeeDiy;
|
|
|
import com.dgtly.sync.domain.SyncFailDetail;
|
|
|
import com.dgtly.sync.domain.SyncLog;
|
|
|
-import com.dgtly.sync.exception.NotFountOrgCodeException;
|
|
|
-import com.dgtly.sync.exception.OutOfDIYPostNameException;
|
|
|
-import com.dgtly.sync.exception.OutOfLeveLException;
|
|
|
-import com.dgtly.sync.exception.OutOfScopeDIYException;
|
|
|
+import com.dgtly.sync.exception.*;
|
|
|
import com.dgtly.sync.mapper.MetaDiySalesorgtreeMapper;
|
|
|
import com.dgtly.sync.mapper.MetaEmployeeDiyMapper;
|
|
|
import com.dgtly.sync.mapper.SyncFailDetailMapper;
|
|
@@ -142,6 +139,7 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
userExt.setPostCode(m.getEmployeePost());
|
|
|
String postName = m.getEmployeePostName();
|
|
|
userExt.setPostName(postName);
|
|
|
+
|
|
|
//判断用户所处销售层级
|
|
|
//先啊判断用户所属的岗位名称确定销售部门
|
|
|
if(companySet.contains(postName)){
|
|
@@ -149,61 +147,47 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
userExt.setSalesLevel("company_level");
|
|
|
userExt.setOrgName(m.getStext3());
|
|
|
setExtOrgCodeOn3(salesTreeMap,userExt);
|
|
|
- }else {
|
|
|
- if(m.getStext6()!=null){
|
|
|
- if(empSet.contains(m.getEmployeePostName())){
|
|
|
- userExt.setSalesLevel("emp_level");
|
|
|
- userExt.setOrgName(m.getStext6());
|
|
|
- setExtOrgCode(salesTreeMap,6,userExt);
|
|
|
-
|
|
|
- }else if(subofficeSet.contains(m.getEmployeePostName())){
|
|
|
- userExt.setSalesLevel("suboffice_level");
|
|
|
- userExt.setOrgName(m.getStext6());
|
|
|
- setExtOrgCode(salesTreeMap,6,userExt);
|
|
|
-
|
|
|
- }else{
|
|
|
- throw new OutOfDIYPostNameException(m,6);
|
|
|
- }
|
|
|
- }else if(m.getStext5()!=null){
|
|
|
-
|
|
|
- if(officeSet.contains(m.getEmployeePostName())){
|
|
|
- userExt.setSalesLevel("office_level");
|
|
|
- userExt.setOrgName(m.getStext5());
|
|
|
- setExtOrgCode(salesTreeMap,5,userExt);
|
|
|
|
|
|
- }else{
|
|
|
- throw new OutOfDIYPostNameException(m,5);
|
|
|
+ }else {
|
|
|
+ //判断用户u岗位是否在销售员敢为、销售分部岗位、销售部岗位、销售大区岗位中
|
|
|
+ if(empSet.contains(postName)||subofficeSet.contains(postName)||officeSet.contains(postName)||saledeptSet.contains(postName)){
|
|
|
+ //获取最后所属的部门名称
|
|
|
+ String orgName = getStext(m);
|
|
|
+ userExt.setOrgName(orgName);
|
|
|
+ int i = getLevel(userExt,salesTreeMap);
|
|
|
+ if (i==-1){
|
|
|
+ throw new NotFountOrgCodeException(m);
|
|
|
}
|
|
|
- }else if(m.getStext4()!=null){
|
|
|
- if(saledeptSet.contains(m.getEmployeePostName())){
|
|
|
- userExt.setSalesLevel("saledept_level");
|
|
|
- userExt.setOrgName(m.getStext4());
|
|
|
- setExtOrgCode(salesTreeMap,4,userExt);
|
|
|
-
|
|
|
- } else{
|
|
|
- throw new OutOfDIYPostNameException(m,4);
|
|
|
+ switch (i){
|
|
|
+ case 6:
|
|
|
+ if(empSet.contains(m.getEmployeePostName())){
|
|
|
+ //等级6 销售员
|
|
|
+ userExt.setSalesLevel("emp_level");
|
|
|
+ }else if(subofficeSet.contains(m.getEmployeePostName())){
|
|
|
+ //等级6 销售分部
|
|
|
+ userExt.setSalesLevel("suboffice_level");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ userExt.setSalesLevel("office_level");
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ userExt.setSalesLevel("saledept_level");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ userExt.setSalesLevel("company_level");
|
|
|
+ break;
|
|
|
}
|
|
|
}else{
|
|
|
- throw new OutOfLeveLException(m);
|
|
|
+ throw new OutOfDIYPostNameException(m);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// if(userExt.getOrgName()!=null){
|
|
|
-// Map<String,String> map= metaDiySalesorgtreeMapper.selectSalesorgByName(fildName,fildCode,userExt.getOrgName());
|
|
|
-// if(map!=null && map.containsKey("orgcode")){
|
|
|
-// userExt.setOrgCode(map.get("orgcode"));
|
|
|
-// }
|
|
|
+// if(userExt.getOrgCode()==null){
|
|
|
+// throw new NotFountOrgCodeException(m);
|
|
|
// }
|
|
|
- if(userExt.getOrgCode()==null){
|
|
|
- throw new NotFountOrgCodeException(m);
|
|
|
- }
|
|
|
- /**======== 构建diy用户扩展信息表 end===============*/
|
|
|
-
|
|
|
-
|
|
|
|
|
|
+ /**======== 构建diy用户扩展信息表 end===============*/
|
|
|
if (loginNameList.contains(user.getLoginName())) {
|
|
|
/** 更新 */
|
|
|
SysUser userInDb =sysUserService.selectUserByLoginName(user.getLoginName());
|
|
@@ -221,7 +205,7 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
sysUserService.insertUserAndSalesExt(user);
|
|
|
successCount++;
|
|
|
}
|
|
|
- }catch (OutOfScopeDIYException|NotFountOrgCodeException|OutOfDIYPostNameException|OutOfLeveLException e){
|
|
|
+ }catch (OutOfScopeDIYException|NotFountOrgCodeException|OutOfDIYPostNameException|OutOfLeveLException|NotOrgNameException e){
|
|
|
/**
|
|
|
* 警告类异常
|
|
|
*/
|
|
@@ -286,6 +270,8 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取销售组织架构树
|
|
|
* @return
|
|
@@ -304,7 +290,30 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据销售的部门等级及销售组织名称获取销售的组织code
|
|
|
+ * 获取用户最后的stext
|
|
|
+ * @param m
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getStext(MetaEmployeeDiy m){
|
|
|
+ if(m.getStext6()!=null&&!m.getStext6().trim().equals("")){
|
|
|
+ return m.getStext6();
|
|
|
+ }else if(m.getStext5()!=null&&!m.getStext5().trim().equals("")){
|
|
|
+ return m.getStext5();
|
|
|
+ }else if(m.getStext4()!=null&&!m.getStext4().trim().equals("")){
|
|
|
+ return m.getStext4();
|
|
|
+ }else if(m.getStext3()!=null&&!m.getStext3().trim().equals("")){
|
|
|
+ return m.getStext3();
|
|
|
+ }else if(m.getStext2()!=null&&!m.getStext2().trim().equals("")){
|
|
|
+ return m.getStext2();
|
|
|
+ }else if(m.getStext1()!=null&&!m.getStext1().trim().equals("")){
|
|
|
+ return m.getStext1();
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new NotOrgNameException(m);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据销售的部门等级及销售组织名称获取销售的组织code 向下兼容
|
|
|
* @param salesTree
|
|
|
* @param level 销售登记
|
|
|
* @param userExt 用户扩展信息
|
|
@@ -327,9 +336,34 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据销售的部门等级及销售组织名称获取销售的组织code 向上兼容
|
|
|
+ * @param salesTree
|
|
|
+ * @param level 销售登记
|
|
|
+ * @param userExt 用户扩展信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean setExtOrgCodeUp(Map<Integer,Map<String,Map<String,String>>> salesTree,int level,SysUserExt userExt){
|
|
|
+ if(userExt.getOrgName()==null||userExt.getOrgName().trim().equals("")){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String orgname = userExt.getOrgName();
|
|
|
+ for(;level>3;level--){
|
|
|
+ if(salesTree.containsKey(level)){
|
|
|
+ Map<String,Map<String,String>> temp = salesTree.get(level);
|
|
|
+ if(temp.containsKey(orgname)){
|
|
|
+ userExt.setOrgCode(temp.get(orgname).get("orgcode"));
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
/**
|
|
|
* 根据用户所处部门是否包含第三等级区公司名称 来获取code特殊情况针对 第三级特殊情况
|
|
|
* @param salesTree
|
|
@@ -354,6 +388,21 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public int getLevel(SysUserExt userExt,Map<Integer,Map<String,Map<String,String>>> salesTree){
|
|
|
+ String orgName = userExt.getOrgName();
|
|
|
+ for(int i =6;i>2;i--){
|
|
|
+ if(salesTree.containsKey(i)){
|
|
|
+ Map<String,Map<String,String>> temp = salesTree.get(i);
|
|
|
+ if(temp.containsKey(orgName)){
|
|
|
+ userExt.setOrgCode(temp.get(orgName).get("orgcode"));
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|