|
|
|
|
@ -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); |
|
|
|
|
|