diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index 3a11fa3df..ccc597273 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -212,20 +212,10 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService { return 0; } - // 1. 新增sys_dept - SysDept dept = new SysDept(); - // 根据运营商Id查询到对应的部门id - dept.setParentId(Long.parseLong(merchantInfo.getDeptId())); - dept.setOrderNum(0); - - dept.setDeptName(StringUtils.trim(dto.getStationName())); - dept.setLeader(StringUtils.trim(dto.getStationAdminName())); - dept.setPhone(StringUtils.trim(dto.getStationTel())); - dept.setStatus("0"); - sysDeptService.insertDept(dept); + // 创建站点对应部门 + SysDept dept = sysDeptService.createStationDept(Long.valueOf(merchantInfo.getDeptId()), dto.getStationName(), dto.getStationAdminName(), dto.getStationTel()); PileStationInfo pileStationInfo = new PileStationInfo(); - // pileStationInfo.setId(dept.getDeptId()); pileStationInfo.setDeptId(String.valueOf(dept.getDeptId())); // 前端输入信息 pileStationInfo.setMerchantId(Long.valueOf(dto.getMerchantId())); @@ -259,9 +249,14 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService { String redisKey = CacheConstants.SELECT_PILE_STATION_INFO_BY_ID + pileStationInfo.getId(); redisCache.deleteObject(redisKey); + // 更新数据库 pileStationInfo.setUpdateBy(SecurityUtils.getUsername()); pileStationInfo.setUpdateTime(DateUtils.getNowDate()); int i = pileStationInfoMapper.updatePileStationInfo(pileStationInfo); + + // 同步组织中的名称,联系人,电话 + SysDept sysDept = sysDeptService.selectDeptById(Long.parseLong(pileStationInfo.getDeptId())); + // 若修改运营商,则将此站点下所有桩对应的运营商也进行修改 if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getMerchantId()))) { // 先查出桩基本信息 @@ -271,9 +266,11 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService { // 修改桩基本信息 pileBasicInfoService.updatePileMerchantBatch(pileIdList, String.valueOf(pileStationInfo.getMerchantId())); } + + // 修改了运营商,同步修改组织 + } - // 同步组织中的名称,联系人,电话 - SysDept sysDept = sysDeptService.selectDeptById(Long.parseLong(pileStationInfo.getDeptId())); + if (sysDept != null) { sysDept.setDeptName(pileStationInfo.getStationName()); sysDept.setLeader(pileStationInfo.getStationAdminName()); diff --git a/jsowell-system/src/main/java/com/jsowell/system/service/SysDeptService.java b/jsowell-system/src/main/java/com/jsowell/system/service/SysDeptService.java index fab3db6c8..35e1663ec 100644 --- a/jsowell-system/src/main/java/com/jsowell/system/service/SysDeptService.java +++ b/jsowell-system/src/main/java/com/jsowell/system/service/SysDeptService.java @@ -113,4 +113,12 @@ public interface SysDeptService { * @return 结果 */ public int deleteDeptById(Long deptId); + + /** + * 创建站点对应的组织部门 + * @param parentDeptId 运营商对应的deptId + * @param stationAdminName 站点负责人姓名,用作组织部门负责人姓名 + * @param stationTel 站点联系电话, 用作联系电话 + */ + SysDept createStationDept(Long parentDeptId, String stationName, String stationAdminName, String stationTel); } diff --git a/jsowell-system/src/main/java/com/jsowell/system/service/impl/SysDeptServiceImpl.java b/jsowell-system/src/main/java/com/jsowell/system/service/impl/SysDeptServiceImpl.java index 176529a67..7ace00420 100644 --- a/jsowell-system/src/main/java/com/jsowell/system/service/impl/SysDeptServiceImpl.java +++ b/jsowell-system/src/main/java/com/jsowell/system/service/impl/SysDeptServiceImpl.java @@ -1,6 +1,7 @@ package com.jsowell.system.service.impl; import com.jsowell.common.annotation.DataScope; +import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.UserConstants; import com.jsowell.common.core.domain.TreeSelect; import com.jsowell.common.core.domain.entity.SysDept; @@ -292,4 +293,25 @@ public class SysDeptServiceImpl implements SysDeptService { private boolean hasChild(List list, SysDept t) { return getChildList(list, t).size() > 0; } + + /** + * 创建站点对应的组织部门 + * @param parentDeptId 运营商对应的deptId + * @param stationAdminName 站点负责人姓名,用作组织部门负责人姓名 + * @param stationTel 站点联系电话, 用作联系电话 + */ + @Override + public SysDept createStationDept(Long parentDeptId, String stationName, String stationAdminName, String stationTel) { + // 新增sys_dept + SysDept dept = new SysDept(); + // 根据运营商Id查询到对应的部门id + dept.setParentId(parentDeptId); + dept.setOrderNum(Constants.zero); + dept.setDeptName(StringUtils.trim(stationName)); + dept.setLeader(StringUtils.trim(stationAdminName)); + dept.setPhone(StringUtils.trim(stationTel)); + dept.setStatus(Constants.ZERO); + insertDept(dept); + return dept; + } }