|
@@ -4,10 +4,13 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dgtly.common.exception.BusinessException;
|
|
|
import com.dgtly.common.utils.ShiroSaltUtil;
|
|
|
import com.dgtly.common.utils.security.EncryptPassWordClass;
|
|
|
+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.mapper.MetaDiySalesorgtreeMapper;
|
|
|
import com.dgtly.sync.mapper.MetaEmployeeDiyMapper;
|
|
@@ -89,7 +92,7 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
if(metaEmployeeDiys.size()>0){
|
|
|
|
|
|
//用户objid3为列表内的内容才为DIY人员
|
|
|
- Set<String> divObjid3Set = getConfigValueSet("libang_diyobjid3");
|
|
|
+ Set<String> diyObjid3Set = getConfigValueSet("libang_diyobjid3");
|
|
|
//用户岗位名称为列表的内容才是区公司级别人员
|
|
|
Set<String> companySet = getConfigValueSet("libang_company_level_postname");
|
|
|
//用户岗位名称为列表的内容才是销售大区级别人员
|
|
@@ -100,15 +103,16 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
Set<String> subofficeSet = getConfigValueSet("libang_suboffice_level_postname");
|
|
|
//用户岗位名称为列表的内容才是销售员级别人员
|
|
|
Set<String> empSet = getConfigValueSet("libang_emp_level_postname");
|
|
|
-
|
|
|
+ Map<Integer,Map<String,Map<String,String>>> salesTreeMap = getDiySalesOrgTree();
|
|
|
|
|
|
|
|
|
|
|
|
for(MetaEmployeeDiy m:metaEmployeeDiys) {
|
|
|
try {
|
|
|
- if(!divObjid3Set.contains(m.getStext3())){
|
|
|
- throw new OutOfScopeDIYException(m);
|
|
|
- }
|
|
|
+ //用户是否属于DIY筛选范围
|
|
|
+// if(!diyObjid3Set.contains(m.getStext3())){
|
|
|
+// throw new OutOfScopeDIYException(m);
|
|
|
+// }
|
|
|
/** =============用户基本信息构建 start===============*/
|
|
|
SysUser user = new SysUser();
|
|
|
user.setCompanyId(1L);
|
|
@@ -145,55 +149,61 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
if(empSet.contains(m.getEmployeePostName())){
|
|
|
userExt.setSalesLevel("emp_level");
|
|
|
userExt.setOrgName(m.getStext6());
|
|
|
+ setExtOrgCode(salesTreeMap,6,userExt);
|
|
|
fildName = "Org6name";
|
|
|
fildCode = "Org6code";
|
|
|
}else if(subofficeSet.contains(m.getEmployeePostName())){
|
|
|
userExt.setSalesLevel("suboffice_level");
|
|
|
userExt.setOrgName(m.getStext6());
|
|
|
+ setExtOrgCode(salesTreeMap,6,userExt);
|
|
|
fildName = "Org6name";
|
|
|
fildCode = "Org6code";
|
|
|
}else{
|
|
|
- throw new OutOfScopeDIYException(m);
|
|
|
+ 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);
|
|
|
fildName = "Org5name";
|
|
|
fildCode = "Org5code";
|
|
|
}else{
|
|
|
- throw new OutOfScopeDIYException(m);
|
|
|
+ throw new OutOfDIYPostNameException(m,5);
|
|
|
}
|
|
|
}else if(m.getStext4()!=null){
|
|
|
if(saledeptSet.contains(m.getEmployeePostName())){
|
|
|
userExt.setSalesLevel("saledept_level");
|
|
|
userExt.setOrgName(m.getStext4());
|
|
|
+ setExtOrgCode(salesTreeMap,4,userExt);
|
|
|
fildName = "Org4name";
|
|
|
fildCode = "Org4code";
|
|
|
} else{
|
|
|
- throw new OutOfScopeDIYException(m);
|
|
|
+ throw new OutOfDIYPostNameException(m,4);
|
|
|
}
|
|
|
}else if(m.getStext3()!=null){
|
|
|
if(companySet.contains(m.getEmployeePostName())){
|
|
|
userExt.setSalesLevel("company_level");
|
|
|
userExt.setOrgName(m.getStext3());
|
|
|
+ setExtOrgCode(salesTreeMap,3,userExt);
|
|
|
fildName = "Org3name";
|
|
|
fildCode = "Org3code";
|
|
|
} else{
|
|
|
- throw new OutOfScopeDIYException(m);
|
|
|
+ throw new OutOfDIYPostNameException(m,3);
|
|
|
}
|
|
|
}else{
|
|
|
- throw new OutOfScopeDIYException(m);
|
|
|
+ throw new OutOfLeveLException(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.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);
|
|
|
}
|
|
@@ -218,7 +228,7 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
sysUserService.insertUserAndSalesExt(user);
|
|
|
successCount++;
|
|
|
}
|
|
|
- }catch (OutOfScopeDIYException|NotFountOrgCodeException e){
|
|
|
+ }catch (OutOfScopeDIYException|NotFountOrgCodeException|OutOfDIYPostNameException|OutOfLeveLException e){
|
|
|
/**
|
|
|
* 警告类异常
|
|
|
*/
|
|
@@ -268,6 +278,11 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取字典的set
|
|
|
+ * @param dictType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Set<String> getConfigValueSet(String dictType){
|
|
|
Set<String> res = new HashSet<>();
|
|
|
List<SysDictData> dictDatas = sysDictDataService.selectSimpleDictDataByType(dictType);
|
|
@@ -278,6 +293,50 @@ public class AnalysisSysUserService implements IAnalysisSysUserService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取销售组织架构树
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<Integer,Map<String,Map<String,String>>> getDiySalesOrgTree(){
|
|
|
+ Map<String,Map<String,String>> map3= metaDiySalesorgtreeMapper.selectSalesTreeByLevel(3);
|
|
|
+ Map<String,Map<String,String>> map4= metaDiySalesorgtreeMapper.selectSalesTreeByLevel(4);
|
|
|
+ Map<String,Map<String,String>> map5= metaDiySalesorgtreeMapper.selectSalesTreeByLevel(5);
|
|
|
+ Map<String,Map<String,String>> map6= metaDiySalesorgtreeMapper.selectSalesTreeByLevel(6);
|
|
|
+ Map<Integer,Map<String,Map<String,String>>>res = new HashMap<>();
|
|
|
+ res.put(3,map3);
|
|
|
+ res.put(4,map4);
|
|
|
+ res.put(5,map5);
|
|
|
+ res.put(6,map6);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据销售的部门等级及销售组织名称获取销售的组织code
|
|
|
+ * @param salesTree
|
|
|
+ * @param level 销售登记
|
|
|
+ * @param userExt 用户扩展信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean setExtOrgCode(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<7;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;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|