liupeng 4 years ago
parent
commit
adad8be484

+ 16 - 14
code/sapparent/sapcms/src/main/java/org/fouram/controller/ApiController.java

@@ -28,7 +28,6 @@ import org.fouram.dto.output.SyncWeixinUserOutput;
 import org.fouram.entity.SapOrg;
 import org.fouram.entity.SapUser;
 import org.fouram.enums.DelFlagEnum;
-import org.fouram.enums.SapUserResultEnum;
 import org.fouram.input.FindUsersDTO;
 import org.fouram.service.SapCheckReportService;
 import org.fouram.service.SapOrgService;
@@ -42,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
 import io.swagger.annotations.Api;
@@ -65,7 +65,7 @@ public class ApiController extends BaseController {
 	private SapCheckReportService sapCheckReportService;
 	@Autowired
 	private SyncSapUserToWxService syncSapUserToWxService;
-	
+
 	private static final String TOKEN = "UserId";
 
 	/**
@@ -206,7 +206,7 @@ public class ApiController extends BaseController {
 			return ResultUtil.error(ResultConstant.TOKEN_ERR_MSG);
 		}
 		try {
-			if(WebConstants.CACHE.containsKey(WebConstants.CACHE_SYNC_SAP)) {
+			if (WebConstants.CACHE.containsKey(WebConstants.CACHE_SYNC_SAP)) {
 				return ResultUtil.error("数据正在同步,请稍等");
 			}
 			return ResultUtil.success(sapUserService.selectToBeConfirmedPrimaryList(dto), null);
@@ -224,14 +224,18 @@ public class ApiController extends BaseController {
 			return ResultUtil.error(ResultConstant.TOKEN_ERR_MSG);
 		}
 		try {
-			sapUserService.updateIngore(dto.getUserId());
+			List<String> userIds = dto.getUserIds();
+			if (StringUtils.isNotBlank(dto.getUserId())) {
+				userIds = Lists.newArrayList(dto.getUserId());
+			}
+			sapUserService.updateIngore(userIds);
 			return ResultUtil.success(null, "操作成功");
 		} catch (Exception e) {
 			LoggerUtil.error(e);
 			return ResultUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
+
 	@ApiOperation(value = "更新同步")
 	@PostMapping(value = "/updateSync", produces = "application/json;charset=utf-8")
 	@ResponseBody
@@ -240,20 +244,18 @@ public class ApiController extends BaseController {
 			return ResultUtil.error(ResultConstant.TOKEN_ERR_MSG);
 		}
 		try {
-			SapUser sapUser = sapUserService.selectByUserId(dto.getUserId());
-			if(SapUserResultEnum.LEAVE.getCode().equals(sapUser.getResult())) {
-//				String oprUserId = request.getSession().getAttribute(TOKEN).toString();
-				sapUserService.deleteQuitUserByUserId(dto.getUserId(), null);
-			}else {
-				sapUserService.updateSyncWxResult(dto.getUserId());
+			List<String> userIds = dto.getUserIds();
+			if (StringUtils.isNotBlank(dto.getUserId())) {
+				userIds = Lists.newArrayList(dto.getUserId());
 			}
+			sapUserService.updateSync(userIds);
 			return ResultUtil.success(null, "操作成功");
 		} catch (Exception e) {
 			LoggerUtil.error(e);
 			return ResultUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
+
 	@ApiOperation(value = "手动同步SAP用户数据")
 	@ApiResponses(@ApiResponse(response = SyncWeixinUserOutput.class, code = 200, message = "success"))
 	@PostMapping(value = "/syncWeixinUser", produces = "application/json;charset=utf-8")
@@ -267,7 +269,7 @@ public class ApiController extends BaseController {
 			return ResultUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
+
 	@ApiResponses(@ApiResponse(response = GetIngoreListOutput.class, code = 200, message = "success"))
 	@ApiOperation(value = "查询忽略列表")
 	@PostMapping(value = "/getIngoreList", produces = "application/json;charset=utf-8")
@@ -283,7 +285,7 @@ public class ApiController extends BaseController {
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
+
 	@ApiOperation(value = "取消忽略")
 	@PostMapping(value = "/cancelIngore", produces = "application/json;charset=utf-8")
 	@ResponseBody

+ 4 - 0
code/sapparent/sapservice/src/main/java/org/fouram/dto/input/UpdateResultDTO.java

@@ -1,6 +1,7 @@
 package org.fouram.dto.input;
 
 import java.io.Serializable;
+import java.util.List;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -19,4 +20,7 @@ public class UpdateResultDTO implements Serializable {
 	
 	@ApiModelProperty(value = "用户id")
 	private String userId;
+	
+	@ApiModelProperty(value = "用户ids")
+	private List<String> userIds;
 }

+ 18 - 2
code/sapparent/sapservice/src/main/java/org/fouram/service/SapUserService.java

@@ -242,6 +242,19 @@ public class SapUserService extends BaseService {
 		update("SapUserMapper.updateOne", entity);
 	}
 
+	@Transactional
+	public void updateSync(List<String> userIds) throws Exception {
+		SapUser sapUser = null;
+		for(String userId : userIds) {
+			sapUser = this.selectByUserId(userId);
+			if (SapUserResultEnum.LEAVE.getCode().equals(sapUser.getResult())) {
+				this.deleteQuitUserByUserId(userId, null);
+			} else {
+				this.updateSyncWxResult(userId);
+			}
+		}
+	}
+	
 	public void updateSyncWxResult(String personId) throws Exception {
 		String result = createOrUpdateWXUser(personId);
 		updateResultByUserId(result, personId);
@@ -426,8 +439,11 @@ public class SapUserService extends BaseService {
 		return GetToBeConfirmedListOutput.builder().data(toInfoDetails(data)).total(total).build();
 	}
 
-	public void updateIngore(String personId) throws Exception {
-		updateResultByUserId(SapUserResultEnum.INGORE.getCode(), personId);
+	@Transactional
+	public void updateIngore(List<String> personIds) throws Exception {
+		for(String personId : personIds) {
+			updateResultByUserId(SapUserResultEnum.INGORE.getCode(), personId);
+		}
 	}
 	
 	public void updateCancelIngore(String personId) throws Exception {