Parcourir la source

出入库角色分开

hefeng il y a 5 ans
Parent
commit
aa25b50d8c

+ 16 - 22
src/main/java/com/chinaitop/depot/system/controller/UserInfoController.java

@@ -597,9 +597,10 @@ public class UserInfoController {
597 597
 	@ApiOperation(value="保存用户", notes = "保存用户信息,新增或者修改")
598 598
 	@ApiImplicitParams({
599 599
 			@ApiImplicitParam(name = "userInfoJson", value = "用户信息JSON串", paramType = "form"),
600
-			@ApiImplicitParam(name = "userRoleIds", value = "用户角色编号,多个之间用逗号隔开", paramType = "form")
600
+			@ApiImplicitParam(name = "userRoleIds", value = "用户角色编号,多个之间用逗号隔开", paramType = "form"),
601
+			@ApiImplicitParam(name = "crkRoleIds", value = "出入库角色编号,多个之间用逗号隔开", paramType = "form")
601 602
 	})
602
-	public Map<String, Object> save(String userInfoJson , String userRoleIds) throws JsonParseException, JsonMappingException, IOException {
603
+	public Map<String, Object> save(String userInfoJson , String userRoleIds, String crkRoleIds) throws JsonParseException, JsonMappingException, IOException {
603 604
 		Map<String, Object> modelMap = new HashMap<>();
604 605
 		Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
605 606
 		// JSON字符串转对象
@@ -617,32 +618,25 @@ public class UserInfoController {
617 618
 			userRoleIds = userRoleIds.substring(1, userRoleIds.length());
618 619
 			userRoleIds = userRoleIds.substring(0, userRoleIds.length() - 1);
619 620
 	        String[] idArray = userRoleIds.split(",");
620
-	        String idArrayCrk = "[";
621 621
             userRole.setUserId(userInfo.getUserId());
622 622
             for (String id : idArray) {
623
-            	if(pattern.matcher(id).matches()) {//id为数字时是库级数据
624
-            		userRole.setRoleId(Integer.parseInt(id));
625
-            		userRoleService.add(userRole);
626
-            	} else {
627
-            		idArrayCrk = idArrayCrk+id+",";
628
-            	}
623
+            	userRole.setRoleId(Integer.parseInt(id));
624
+            	userRoleService.add(userRole);
629 625
             }
630
-            if("正常".equals(NetStateUtil.connectingAddress(wsdlUrl))) {
631
-            	try {
632
-            		if(idArrayCrk != "[") {
633
-            			idArrayCrk = idArrayCrk.substring(0,idArrayCrk.length() - 1)+"]";
634
-            		}else {
635
-            			idArrayCrk = "[]";
636
-            		}
637
-            		String json = "{userId:\""+userInfo.getUserId()+"\", roleIds:"+idArrayCrk+"}";
638
-            		ExchangeServer wb = new ExchangeServer();
639
-            		IExchangeService action = wb.getExchangeServiceImplPort();
640
-            		action.saveUserRoles(FLATID, KEY, json);
626
+		}
627
+		
628
+		if (StringUtils.isNotBlank(crkRoleIds)) {//保存出入库用户角色信息
629
+			if("正常".equals(NetStateUtil.connectingAddress(wsdlUrl))) {
630
+				try {
631
+					String json = "{userId:\""+userInfo.getUserId()+"\", roleIds:"+crkRoleIds+"}";
632
+					ExchangeServer wb = new ExchangeServer();
633
+					IExchangeService action = wb.getExchangeServiceImplPort();
634
+					action.saveUserRoles(FLATID, KEY, json);
641 635
 				} catch (Exception e) {
642 636
 					e.printStackTrace();
643 637
 				}
644
-            }
645
-	          
638
+			}
639
+			
646 640
 		}
647 641
 		
648 642
 		modelMap.put("status", "success");

+ 11 - 0
src/main/java/com/chinaitop/depot/system/model/UserInfo.java

@@ -53,6 +53,8 @@ public class UserInfo implements Serializable{
53 53
     
54 54
     private List<String> roleIds = new ArrayList<String>();
55 55
     
56
+    private List<String> crkRoleIds = new ArrayList<String>();
57
+    
56 58
     //业务字段
57 59
     private String roleNames;
58 60
     
@@ -403,4 +405,13 @@ public class UserInfo implements Serializable{
403 405
 	public void setRoleIds(List<String> roleIds) {
404 406
 		this.roleIds = roleIds;
405 407
 	}
408
+
409
+	public List<String> getCrkRoleIds() {
410
+		return crkRoleIds;
411
+	}
412
+
413
+	public void setCrkRoleIds(List<String> crkRoleIds) {
414
+		this.crkRoleIds = crkRoleIds;
415
+	}
416
+	
406 417
 }