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

修改自动考核

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