Commit f06cefc3 authored by 赵啸非's avatar 赵啸非

修改自动考核

parent 6b336834
package com.mortals.xhx.module.perform.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
......@@ -28,12 +29,12 @@ import java.util.Map;
import java.util.stream.Collectors;
/**
* PerformDeptConfService
* 部门自动考核信息 service实现
*
* @author zxfei
* @date 2023-05-16
*/
* PerformDeptConfService
* 部门自动考核信息 service实现
*
* @author zxfei
* @date 2023-05-16
*/
@Service("performDeptConfService")
@Slf4j
public class PerformDeptConfServiceImpl extends AbstractCRUDServiceImpl<PerformDeptConfDao, PerformDeptConfEntity, Long> implements PerformDeptConfService {
......@@ -51,10 +52,10 @@ public class PerformDeptConfServiceImpl extends AbstractCRUDServiceImpl<PerformD
protected void findAfter(PerformDeptConfEntity params, PageInfo pageInfo, Context context, List<PerformDeptConfEntity> list) throws AppException {
Map<Long, UserEntity> userMap = userService.findToMap(new UserQuery(), context);
if(CollectionUtils.isNotEmpty(list)){
for (PerformDeptConfEntity item:list){
if (CollectionUtils.isNotEmpty(list)) {
for (PerformDeptConfEntity item : list) {
UserEntity userEntity = userMap.get(item.getCreateUserId());
if(!ObjectUtils.isEmpty(userEntity)){
if (!ObjectUtils.isEmpty(userEntity)) {
item.setCreateUserName(userEntity.getRealName());
}
List<PerformDeptConfDetailEntity> detailEntityList = performDeptConfDetailService.find(new PerformDeptConfDetailQuery().deptConfId(item.getId()));
......@@ -70,61 +71,66 @@ public class PerformDeptConfServiceImpl extends AbstractCRUDServiceImpl<PerformD
if (deptEntity != null) {
entity.setDeptName(deptEntity.getDeptName());
}
updateCount(entity);
}
@Override
protected void updateAfter(PerformDeptConfEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getDeptConfDetail())){
if (CollectionUtils.isNotEmpty(entity.getDeptConfDetail())) {
Long[] detailIds = performDeptConfDetailService.find(new PerformDeptConfDetailQuery().deptConfId(entity.getId())).stream().map(PerformDeptConfDetailEntity::getId).toArray(Long[]::new);
performDeptConfDetailService.remove(detailIds,context);
for(PerformDeptConfDetailEntity item:entity.getDeptConfDetail()){
performDeptConfDetailService.remove(detailIds, context);
for (PerformDeptConfDetailEntity item : entity.getDeptConfDetail()) {
item.setDeptConfId(entity.getId());
item.setCreateTime(entity.getCreateTime());
item.setCreateUser(entity.getCreateUser());
item.setDeptId(entity.getDeptId());
item.setDeptName(entity.getDeptName());
PerformRulesCategoryEntity categoryEntity = performRulesCategoryService.get(item.getCategoryId());
if(categoryEntity!=null){
if (categoryEntity != null) {
item.setCategoryName(categoryEntity.getName());
}
item.setId(null);
}
performDeptConfDetailService.save(entity.getDeptConfDetail(),context);
performDeptConfDetailService.save(entity.getDeptConfDetail(), context);
}
}
@Override
protected void saveBefore(PerformDeptConfEntity entity, Context context) throws AppException {
super.saveBefore(entity,context);
super.saveBefore(entity, context);
DeptEntity deptEntity = deptService.get(entity.getDeptId());
if(deptEntity!=null){
if (deptEntity != null) {
entity.setDeptName(deptEntity.getDeptName());
}
if(CollectionUtils.isNotEmpty(entity.getDeptConfDetail())){
Map<Integer,List<PerformDeptConfDetailEntity>> groupMap = entity.getDeptConfDetail().stream().collect(Collectors.groupingBy(PerformDeptConfDetailEntity::getType));
if(groupMap.containsKey(CheckTypeEnum.考勤绩效.getValue())) {
updateCount(entity);
}
private void updateCount(PerformDeptConfEntity entity) {
if (CollectionUtils.isNotEmpty(entity.getDeptConfDetail())) {
Map<Integer, List<PerformDeptConfDetailEntity>> groupMap = entity.getDeptConfDetail().stream().collect(Collectors.groupingBy(PerformDeptConfDetailEntity::getType));
if (groupMap.containsKey(CheckTypeEnum.考勤绩效.getValue())) {
entity.setAttendCount(groupMap.get(CheckTypeEnum.考勤绩效.getValue()).size());
}else {
} else {
entity.setAttendCount(0);
}
if(groupMap.containsKey(CheckTypeEnum.评价绩效.getValue())) {
if (groupMap.containsKey(CheckTypeEnum.评价绩效.getValue())) {
entity.setAssessCount(groupMap.get(CheckTypeEnum.评价绩效.getValue()).size());
}else {
} else {
entity.setAssessCount(0);
}
if(groupMap.containsKey(CheckTypeEnum.办件绩效.getValue())) {
if (groupMap.containsKey(CheckTypeEnum.办件绩效.getValue())) {
entity.setWorkCount(groupMap.get(CheckTypeEnum.办件绩效.getValue()).size());
}else {
} else {
entity.setWorkCount(0);
}
if(groupMap.containsKey(CheckTypeEnum.效能绩效.getValue())) {
if (groupMap.containsKey(CheckTypeEnum.效能绩效.getValue())) {
entity.setEffectCount(groupMap.get(CheckTypeEnum.效能绩效.getValue()).size());
}else {
} else {
entity.setEffectCount(0);
}
if(groupMap.containsKey(CheckTypeEnum.其它绩效.getValue())) {
if (groupMap.containsKey(CheckTypeEnum.其它绩效.getValue())) {
entity.setOtherCount(groupMap.get(CheckTypeEnum.其它绩效.getValue()).size());
}else {
} else {
entity.setOtherCount(0);
}
}
......@@ -132,27 +138,27 @@ public class PerformDeptConfServiceImpl extends AbstractCRUDServiceImpl<PerformD
@Override
protected void saveAfter(PerformDeptConfEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getDeptConfDetail())){
for(PerformDeptConfDetailEntity item:entity.getDeptConfDetail()){
if (CollectionUtils.isNotEmpty(entity.getDeptConfDetail())) {
for (PerformDeptConfDetailEntity item : entity.getDeptConfDetail()) {
item.setDeptConfId(entity.getId());
item.setCreateTime(entity.getCreateTime());
item.setCreateUser(entity.getCreateUser());
item.setDeptId(entity.getDeptId());
item.setDeptName(entity.getDeptName());
PerformRulesCategoryEntity categoryEntity = performRulesCategoryService.get(item.getCategoryId());
if(categoryEntity!=null){
if (categoryEntity != null) {
item.setCategoryName(categoryEntity.getName());
}
item.setId(null);
}
performDeptConfDetailService.save(entity.getDeptConfDetail(),context);
performDeptConfDetailService.save(entity.getDeptConfDetail(), context);
}
}
@Override
public PerformDeptConfEntity get(Long key, Context context) throws AppException {
PerformDeptConfEntity entity = this.dao.get(key);
if(entity!=null) {
if (entity != null) {
List<PerformDeptConfDetailEntity> detailEntityList = performDeptConfDetailService.find(new PerformDeptConfDetailQuery().deptConfId(entity.getId()));
entity.setDeptConfDetail(detailEntityList);
}
......@@ -161,11 +167,11 @@ public class PerformDeptConfServiceImpl extends AbstractCRUDServiceImpl<PerformD
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
if(ids != null && ids.length != 0){
for (Long id:ids){
if (ids != null && ids.length != 0) {
for (Long id : ids) {
PerformDeptConfDetailEntity condition = new PerformDeptConfDetailEntity();
condition.setDeptConfId(id);
performDeptConfDetailService.remove(condition,context);
performDeptConfDetailService.remove(condition, context);
}
}
}
......
......@@ -70,6 +70,10 @@ public class PerformStaffConfServiceImpl extends AbstractCRUDServiceImpl<Perform
}
updateCount(entity);
}
private void updateCount(PerformStaffConfEntity entity) {
if (CollectionUtils.isNotEmpty(entity.getStaffConfDetail())) {
Map<Integer, List<PerformStaffConfDetailEntity>> groupMap = entity.getStaffConfDetail().stream().collect(Collectors.groupingBy(PerformStaffConfDetailEntity::getType));
if (groupMap.containsKey(CheckTypeEnum.考勤绩效.getValue())) {
......@@ -126,16 +130,13 @@ public class PerformStaffConfServiceImpl extends AbstractCRUDServiceImpl<Perform
staffQuery.setIdList(staffIdList);
List<StaffEntity> staffEntityList = staffService.find(staffQuery);
if (CollectionUtils.isNotEmpty(staffEntityList)) {
String names = "";
for (StaffEntity item : staffEntityList) {
names += item.getName() + ",";
}
entity.setStaffNames(names.substring(0, names.length() - 1));
entity.setStaffNames(staffEntityList.stream().map(i->i.getName()).collect(Collectors.joining(",")));
entity.setStaffCount(staffEntityList.size());
} else {
entity.setStaffCount(0);
}
}
updateCount(entity);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment