|
@@ -67,6 +67,7 @@ public class AnalysisDiyCustomerComponent {
|
|
|
private Long[] roleCwIds;
|
|
|
private Long[] roleCwDiyIds;
|
|
|
private Long[] roleFXDiyIds;
|
|
|
+ private Long[] roleStoreIds;
|
|
|
|
|
|
* 获取并解析DIY经销商用户
|
|
|
* 因为经销商用户并不涉及用信息更新等方面 所以只插入不更新
|
|
@@ -99,6 +100,10 @@ public class AnalysisDiyCustomerComponent {
|
|
|
Long roleId = Long.parseLong(configService.selectConfigByKey("libang.fx.roleid"));
|
|
|
roleFXDiyIds = new Long[]{roleId};
|
|
|
}
|
|
|
+ if (roleStoreIds == null) {
|
|
|
+ Long roleId = Long.parseLong(configService.selectConfigByKey("libang.storeCustomer.roleid"));
|
|
|
+ roleStoreIds = new Long[]{roleId};
|
|
|
+ }
|
|
|
|
|
|
|
|
|
List<SyncFailDetail> failDetails = new ArrayList<>();
|
|
@@ -275,6 +280,51 @@ public class AnalysisDiyCustomerComponent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ try {
|
|
|
+ JSONObject bossListJson = JSONObject.parseObject(HttpUtils.sendSSLGet(customerAccessTokenUtil.getUrl(UrlType.STAFF, 1+"")));
|
|
|
+ int codeStaff = bossListJson.getInteger("code");
|
|
|
+ if (codeStaff == 0) {
|
|
|
+ success += buildSysUserStaff(bossListJson, loginNameSet, diyNameSet, failDetails, packageId, chainsMap);
|
|
|
+ total += bossListJson.getJSONArray("data").size();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("3.6经销商经销人员列表!");
|
|
|
+ customerAccessTokenUtil.reSetToken();
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject json = JSONObject.parseObject(financeJson);
|
|
|
+ Integer Staffcount = json.getInteger("count");
|
|
|
+ if(Staffcount>100){
|
|
|
+ int co = 0;
|
|
|
+ if (Staffcount%100 != 0){
|
|
|
+ co = (Staffcount/100) +2;
|
|
|
+ }else{
|
|
|
+ co = (Staffcount/100) +1;
|
|
|
+ }
|
|
|
+ for (int i = 1; i < co; i++) {
|
|
|
+ try {
|
|
|
+ json = JSONObject.parseObject(HttpUtils.sendSSLGet(customerAccessTokenUtil.getUrl(UrlType.STAFF,i+"")));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("循环获取3.6接口错误!第"+i+"页");
|
|
|
+ customerAccessTokenUtil.reSetToken();
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ code = json.getInteger("code");
|
|
|
+ if(code==0){
|
|
|
+ success += buildSysUserStaff(json, loginNameSet, diyNameSet, failDetails, packageId, chainsMap);
|
|
|
+ total += json.getJSONArray("data").size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ code = json.getInteger("code");
|
|
|
+ if(code==0){
|
|
|
+ success += buildSysUserStaff(json, loginNameSet, diyNameSet, failDetails, packageId, chainsMap);
|
|
|
+ total += json.getJSONArray("data").size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
JSONObject bossListJson = JSONObject.parseObject(HttpUtils.sendSSLGet(customerAccessTokenUtil.getUrl(UrlType.BOSSLIST, null)));
|
|
|
code = bossListJson.getInteger("code");
|
|
@@ -555,8 +605,11 @@ public class AnalysisDiyCustomerComponent {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+ if(isManager == 0){
|
|
|
+ sysUserService.insertUserRole(user.getUserId(), roleGuideIds[0]);
|
|
|
+ }else{
|
|
|
sysUserService.insertUserRole(user.getUserId(), roleIds[0]);
|
|
|
+ }
|
|
|
|
|
|
if (!user.getSysUserExt().getIsCustomerManager().contains(isManager + "") ||
|
|
|
!user.getSysUserExt().getCustomerCode().equals(customerCode) || !user.getSysUserExt().getOrgCode().equals(customerCode)) {
|
|
@@ -848,6 +901,155 @@ public class AnalysisDiyCustomerComponent {
|
|
|
|
|
|
return count;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+ * 3.6经销商经销人员门店
|
|
|
+ * **/
|
|
|
+ public Integer buildSysUserStaff(JSONObject json, Set<String> loginNameSet,Set<String> diyNameSet, List<SyncFailDetail> failDetails,String packageId, Map<String,Customers> cusMap){
|
|
|
+ JSONArray jsonArray = json.getJSONArray("data");
|
|
|
+ int count = 0;
|
|
|
+ int isManager=8;
|
|
|
+ for(int i =0;i<jsonArray.size();i++){
|
|
|
+ JSONObject jo = jsonArray.getJSONObject(i);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String userNo = jo.getString("userNo");
|
|
|
+ String name = jo.getString("name");
|
|
|
+ String userid = jo.getString("userid");
|
|
|
+ String customerCode = jo.getString("depCode");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ *
|
|
|
+ if(status==null || !status.trim().equals("1")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ *
|
|
|
+ if(!isSync){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ *
|
|
|
+ if(isDelete){
|
|
|
+ continue;
|
|
|
+ }*/
|
|
|
+ if(userid==null||userid.trim().equals("")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!loginNameSet.contains(userid)) {
|
|
|
+
|
|
|
+
|
|
|
+ SysUser user = new SysUser();
|
|
|
+ user.setCompanyId(1L);
|
|
|
+ user.setDeptId(deptId);
|
|
|
+ user.setLoginName(userid);
|
|
|
+ user.setUserName(jo.getString("name"));
|
|
|
+ user.setPhonenumber(jo.getString("mobile"));
|
|
|
+ user.setRoleIds(roleStoreIds);
|
|
|
+ user.setPassword(user.getLoginName());
|
|
|
+ user.setSalt(ShiroSaltUtil.randomSalt());
|
|
|
+ user.setPassword(EncryptPassWordClass.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ SysUserExt userExt = new SysUserExt();
|
|
|
+ userExt.setSalesLevel("customer_level");
|
|
|
+
|
|
|
+ userExt.setIdentity(UserIdentityUtil.UI_DIY);
|
|
|
+
|
|
|
+ userExt.setCustomerCode(jo.getString("depCode"));
|
|
|
+ userExt.setIsCustomerManager(isManager + "");
|
|
|
+ userExt.setSapEmployeeId(userNo);
|
|
|
+
|
|
|
+ userExt.setPostName("DIY经销商");
|
|
|
+ String orgCode = jo.getString("depCode");
|
|
|
+ if(cusMap.containsKey(orgCode)){
|
|
|
+ Customers c = cusMap.get(orgCode);
|
|
|
+ userExt.setOrgCode(c.getChainsCode());
|
|
|
+ userExt.setOrgName(c.getChainsName());
|
|
|
+ }else{
|
|
|
+ userExt.setOrgCode(orgCode);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ user.setSysUserExt(userExt);
|
|
|
+ insertUserAndExt(user);
|
|
|
+ count++;
|
|
|
+ loginNameSet.add(userid);
|
|
|
+ diyNameSet.add(userid);
|
|
|
+ }else{
|
|
|
+
|
|
|
+ (首先查询当前用户职位,判断当前职位是否包含当前职位,不存在就更新,存在就不更新)*/
|
|
|
+ SysUser user = sysUserService.selectUserByLoginName(userid);
|
|
|
+ sysUserService.insertUserRole(user.getUserId(), roleStoreIds[0]);
|
|
|
+
|
|
|
+ if (!user.getSysUserExt().getIsCustomerManager().contains(isManager + "") ||
|
|
|
+ !user.getSysUserExt().getCustomerCode().equals(customerCode) || !user.getSysUserExt().getOrgCode().equals(customerCode)) {
|
|
|
+ if (!user.getSysUserExt().getIsCustomerManager().contains(isManager + "")) {
|
|
|
+
|
|
|
+ user.getSysUserExt().setIsCustomerManager(user.getSysUserExt().getIsCustomerManager() + "," + isManager);
|
|
|
+ }
|
|
|
+ if (!user.getSysUserExt().getCustomerCode().equals(customerCode) || !user.getSysUserExt().getOrgCode().equals(customerCode)) {
|
|
|
+
|
|
|
+ if (cusMap.containsKey(customerCode)) {
|
|
|
+ Customers c = cusMap.get(customerCode);
|
|
|
+ user.getSysUserExt().setOrgCode(c.getChainsCode());
|
|
|
+ user.getSysUserExt().setOrgName(c.getChainsName());
|
|
|
+ } else {
|
|
|
+ user.getSysUserExt().setOrgCode(customerCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("updateSysUserExt" + customerCode);
|
|
|
+ sysUserExtMapper.updateSysUserExt(user.getSysUserExt());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!user.getUserName().equals(name)){
|
|
|
+ user.setUserName(name);
|
|
|
+ if("2".equals(user.getQuit())){
|
|
|
+ user.setQuit(null);
|
|
|
+ }
|
|
|
+ sysUserService.updateUserInfo(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (diyNameSet.contains(userid) && !"1,2".equals(user.getSysUserExt().getIdentity())) {
|
|
|
+
|
|
|
+ log.info("updateSysUserExt identity 1,2" + userid);
|
|
|
+ user.getSysUserExt().setIdentity(UserIdentityUtil.UI_DIY+","+UserIdentityUtil.UI_CW);
|
|
|
+
|
|
|
+ sysUserExtMapper.updateSysUserExt(user.getSysUserExt());
|
|
|
+ }
|
|
|
+ if (!diyNameSet.contains(userid) && !"2".equals(user.getSysUserExt().getIdentity())) {
|
|
|
+ log.info("updateSysUserExt identity 2" + userid);
|
|
|
+ user.getSysUserExt().setIdentity(UserIdentityUtil.UI_CW);
|
|
|
+ sysUserExtMapper.updateSysUserExt(user.getSysUserExt());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ SyncFailDetail syncFailDetail = new SyncFailDetail();
|
|
|
+ syncFailDetail.setPackageId(packageId);
|
|
|
+ syncFailDetail.setFailReason(e.getMessage());
|
|
|
+ syncFailDetail.setDataJson(jo.toJSONString());
|
|
|
+ syncFailDetail.setFailLevel("1");
|
|
|
+ syncFailDetail.setExceptionType(e.getClass().getSimpleName());
|
|
|
+ failDetails.add(syncFailDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return count;
|
|
|
+ }
|
|
|
|
|
|
* 构建 插入分销 3.4 分销业务员人员 List
|
|
|
* @param json
|