mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-05 10:30:12 +08:00
update 补充站点更换运营商逻辑
This commit is contained in:
@@ -107,18 +107,6 @@ public class SysUserController extends BaseController {
|
|||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||||
// if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
|
||||||
// return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
|
||||||
// } else if (StringUtils.isNotEmpty(user.getPhone())
|
|
||||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
|
||||||
// return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
|
||||||
// } else if (StringUtils.isNotEmpty(user.getEmail())
|
|
||||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
|
||||||
// return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
||||||
// }
|
|
||||||
// user.setCreateBy(getUsername());
|
|
||||||
// user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
||||||
|
|
||||||
AjaxResult result;
|
AjaxResult result;
|
||||||
try {
|
try {
|
||||||
int i = userService.createUser(user);
|
int i = userService.createUser(user);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
import com.jsowell.common.constant.Constants;
|
import com.jsowell.common.constant.Constants;
|
||||||
import com.jsowell.common.core.domain.entity.SysDept;
|
import com.jsowell.common.core.domain.entity.SysDept;
|
||||||
|
import com.jsowell.common.core.domain.entity.SysUser;
|
||||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||||
import com.jsowell.common.core.page.PageResponse;
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
@@ -25,6 +26,7 @@ import com.jsowell.pile.vo.base.StationInfoVO;
|
|||||||
import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails;
|
import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails;
|
||||||
import com.jsowell.pile.vo.web.PileStationVO;
|
import com.jsowell.pile.vo.web.PileStationVO;
|
||||||
import com.jsowell.system.service.SysDeptService;
|
import com.jsowell.system.service.SysDeptService;
|
||||||
|
import com.jsowell.system.service.SysUserService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -68,6 +70,9 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserService userService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,41 +254,78 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
|||||||
String redisKey = CacheConstants.SELECT_PILE_STATION_INFO_BY_ID + pileStationInfo.getId();
|
String redisKey = CacheConstants.SELECT_PILE_STATION_INFO_BY_ID + pileStationInfo.getId();
|
||||||
redisCache.deleteObject(redisKey);
|
redisCache.deleteObject(redisKey);
|
||||||
|
|
||||||
// 更新数据库
|
// 先查询一下当前数据库的充电站数据
|
||||||
|
PileStationInfo queryStationInfo = selectPileStationInfoById(pileStationInfo.getId());
|
||||||
|
String oldMerchantId = String.valueOf(queryStationInfo.getMerchantId());
|
||||||
|
String newMerchantId = String.valueOf(pileStationInfo.getMerchantId());
|
||||||
|
|
||||||
|
// 对比一下运营商有没有变化
|
||||||
|
if (!StringUtils.equals(oldMerchantId, newMerchantId)) {
|
||||||
|
// 新旧运营商不一致,执行站点更换运营商逻辑
|
||||||
|
stationUpdateMerchant(pileStationInfo, newMerchantId);
|
||||||
|
} else {
|
||||||
|
// 查询部门
|
||||||
|
SysDept sysDept = sysDeptService.selectDeptById(Long.parseLong(pileStationInfo.getDeptId()));
|
||||||
|
// 同步组织中的名称,联系人,电话
|
||||||
|
if (sysDept != null) {
|
||||||
|
sysDept.setDeptName(pileStationInfo.getStationName());
|
||||||
|
sysDept.setLeader(pileStationInfo.getStationAdminName());
|
||||||
|
sysDept.setPhone(pileStationInfo.getStationTel());
|
||||||
|
sysDept.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
sysDeptService.updateDept(sysDept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pileStationInfo.setUpdateBy(SecurityUtils.getUsername());
|
pileStationInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||||
pileStationInfo.setUpdateTime(DateUtils.getNowDate());
|
pileStationInfo.setUpdateTime(DateUtils.getNowDate());
|
||||||
int i = pileStationInfoMapper.updatePileStationInfo(pileStationInfo);
|
int i = pileStationInfoMapper.updatePileStationInfo(pileStationInfo);
|
||||||
|
|
||||||
// 同步组织中的名称,联系人,电话
|
|
||||||
SysDept sysDept = sysDeptService.selectDeptById(Long.parseLong(pileStationInfo.getDeptId()));
|
|
||||||
|
|
||||||
// 若修改运营商,则将此站点下所有桩对应的运营商也进行修改
|
|
||||||
if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getMerchantId()))) {
|
|
||||||
// 先查出桩基本信息
|
|
||||||
List<PileBasicInfo> pileInfoList = pileBasicInfoService.getPileListByStationId(String.valueOf(pileStationInfo.getId()));
|
|
||||||
if (CollectionUtils.isNotEmpty(pileInfoList)) {
|
|
||||||
List<Long> pileIdList = pileInfoList.stream().map(PileBasicInfo::getId).collect(Collectors.toList());
|
|
||||||
// 修改桩基本信息
|
|
||||||
pileBasicInfoService.updatePileMerchantBatch(pileIdList, String.valueOf(pileStationInfo.getMerchantId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改了运营商,同步修改组织
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sysDept != null) {
|
|
||||||
sysDept.setDeptName(pileStationInfo.getStationName());
|
|
||||||
sysDept.setLeader(pileStationInfo.getStationAdminName());
|
|
||||||
sysDept.setPhone(pileStationInfo.getStationTel());
|
|
||||||
sysDept.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
sysDeptService.updateDept(sysDept);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 再次清缓存
|
// 再次清缓存
|
||||||
redisCache.deleteObject(redisKey);
|
redisCache.deleteObject(redisKey);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电站更换运营商逻辑
|
||||||
|
*/
|
||||||
|
private void stationUpdateMerchant(PileStationInfo pileStationInfo, String newMerchantId) {
|
||||||
|
/*
|
||||||
|
修改充电桩所属运营商
|
||||||
|
*/
|
||||||
|
List<PileBasicInfo> pileInfoList = pileBasicInfoService.getPileListByStationId(String.valueOf(pileStationInfo.getId()));
|
||||||
|
if (CollectionUtils.isNotEmpty(pileInfoList)) {
|
||||||
|
List<Long> pileIdList = pileInfoList.stream().map(PileBasicInfo::getId).collect(Collectors.toList());
|
||||||
|
// 修改桩基本信息
|
||||||
|
pileBasicInfoService.updatePileMerchantBatch(pileIdList, newMerchantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
修改组织部门
|
||||||
|
*/
|
||||||
|
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(newMerchantId);
|
||||||
|
if (merchantInfo != null) {
|
||||||
|
// 创建一个新的站点对应部门
|
||||||
|
SysDept dept = sysDeptService.createStationDept(Long.valueOf(merchantInfo.getDeptId()),
|
||||||
|
pileStationInfo.getStationName(), pileStationInfo.getStationAdminName(), pileStationInfo.getStationTel());
|
||||||
|
pileStationInfo.setDeptId(String.valueOf(dept.getDeptId()));
|
||||||
|
|
||||||
|
// 修改账号归属部门
|
||||||
|
SysUser user = new SysUser();
|
||||||
|
user.setDeptId(Long.valueOf(pileStationInfo.getDeptId()));
|
||||||
|
List<SysUser> userList = userService.selectUserList(user);
|
||||||
|
if (CollectionUtils.isNotEmpty(userList)) {
|
||||||
|
for (SysUser sysUser : userList) {
|
||||||
|
sysUser.setDeptId(dept.getDeptId());
|
||||||
|
userService.updateUser(sysUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 逻辑删除老的部门
|
||||||
|
sysDeptService.deleteDeptById(Long.parseLong(pileStationInfo.getDeptId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除充电站信息
|
* 批量删除充电站信息
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user