绩效填报调整

liweidong
maxiangong 3 days ago
parent e998e02bd5
commit 07958fd2ab
  1. 3
      blade-service-api/blade-desk-api/src/main/java/org/springblade/desk/energy/feign/IBsEnergyCoreUseClient.java
  2. 4
      blade-service-api/blade-user-api/src/main/java/org/springblade/system/feign/IUserClient.java
  3. 103
      blade-service/blade-desk/src/main/java/org/springblade/desk/efficiency/controller/BsEfficiencyTaskController.java
  4. 4
      blade-service/blade-desk/src/main/java/org/springblade/desk/efficiency/service/IBsEfficiencyTaskParamService.java
  5. 21
      blade-service/blade-desk/src/main/java/org/springblade/desk/efficiency/service/impl/BsEfficiencyTaskParamServiceImpl.java
  6. 6
      blade-service/blade-desk/src/main/java/org/springblade/desk/energy/service/impl/BsEnergyCoreUseServiceImpl.java
  7. 15
      blade-service/blade-system/src/main/java/org/springblade/system/feign/UserClient.java
  8. 2
      blade-service/blade-system/src/main/java/org/springblade/system/service/IUserService.java
  9. 6
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/UserServiceImpl.java

@ -3,6 +3,7 @@ package org.springblade.desk.energy.feign;
import org.springblade.core.launch.constant.AppConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(
value = AppConstant.APPLICATION_DESK_NAME
@ -14,7 +15,7 @@ public interface IBsEnergyCoreUseClient {
String SAVE_HISTORY_REC = API_PREFIX + "/save-history-rec";
@GetMapping(UPDATE_USED)
void updateUsed(String type);
void updateUsed(@RequestParam String type);
@GetMapping(SAVE_HISTORY_REC)
void saveHistoryRec();

@ -69,6 +69,7 @@ public interface IUserClient {
String SELECTUSER_LIST = API_PREFIX + "/unuser-listByName";
String SELECTUSER_LIST_NO_LIKE = API_PREFIX + "/unuser-listByNameNolike";
String USER_BY_ROLE = API_PREFIX + "/user_by_role";
String USER_BY_CODES = API_PREFIX + "/user_by_codes";
@GetMapping(USER_LIST)
@ -228,4 +229,7 @@ public interface IUserClient {
*/
@GetMapping(USER_BY_ROLE)
List<User> userByRole(@RequestParam("account") String account);
@PostMapping(USER_BY_CODES)
List<User> userByCodes(@RequestBody List<String> codes);
}

@ -6,6 +6,7 @@ import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -34,7 +35,7 @@ import org.springblade.desk.efficiency.service.IBsEfficiencyTaskService;
import org.springblade.desk.efficiency.service.IBsEfficiencyTempParamService;
import org.springblade.desk.efficiency.util.EasyExcelUtil;
import org.springblade.system.feign.IUserClient;
import org.springblade.system.pojo.entity.UserInfo;
import org.springblade.system.pojo.entity.User;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -42,6 +43,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -280,13 +282,27 @@ public class BsEfficiencyTaskController extends BladeController {
num++;
}
}
List<LinkedHashMap<String, Object>> tableColumnList = new ArrayList<>();
List<LinkedHashMap<String, Object>> tableColumnList = new ArrayList<>(headMap.size());
for (Map.Entry<String, String> entry : headMap.entrySet()) {
LinkedHashMap<String, Object> tableColumn = new LinkedHashMap<>();
tableColumn.put("label", entry.getKey());
tableColumn.put("prop", entry.getValue());
tableColumnList.add(tableColumn);
}
List<String> employeeCodes = mapList.stream()
.map(map -> (String) map.get(EMPLOYEE_CODE))
.filter(StrUtil::isNotBlank)
.distinct()
.collect(Collectors.toList());
Map<String, User> userMap = new HashMap<>(employeeCodes.size());
if (!CollectionUtils.isEmpty(employeeCodes)) {
List<User> batchUser = userClient.userByCodes(employeeCodes);
if (!CollectionUtils.isEmpty(batchUser)) {
userMap = batchUser.stream()
.filter(u -> u != null)
.collect(Collectors.toMap(User::getCode, Function.identity(), (v1, v2) -> v1));
}
}
List<LinkedHashMap<String, Object>> tableDataList = new ArrayList<>();
LinkedHashMap<String, LinkedHashMap<String, Object>> tableMap = new LinkedHashMap<>();
if (!CollectionUtils.isEmpty(mapList)) {
@ -295,17 +311,19 @@ public class BsEfficiencyTaskController extends BladeController {
for (Map.Entry<String, String> entry : headMap.entrySet()) {
tableData.put(entry.getValue(), map.get(entry.getKey()));
}
String empployeeCode = (String) tableData.get("employeeCode");
R<UserInfo> userInfoResult = userClient.userInfoByCode(empployeeCode);
if (userInfoResult.getData() == null || userInfoResult.getData().getUser() == null || !tableData.get("employeeName").equals(userInfoResult.getData().getUser().getRealName())) {
String employeeCode = (String) tableData.get("employeeCode");
String employeeName = (String) tableData.get("employeeName");
User user = userMap.get(employeeCode);
if (user == null || !Objects.equals(user.getRealName(), employeeName)) {
tableData.put("isSysUser", "0");
} else {
tableData.put("isSysUser", "1");
}
if(tableMap.containsKey(empployeeCode)){
tableMap.remove(empployeeCode);
if (tableMap.containsKey(employeeCode)) {
tableMap.remove(employeeCode);
}
tableMap.put(empployeeCode, tableData);
tableMap.put(employeeCode, tableData);
}
}
tableDataList.addAll(tableMap.values());
@ -333,7 +351,7 @@ public class BsEfficiencyTaskController extends BladeController {
if (!"1".equals(task.getType())) {
R.fail("绩效任务类型检查失败");
}
if (task.getStatus() == null || task.getStatus() != BsEfficiencyTaskEnum.STATUS_IN_PROGRESS.getCode() || task.getStatus() != BsEfficiencyTaskEnum.STATUS_REJECTED.getCode()) {
if (task.getStatus() == null || !(task.getStatus() == BsEfficiencyTaskEnum.STATUS_IN_PROGRESS.getCode() || task.getStatus() == BsEfficiencyTaskEnum.STATUS_REJECTED.getCode())) {
R.fail("绩效任务明细已经填报过了");
}
if (bsEfficiencyTask.getTable() == null) {
@ -341,13 +359,14 @@ public class BsEfficiencyTaskController extends BladeController {
}
List<BsEfficiencyTaskReportEntity> reports = bsEfficiencyTaskReportService.list(new LambdaQueryWrapper<BsEfficiencyTaskReportEntity>().eq(BsEfficiencyTaskReportEntity::getTaskId, task.getId()));
if (!CollectionUtils.isEmpty(reports)) {
for (BsEfficiencyTaskReportEntity report : reports) {
bsEfficiencyTaskReportService.deleteLogic(Arrays.asList(report.getId()));
List<BsEfficiencyTaskParamEntity> params = bsEfficiencyTaskParamService.list(new LambdaQueryWrapper<BsEfficiencyTaskParamEntity>().eq(BsEfficiencyTaskParamEntity::getReportId, report.getId()));
if (CollectionUtils.isEmpty(params)) {
List<Long> ids = params.stream().map(BsEfficiencyTaskParamEntity::getId).collect(Collectors.toList());
bsEfficiencyTaskParamService.deleteLogic(ids);
}
List<Long> reportIds = reports.stream()
.map(BsEfficiencyTaskReportEntity::getId)
.collect(Collectors.toList());
List<BsEfficiencyTaskParamEntity> allParams = bsEfficiencyTaskParamService.listByReportIds(reportIds);
bsEfficiencyTaskReportService.deleteLogic(reportIds);
if (CollectionUtils.isEmpty(allParams)) {
List<Long> ids = allParams.stream().map(BsEfficiencyTaskParamEntity::getId).collect(Collectors.toList());
bsEfficiencyTaskParamService.deleteLogic(ids);
}
}
Map<String, Object> tableMap = bsEfficiencyTask.getTable();
@ -373,6 +392,7 @@ public class BsEfficiencyTaskController extends BladeController {
}
}
bsEfficiencyTaskReportService.save(report);
List<BsEfficiencyTaskParamEntity> paramList = new ArrayList<>();
for (LinkedHashMap<String, Object> column : tableColumn) {
String label = (String) column.get("label");
String prop = (String) column.get("prop");
@ -384,8 +404,9 @@ public class BsEfficiencyTaskController extends BladeController {
param.setReportId(report.getId());
param.setParamName(label);
param.setParamValue(value);
bsEfficiencyTaskParamService.save(param);
paramList.add(param);
}
bsEfficiencyTaskParamService.saveBatch(paramList);
}
BsEfficiencyTaskDTO sub = new BsEfficiencyTaskDTO();
sub.setParentId(task.getId());
@ -434,17 +455,22 @@ public class BsEfficiencyTaskController extends BladeController {
reportParam.setYearMonth(bsEfficiencyTask.getYearMonth());
List<BsEfficiencyTaskReportVO> reports = bsEfficiencyTaskReportService.selectBsEfficiencyTaskReportList(reportParam);
if (!CollectionUtils.isEmpty(reports)) {
List<BsEfficiencyTaskParamEntity> firstParams = bsEfficiencyTaskParamService.list(new LambdaQueryWrapper<BsEfficiencyTaskParamEntity>().eq(BsEfficiencyTaskParamEntity::getReportId, reports.get(0).getId()));
List<LinkedHashMap<String, Object>> tableColumnList = new ArrayList<>();
List<Long> reportIds = reports.stream()
.map(BsEfficiencyTaskReportVO::getId)
.collect(Collectors.toList());
List<BsEfficiencyTaskParamEntity> allParams = bsEfficiencyTaskParamService.listByReportIds(reportIds);
Map<Long, List<BsEfficiencyTaskParamEntity>> paramMap = allParams.stream()
.collect(Collectors.groupingBy(BsEfficiencyTaskParamEntity::getReportId));
LinkedHashMap<String, String> headMap = new LinkedHashMap<>();
headMap.put(this.EMPLOYEE_CODE, "employeeCode");
headMap.put(this.EMPLOYEE_NAME, "employeeName");
headMap.put(EMPLOYEE_CODE, "employeeCode");
headMap.put(EMPLOYEE_NAME, "employeeName");
int num = 1;
List<BsEfficiencyTaskParamEntity> firstParams = paramMap.getOrDefault(reportIds.get(0), Collections.emptyList());
for (BsEfficiencyTaskParamEntity param : firstParams) {
headMap.put(param.getParamName(), "temp" + num);
num++;
headMap.put(param.getParamName(), "temp" + num++);
}
headMap.put(this.TOTAL_SCORE, "totalScore");
headMap.put(TOTAL_SCORE, "totalScore");
List<LinkedHashMap<String, Object>> tableColumnList = new ArrayList<>(headMap.size());
for (Map.Entry<String, String> entry : headMap.entrySet()) {
LinkedHashMap<String, Object> tableColumn = new LinkedHashMap<>();
tableColumn.put("label", entry.getKey());
@ -452,30 +478,41 @@ public class BsEfficiencyTaskController extends BladeController {
tableColumnList.add(tableColumn);
}
Map<String, Object> table = new HashMap<>();
table.put("tableColumn", tableColumnList);
List<String> employeeCodes = reports.stream()
.map(BsEfficiencyTaskReportVO::getEmployeeCode)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
List<User> batchUser = userClient.userByCodes(employeeCodes);
Map<String, User> userMap = new HashMap<>(employeeCodes.size());
if (!CollectionUtils.isEmpty(batchUser)) {
userMap = batchUser.stream()
.filter(user -> user != null)
.collect(Collectors.toMap(User::getCode, Function.identity(), (v1, v2) -> v1));
}
List<LinkedHashMap<String, Object>> tableDataList = new ArrayList();
for (BsEfficiencyTaskReportEntity report : reports) {
List<BsEfficiencyTaskParamEntity> params = bsEfficiencyTaskParamService.list(new LambdaQueryWrapper<BsEfficiencyTaskParamEntity>().eq(BsEfficiencyTaskParamEntity::getReportId, report.getId()));
List<BsEfficiencyTaskParamEntity> params = paramMap.getOrDefault(report.getId(), Collections.emptyList());
LinkedHashMap<String, Object> tableData = new LinkedHashMap<>();
for (BsEfficiencyTaskParamEntity param : params) {
for (Map.Entry<String, String> entry : headMap.entrySet()) {
if (param.getParamName().equals(entry.getKey())) {
tableData.put(entry.getValue(), param.getParamValue());
}
String prop = headMap.get(param.getParamName());
if (prop != null) {
tableData.put(prop, param.getParamValue());
}
}
tableData.put(headMap.get(this.EMPLOYEE_CODE), report.getEmployeeCode());
tableData.put(headMap.get(this.EMPLOYEE_NAME), report.getEmployeeName());
tableData.put(headMap.get(this.TOTAL_SCORE), report.getTotalScore());
R<UserInfo> userInfoResult = userClient.userInfoByCode((String) tableData.get("employeeCode"));
if (userInfoResult.getData() == null || userInfoResult.getData().getUser() == null || !userInfoResult.getData().getUser().getRealName().equals(tableData.get("employeeName"))) {
User user = userMap.get(report.getEmployeeCode());
if (user == null || !Objects.equals(user.getRealName(), report.getEmployeeName())) {
tableData.put("isSysUser", "0");
} else {
tableData.put("isSysUser", "1");
}
tableDataList.add(tableData);
}
table.put("tableDataList", tableDataList);
table.put("tableColumn", tableColumnList);
table.put("tableData", tableDataList);
task.setTable(table);
}
return R.data(task);

@ -5,6 +5,8 @@ import org.springblade.core.mp.base.BaseService;
import org.springblade.desk.efficiency.pojo.entity.BsEfficiencyTaskParamEntity;
import org.springblade.desk.efficiency.pojo.vo.BsEfficiencyTaskParamVO;
import java.util.List;
/**
* 绩效任务参数 服务类
*
@ -22,4 +24,6 @@ public interface IBsEfficiencyTaskParamService extends BaseService<BsEfficiencyT
*/
IPage<BsEfficiencyTaskParamVO> selectBsEfficiencyTaskParamPage(IPage<BsEfficiencyTaskParamVO> page, BsEfficiencyTaskParamVO bsEfficiencyTaskParam);
List<BsEfficiencyTaskParamEntity> listByReportIds(List<Long> reportIds);
}

@ -1,6 +1,8 @@
package org.springblade.desk.efficiency.service.impl;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.desk.efficiency.mapper.BsEfficiencyTaskParamMapper;
@ -9,6 +11,9 @@ import org.springblade.desk.efficiency.pojo.vo.BsEfficiencyTaskParamVO;
import org.springblade.desk.efficiency.service.IBsEfficiencyTaskParamService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 绩效任务参数 服务实现类
*
@ -22,4 +27,20 @@ public class BsEfficiencyTaskParamServiceImpl extends BaseServiceImpl<BsEfficien
public IPage<BsEfficiencyTaskParamVO> selectBsEfficiencyTaskParamPage(IPage<BsEfficiencyTaskParamVO> page, BsEfficiencyTaskParamVO bsEfficiencyTaskParam) {
return page.setRecords(baseMapper.selectBsEfficiencyTaskParamPage(page, bsEfficiencyTaskParam));
}
@Override
public List<BsEfficiencyTaskParamEntity> listByReportIds(List<Long> reportIds) {
int batchSize = 950;
List<List<Long>> batchList = ListUtil.split(reportIds, batchSize);
List<BsEfficiencyTaskParamEntity> allList = new ArrayList<>();
for (List<Long> subReportIds : batchList) {
List<BsEfficiencyTaskParamEntity> tempList = this.list(
new LambdaQueryWrapper<BsEfficiencyTaskParamEntity>()
.in(BsEfficiencyTaskParamEntity::getReportId, subReportIds)
);
allList.addAll(tempList);
}
return allList;
}
}

@ -156,7 +156,11 @@ public class BsEnergyCoreUseServiceImpl extends BaseServiceImpl<BsEnergyCoreUseM
bsEnergyHistoryRec.setReadElectric(new BigDecimal(this.totalRead(jsonObject, readElectric, readElectric2, readElectric3)));
// 读取上传时间
bsEnergyHistoryRec.setUploadTime(jsonObject.getDate(timestamp));
BsEnergyHistoryRecEntity last = bsEnergyHistoryRecService.getOne(new LambdaQueryWrapper<BsEnergyHistoryRecEntity>().eq(BsEnergyHistoryRecEntity::getDeviceCode, deviceCode).orderByDesc(BsEnergyHistoryRecEntity::getCreateTime).last("AND ROWNUM = 1"));
List<BsEnergyHistoryRecEntity> bsEnergyHistoryRecEntities = bsEnergyHistoryRecService.list(new LambdaQueryWrapper<BsEnergyHistoryRecEntity>().eq(BsEnergyHistoryRecEntity::getDeviceCode, deviceCode).orderByDesc(BsEnergyHistoryRecEntity::getCreateTime));
BsEnergyHistoryRecEntity last = null;
if(!CollectionUtils.isEmpty(bsEnergyHistoryRecEntities)){
last = bsEnergyHistoryRecEntities.get(0);
}
if (last != null && last.getId() != null) {
BigDecimal readElectric = last.getReadElectric(); // 电
BigDecimal readPure = last.getReadPure(); // 纯水

@ -25,6 +25,7 @@
*/
package org.springblade.system.feign;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Hidden;
@ -42,6 +43,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
@ -186,4 +188,17 @@ public class UserClient implements IUserClient {
public List<User> userByRole(String roleId) {
return service.userByRole(roleId);
}
@Override
@PostMapping(USER_BY_CODES)
public List<User> userByCodes(@RequestBody List<String> codes) {
int batchSize = 950;
List<List<String>> batchList = ListUtil.split(codes, batchSize);
List<User> allUser = new ArrayList<>();
for (List<String> subCodes : batchList) {
List<User> tempList = service.userByCodes(subCodes);
allUser.addAll(tempList);
}
return allUser;
}
}

@ -320,4 +320,6 @@ public interface IUserService extends BaseService<User> {
User userByAccountV2(String tenantId);
List<User> userByRole(String roleId);
List<User> userByCodes(List<String> codes);
}

@ -627,4 +627,10 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
return list(Wrappers.lambdaQuery(User.class)
.like(User::getRoleId, roleId));
}
@Override
public List<User> userByCodes(List<String> codes) {
return list(Wrappers.lambdaQuery(User.class)
.in(User::getCode, codes));
}
}

Loading…
Cancel
Save