|
@@ -6,10 +6,10 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Sets;
|
|
import com.google.common.collect.Sets;
|
|
-import com.winsea.svc.base.base.entity.CommonCompany;
|
|
|
|
-import com.winsea.svc.base.base.entity.CommonDepartment;
|
|
|
|
-import com.winsea.svc.base.base.entity.CommonStaff;
|
|
|
|
-import com.winsea.svc.base.base.entity.CommonStaffRole;
|
|
|
|
|
|
+import com.winsea.svc.base.base.entity.*;
|
|
|
|
+import com.winsea.svc.base.base.exception.EnterpriseErrorCodeEnums;
|
|
|
|
+import com.winsea.svc.base.base.exception.EnterpriseException;
|
|
|
|
+import com.winsea.svc.base.base.mapper.CommonStaffMapper;
|
|
import com.winsea.svc.base.base.service.*;
|
|
import com.winsea.svc.base.base.service.*;
|
|
import com.winsea.svc.base.security.config.SecurityProperties;
|
|
import com.winsea.svc.base.security.config.SecurityProperties;
|
|
import com.winsea.svc.base.security.config.shiro.ShiroRealm;
|
|
import com.winsea.svc.base.security.config.shiro.ShiroRealm;
|
|
@@ -29,6 +29,7 @@ import com.yh.saas.common.support.entity.BaseModel;
|
|
import com.yh.saas.common.support.event.SupportEventBus;
|
|
import com.yh.saas.common.support.event.SupportEventBus;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.query.QueryUtils;
|
|
import com.yh.saas.common.support.util.query.QueryUtils;
|
|
|
|
+import com.yh.saas.common.support.util.uniqueness.UniquenessChecker;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.AppServiceException;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.AppServiceException;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.ExceptionDefinition;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.ExceptionDefinition;
|
|
@@ -56,6 +57,7 @@ import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.sql.*;
|
|
import java.sql.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -73,10 +75,13 @@ public class CommonUserServiceImpl extends ServiceImpl<CommonUserMapper, CommonU
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SMSClientYlyy smsClient;
|
|
private SMSClientYlyy smsClient;
|
|
-
|
|
|
|
|
|
+ private IRoleBizService roleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IStaffRoleBizService staffRoleService;
|
|
@Autowired
|
|
@Autowired
|
|
private CommonUserMapper commonUserMapper;
|
|
private CommonUserMapper commonUserMapper;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IStaffVesselBizService staffVesselService;
|
|
@Autowired
|
|
@Autowired
|
|
private StringRedisTemplate userRedisTemplate;
|
|
private StringRedisTemplate userRedisTemplate;
|
|
|
|
|
|
@@ -113,6 +118,8 @@ public class CommonUserServiceImpl extends ServiceImpl<CommonUserMapper, CommonU
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private INoticeTaskService noticeTaskService;
|
|
private INoticeTaskService noticeTaskService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommonStaffMapper staffMapper;
|
|
|
|
|
|
|
|
|
|
//用来过滤权限的时候使用,当过滤的code已在其中的时候就不进行过滤;
|
|
//用来过滤权限的时候使用,当过滤的code已在其中的时候就不进行过滤;
|
|
@@ -844,5 +851,94 @@ public class CommonUserServiceImpl extends ServiceImpl<CommonUserMapper, CommonU
|
|
return "OK";
|
|
return "OK";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void changeInfo(CommonStaff staff) {
|
|
|
|
+ UniquenessChecker.check(staffMapper, (new EntityWrapper()).eq("comp_id", staff.getCompId()), staff);
|
|
|
|
+ staff.setEnabled((Integer)null);
|
|
|
|
+ staff.updateById();
|
|
|
|
+ Account account;
|
|
|
|
+ if (null != staff.getStaffMobilePhone()) {
|
|
|
|
+ account = new Account();
|
|
|
|
+ account.setAccountId(staff.getStaffId());
|
|
|
|
+ account.setUserMobilePhone(staff.getStaffMobilePhone());
|
|
|
|
+ this.accountService.changeInfo(account);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != staff.getVesselId()) {
|
|
|
|
+ account = new Account();
|
|
|
|
+ account.setAccountId(staff.getStaffId());
|
|
|
|
+ account.setVesselId(staff.getVesselId());
|
|
|
|
+ this.accountService.changeInfo(account);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(staff.getLoginPassword())) {
|
|
|
|
+ account = new Account();
|
|
|
|
+ account.setAccountId(staff.getStaffId());
|
|
|
|
+ account.setLoginPassword(this.accountService.encryptPassword(staff.getLoginPassword()));
|
|
|
|
+ this.accountService.changeInfo(account);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Account> accounts = this.accountService.selectList((new EntityWrapper()).ne("account_id", staff.getStaffId()).eq("comp_id", staff.getCompId()).eq("login_name", staff.getStaffAccount()));
|
|
|
|
+ if (org.apache.commons.collections.CollectionUtils.isNotEmpty(accounts)) {
|
|
|
|
+ throw new EnterpriseException(EnterpriseErrorCodeEnums.STAFF_NAME_REPEAT);
|
|
|
|
+ } else {
|
|
|
|
+ Account account1 = new Account();
|
|
|
|
+ account1.setAccountId(staff.getStaffId());
|
|
|
|
+ account1.setLoginName(staff.getStaffAccount());
|
|
|
|
+ this.accountService.changeInfo(account1);
|
|
|
|
+// staff.getRoles().clear();
|
|
|
|
+ CommonRole majorRole = new CommonRole();
|
|
|
|
+ majorRole.setRoleId(staff.getMajorRoleId());
|
|
|
|
+ majorRole.setMajor("1");
|
|
|
|
+ staff.getRoles().add(majorRole);
|
|
|
|
+ if (org.apache.commons.collections.CollectionUtils.isNotEmpty(staff.getRoleVesselIds())) {
|
|
|
|
+ List<String> roleIds = (List)staff.getRoleVesselIds().stream().map((roleVesselId) -> {
|
|
|
|
+ return roleVesselId.split("_")[0];
|
|
|
|
+ }).distinct().collect(Collectors.toList());
|
|
|
|
+ staff.getRoles().addAll((Collection)roleIds.stream().map((roleId) -> {
|
|
|
|
+ CommonRole role = new CommonRole();
|
|
|
|
+ role.setRoleId(roleId);
|
|
|
|
+ role.setMajor("0");
|
|
|
|
+ return role;
|
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.bindRoles(staff.getStaffId(), staff.getRoles());
|
|
|
|
+ this.bindVessels(staff.getStaffId(), staff.getVessels(), staff.getMajorRoleId(), staff.getRoleVesselIds());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void bindRoles(String staffId, List<CommonRole> roles) {
|
|
|
|
+ if (null != roles) {
|
|
|
|
+ List<CommonStaffRole> staffRoles = (List)roles.stream().map((role) -> {
|
|
|
|
+ CommonStaffRole staffRole = new CommonStaffRole();
|
|
|
|
+ staffRole.setRoleId(role.getRoleId());
|
|
|
|
+ if (!org.apache.commons.lang3.StringUtils.isEmpty(role.getMajor())) {
|
|
|
|
+ staffRole.setRoleMajor(role.getMajor());
|
|
|
|
+ } else {
|
|
|
|
+ staffRole.setRoleMajor("1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return staffRole;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ this.staffRoleService.bind(staffId, staffRoles);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void bindVessels(String staffId, List<CommonVessel> vessels, String roleId, List<String> roleVessels) {
|
|
|
|
+ if (null != vessels) {
|
|
|
|
+ List<String> vesselIds = (List)vessels.stream().map((vessel) -> {
|
|
|
|
+ return vessel.getVesselId();
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ Set<String> vesselIdSet = new HashSet();
|
|
|
|
+ vesselIdSet.addAll(vesselIds);
|
|
|
|
+ this.staffVesselService.bind(staffId, Lists.newArrayList(vesselIdSet), roleId, roleVessels);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|