|
|
@ -297,6 +297,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
* @Date 2020.04.26 09:48 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result removeGridStaff(CommonGridStaffInfoFormDTO staffInfoFormDTO) { |
|
|
|
|
|
|
|
Result<CustomerGridEntity> authResult = authenticateManager(staffInfoFormDTO.getGridId(),staffInfoFormDTO.getUserId()); |
|
|
@ -308,7 +309,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
staff.setGridId(staffInfoFormDTO.getGridId()); |
|
|
|
staff.setUpdatedBy(staffInfoFormDTO.getUserId()); |
|
|
|
staff.setDelFlag(NumConstant.ONE); |
|
|
|
customerStaffGridService.update(staff); |
|
|
|
customerStaffGridDao.updateByStaffIdAndGridId(staff); |
|
|
|
//3.2 人数减一
|
|
|
|
CustomerGridDTO grid = new CustomerGridDTO(); |
|
|
|
grid.setId(authResult.getData().getId()); |
|
|
@ -316,6 +317,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
grid.setTotalUser(authResult.getData().getTotalUser() == null || authResult.getData().getTotalUser() <= 0 |
|
|
|
? 0 : (authResult.getData().getTotalUser() - 1)); |
|
|
|
update(grid); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result().error(); |
|
|
@ -329,6 +332,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
* @Date 2020.04.26 09:50 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result addGridStaffs(CommonGridStaffListFromDTO staffListFormDTO) { |
|
|
|
//1.校验管理员权限
|
|
|
|
Result<CustomerGridEntity> authResult = authenticateManager(staffListFormDTO.getGridId(),staffListFormDTO.getUserId()); |
|
|
@ -338,13 +342,17 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
customerStaffGridDao.distinctGridStaffs(staffListFormDTO.getSelectedList(),staffListFormDTO.getGridId()); |
|
|
|
Set<String> staffIds = new HashSet<>(staffListFormDTO.getSelectedList()); |
|
|
|
staffIds.removeAll(existedStaffIds); |
|
|
|
if(staffIds.size() <= NumConstant.ZERO){ |
|
|
|
log.error(ModuleConstant.NO_APPROPRIATE_STAFF_TO_ADD); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
//3.校验人员是否被禁用
|
|
|
|
Result<List<CommonStaffInfoResultDTO>> staffsFeignResult = |
|
|
|
epmetUserFeignClient.enableStaffMsgList(new CommonUserIdListFormDTO( |
|
|
|
new ArrayList<>(staffIds), |
|
|
|
authResult.getData().getCustomerId() |
|
|
|
)); |
|
|
|
if(staffsFeignResult.success() && null != staffsFeignResult.getData() && staffsFeignResult.getData().size() > 0){ |
|
|
|
if(staffsFeignResult.success() && null != staffsFeignResult.getData() && staffsFeignResult.getData().size() > NumConstant.ZERO){ |
|
|
|
//4.添加
|
|
|
|
List<String> validStaffIds = |
|
|
|
staffsFeignResult.getData() |
|
|
@ -352,7 +360,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
.map(CommonStaffInfoResultDTO::getStaffId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<CustomerStaffGridDTO> staffs2Insert = new LinkedList<>(); |
|
|
|
for(String id : validStaffIds){ |
|
|
|
validStaffIds.forEach(id -> { |
|
|
|
CustomerStaffGridDTO staff2Insert = new CustomerStaffGridDTO(); |
|
|
|
staff2Insert.setUserId(id); |
|
|
|
staff2Insert.setGridId(staffListFormDTO.getGridId()); |
|
|
@ -360,9 +368,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
staff2Insert.setCreatedBy(staffListFormDTO.getUserId()); |
|
|
|
staff2Insert.setUpdatedBy(staffListFormDTO.getUserId()); |
|
|
|
staffs2Insert.add(staff2Insert); |
|
|
|
} |
|
|
|
}); |
|
|
|
//4.1 批量新增网格工作人员
|
|
|
|
customerStaffGridDao.insertBatch(staffs2Insert); |
|
|
|
//4.2 更新网格人数
|
|
|
|
CustomerGridDTO grid2Update = new CustomerGridDTO(); |
|
|
|
grid2Update.setId(staffListFormDTO.getGridId()); |
|
|
|
grid2Update.setUpdatedBy(staffListFormDTO.getUserId()); |
|
|
@ -370,7 +379,6 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
null == authResult.getData().getTotalUser() ? |
|
|
|
validStaffIds.size() : authResult.getData().getTotalUser() + validStaffIds.size() |
|
|
|
); |
|
|
|
//4.2 更新网格人数
|
|
|
|
update(grid2Update); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|