|
@@ -10,6 +10,8 @@ import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StreamUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.bean.BeanValidators;
|
|
|
import com.ruoyi.system.domain.CpsContentInfo;
|
|
|
import com.ruoyi.system.domain.CpsMeetingEnterpriseTripInfo;
|
|
|
import com.ruoyi.system.domain.CpsMeetingUsr;
|
|
@@ -22,9 +24,12 @@ import com.ruoyi.system.service.ICpsMeetingUsrService;
|
|
|
import io.foldright.cffu.CompletableFutureUtils;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.validation.Validator;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -40,6 +45,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
|
|
*/
|
|
|
@Service
|
|
|
public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CpsMeetingUsrServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private CpsMeetingUsrMapper cpsMeetingUsrMapper;
|
|
|
|
|
@@ -58,6 +65,10 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
|
|
|
@Autowired
|
|
|
private AppCfg appCfg;
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ protected Validator validator;
|
|
|
+
|
|
|
/**
|
|
|
* 查询cps_usr_wechat微信用户
|
|
|
*
|
|
@@ -161,7 +172,7 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
|
|
|
user.setReviewState(ReviewStatus.WAIT.getCode());
|
|
|
user.setApplyType(type);
|
|
|
user.setReviewMsg("");
|
|
|
- WeChatUser loginUser = (WeChatUser)SecurityUtils.getLoginUser();
|
|
|
+ WeChatUser loginUser = (WeChatUser) SecurityUtils.getLoginUser();
|
|
|
user.setUpdateBy(loginUser.getOpenid());
|
|
|
CpsContentInfo cpsContentInfo = contentInfoMapper.selectCpsContentInfoById(user.getContentId());
|
|
|
user.setDeptId(cpsContentInfo.getDeptId());
|
|
@@ -227,6 +238,48 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public String importUser(List<CpsMeetingUsr> userList, Boolean isUpdateSupport, String operName) {
|
|
|
+ if (StringUtils.isNull(userList) || userList.size() == 0) {
|
|
|
+ throw new ServiceException("导入用户数据不能为空!");
|
|
|
+ }
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ for (CpsMeetingUsr user : userList) {
|
|
|
+ try {
|
|
|
+ // 验证是否存在这个用户
|
|
|
+ Integer cnt = cpsMeetingUsrMapper.exitUser(user.getTel());
|
|
|
+ if (cnt < 1) {
|
|
|
+ BeanValidators.validateWithException(validator, user);
|
|
|
+ user.setCreateBy(operName);
|
|
|
+ cpsMeetingUsrMapper.insertCpsMeetingUsr(user);
|
|
|
+ successNum++;
|
|
|
+ } else if (isUpdateSupport) {
|
|
|
+ BeanValidators.validateWithException(validator, user);
|
|
|
+ user.setUpdateBy(operName);
|
|
|
+ cpsMeetingUsrMapper.updateCpsMeetingUsrByTel(user);
|
|
|
+ successNum++;
|
|
|
+ } else {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、账号 " + user.getTel() + " 已存在");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ failureNum++;
|
|
|
+ log.info("导入用户失败:%s", e.getMessage());
|
|
|
+ failureMsg.append(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (failureNum > 0) {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ } else {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
|
|
+ }
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public CpsMeetingEnterpriseTripInfo qryUsrTripContent(String openId) {
|
|
|
CpsMeetingUsr cpsMeetingUsr = cpsMeetingUsrMapper.selectCpsMeetingUsrByOpenId(openId);
|
|
|
if (ObjectUtils.isEmpty(cpsMeetingUsr)) {
|