Commit 59bb0cd7 by 杨卫

feat:周报月报自测

1 parent fe5be261
package cn.com.glsx.dj.mindworkplate.dto.digitalmanagement;
import cn.com.glsx.dj.mindworkplate.model.digitalmanagement.DigitalManagementTemplate;
import cn.hutool.core.map.MapUtil;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Data
......@@ -34,6 +36,9 @@ public class DigitalManagementTemplateSummaryDTO implements Serializable {
private List<String> unSubmittedStaffNames = Lists.newArrayList();
/** key uuid, value staffName */
private Map<String, String> unSubmittedStaffUuidMapName = MapUtil.<String, String>builder().build();
public Integer getIntOrDefault(Integer target){
return Objects.isNull(target) ? 0 : target;
}
......
package cn.com.glsx.dj.mindworkplate.dto.digitalmanagement;
import lombok.Data;
import java.util.Date;
/**
* @author yangwei
* @version 1.0
* @since 2026/01/13 21:07
*/
@Data
public class SubmitCountDTO {
/**
* 用户id
*/
private String uuid;
/**
* 提交次数
*/
private Integer submitCount;
/**
* 最近一次提交时间
*/
private Date recentlySubmitDate;
}
......@@ -12,6 +12,7 @@ import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
@Mapper
public interface DigitalManagementStaffRecordMapper extends OreMapper<DigitalManagementStaffRecord> {
......@@ -89,4 +90,16 @@ public interface DigitalManagementStaffRecordMapper extends OreMapper<DigitalMan
* @return java.util.List<cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.StaffGoodNewsTemplateRespDTO>
*/
List<StaffGoodNewsTemplateRespDTO> findStaffGoodNewsTemplate(StaffGoodNewsTemplateReqDTO request);
List<SubmitCountDTO> selectSubmitCountAssignRange(
@Param("uuids") Set<String> uuids,
@Param("templateCode") String templateCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate
);
List<SubmitCountDTO> selectRecentlySubmitDate(
@Param("uuids") Set<String> strings,
@Param("templateCode") String templateCode
);
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import cn.com.glsx.merchants.remote.MerchantStaffRemote;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
......@@ -190,7 +191,8 @@ public class DigitalManagementStaffRecordService {
return sequenceIdPage;
}
public List<DigitalManagementStaffRecordSummaryDTO> staffRecordSummary(DigitalManagementStaffRecordDTO dto) {
@Deprecated
public List<DigitalManagementStaffRecordSummaryDTO> staffRecordSummary1(DigitalManagementStaffRecordDTO dto) {
// 查询未提交员工
Collection<DigitalManagementStaffInfoDTO> staffInfos = getUnsubmittedStaffInfo(dto);
// 今日未提交员工为空,则返回
......@@ -220,6 +222,73 @@ public class DigitalManagementStaffRecordService {
return res;
}
/**
* 员工未提交统计
* @author yangwei
* @since 2026/1/13 21:51
* @param dto 请求参数
* @return java.util.List<cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementStaffRecordSummaryDTO>
*/
public List<DigitalManagementStaffRecordSummaryDTO> staffRecordSummary(DigitalManagementStaffRecordDTO dto) {
StaffGoodNewsStatisticsDTO staffGoodNewsStatisticsDTO = BeanUtil.copyProperties(dto, StaffGoodNewsStatisticsDTO.class);
staffGoodNewsStatisticsDTO.setCode(dto.getTemplateCode());
// 统计获取未提交人员列表
DigitalManagementTemplateSummaryDTO statistics = this.statistics(staffGoodNewsStatisticsDTO);
List<DigitalManagementStaffRecordSummaryDTO> result = Lists.newArrayList();
Map<String, String> unSubmittedStaffUuidMapName = statistics.getUnSubmittedStaffUuidMapName();
if (MapUtil.isEmpty(unSubmittedStaffUuidMapName)) {
return result;
}
LocalDate currentSystemLocalDate = staffRecordSpecialHandler.getCurrentSystemLocalDate();
// 本月提交数
MonthRange monthRange = cn.com.glsx.dj.mindworkplate.util.DateUtils.getMonthRange(currentSystemLocalDate);
List<SubmitCountDTO> currentMonthSubmitCountAssignRange = staffRecordMapper.selectSubmitCountAssignRange(
unSubmittedStaffUuidMapName.keySet(),
dto.getTemplateCode(),
cn.com.glsx.dj.mindworkplate.util.DateUtils.formatLocalDate(monthRange.getStartDate(), DateUtils.DEFAULT_DATE_FORMAT5),
cn.com.glsx.dj.mindworkplate.util.DateUtils.formatLocalDate(monthRange.getEndDate(), DateUtils.DEFAULT_DATE_FORMAT5));
Map<String, SubmitCountDTO> uuidMapCurrentMonthSubmitCount = currentMonthSubmitCountAssignRange.stream()
.collect(Collectors.toMap(SubmitCountDTO::getUuid, Function.identity(), (p, q) -> p));
// 本周提交数
WeekRange weekRange = cn.com.glsx.dj.mindworkplate.util.DateUtils.getWeekRange(currentSystemLocalDate);
List<SubmitCountDTO> currentWeekSubmitCountAssignRange = staffRecordMapper.selectSubmitCountAssignRange(
unSubmittedStaffUuidMapName.keySet(),
dto.getTemplateCode(),
cn.com.glsx.dj.mindworkplate.util.DateUtils.formatLocalDate(weekRange.getStartDate(), DateUtils.DEFAULT_DATE_FORMAT5),
cn.com.glsx.dj.mindworkplate.util.DateUtils.formatLocalDate(weekRange.getEndDate(), DateUtils.DEFAULT_DATE_FORMAT5));
Map<String, SubmitCountDTO> uuidMapCurrentWeekSubmitCount = currentWeekSubmitCountAssignRange.stream()
.collect(Collectors.toMap(SubmitCountDTO::getUuid, Function.identity(), (p, q) -> p));
// 最近提交时间
List<SubmitCountDTO> recentlySubmitDates = staffRecordMapper.selectRecentlySubmitDate(unSubmittedStaffUuidMapName.keySet(), dto.getTemplateCode());
Map<String, SubmitCountDTO> uuidMapRecentlySubmitDate = recentlySubmitDates.stream()
.collect(Collectors.toMap(SubmitCountDTO::getUuid, Function.identity(), (p, q) -> p));
List<DigitalManagementStaffRecordSummaryDTO> collect = unSubmittedStaffUuidMapName.entrySet()
.stream()
.map(entry -> {
Integer currMonthSubmitCount = Optional.ofNullable(uuidMapCurrentMonthSubmitCount.get(entry.getKey()))
.map(SubmitCountDTO::getSubmitCount)
.orElse(null);
Integer currWeeklySubmitCount = Optional.ofNullable(uuidMapCurrentWeekSubmitCount.get(entry.getKey()))
.map(SubmitCountDTO::getSubmitCount)
.orElse(null);
Date recentlySubmitDate = Optional.ofNullable(uuidMapRecentlySubmitDate.get(entry.getKey()))
.map(SubmitCountDTO::getRecentlySubmitDate)
.orElse(null);
return new DigitalManagementStaffRecordSummaryDTO(
entry.getKey(), entry.getValue(), recentlySubmitDate, currWeeklySubmitCount, currMonthSubmitCount);
})
.collect(Collectors.toList());
result.addAll(collect);
return result;
}
/**
* 查询未提交员工
*/
......@@ -1099,7 +1168,7 @@ public class DigitalManagementStaffRecordService {
for (String date : submitDate) {
List<String> needSubmitStaffUuids = groupedStaffUuids.get(date);
List<String> submittedDateMapUuid = submitDateMapUuidList.get(date);
DigitalManagementTemplateSummaryDTO singleSummary = statisticsSingleCycleByPhone(
DigitalManagementTemplateSummaryDTO singleSummary = statisticsSingleCycle(
request,
submittedDateMapUuid,
needSubmitStaffUuids,
......@@ -1109,9 +1178,11 @@ public class DigitalManagementStaffRecordService {
totalSummary.setFinishCount(singleSummary.getFinishCount() + totalSummary.getFinishCount());
totalSummary.setUndoCount(singleSummary.getUndoCount() + totalSummary.getUndoCount());
totalSummary.getUnSubmittedStaffNames().addAll(singleSummary.getUnSubmittedStaffNames());
totalSummary.getUnSubmittedStaffUuidMapName().putAll(singleSummary.getUnSubmittedStaffUuidMapName());
}
totalSummary.setUnSubmittedStaffNamesStr(StrUtil.join(SymbolConstants.COMMA, totalSummary.getUnSubmittedStaffNames()));
return totalSummary;
}
......@@ -1126,11 +1197,11 @@ public class DigitalManagementStaffRecordService {
* @param distinct 去重维度
* @return cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementTemplateSummaryDTO
*/
public DigitalManagementTemplateSummaryDTO statisticsSingleCycleByPhone(StaffGoodNewsStatisticsDTO request,
List<String> submittedDateUuid,
List<String> needSubmitStaffUuids,
Map<String, MerchantStaffResponse> uuidMapInfo,
DistinctDimensionalityEnum distinct) {
public DigitalManagementTemplateSummaryDTO statisticsSingleCycle(StaffGoodNewsStatisticsDTO request,
List<String> submittedDateUuid,
List<String> needSubmitStaffUuids,
Map<String, MerchantStaffResponse> uuidMapInfo,
DistinctDimensionalityEnum distinct) {
DigitalManagementTemplateSummaryDTO statistics = new DigitalManagementTemplateSummaryDTO();
statistics.setCode(request.getCode());
statistics.setName(request.getName());
......@@ -1147,6 +1218,8 @@ public class DigitalManagementStaffRecordService {
}
Map<String, String> allMapStaffName = MapUtil.<String, String>builder().build();
// 未提交的
Map<String, String> unSubmittedStaffUuidMapName = MapUtil.<String, String>builder().build();
Set<String> submitted = Sets.newHashSet();
List<String> finalSubmittedDateUuid = submittedDateUuid;
if (distinct == DistinctDimensionalityEnum.PHONE) {
......@@ -1158,6 +1231,8 @@ public class DigitalManagementStaffRecordService {
if (finalSubmittedDateUuid.contains(uuid)) {
submitted.add(staffPhone);
} else {
unSubmittedStaffUuidMapName.put(uuid, merchantStaffResponse.getStaffName());
}
});
} else {
......@@ -1167,6 +1242,8 @@ public class DigitalManagementStaffRecordService {
allMapStaffName.putIfAbsent(uuid, merchantStaffResponse.getStaffName());
if (finalSubmittedDateUuid.contains(uuid)) {
submitted.add(uuid);
} else {
unSubmittedStaffUuidMapName.put(uuid, merchantStaffResponse.getStaffName());
}
});
}
......@@ -1174,11 +1251,15 @@ public class DigitalManagementStaffRecordService {
statistics.setTotalCount(Integer.toUnsignedLong(allMapStaffName.size()));
statistics.setFinishCount(Integer.toUnsignedLong(submitted.size()));
statistics.setUndoCount(statistics.getTotalCount() - statistics.getFinishCount());
statistics.setUnSubmittedStaffNames(allMapStaffName.entrySet()
.stream()
.filter(entry -> !submitted.contains(entry.getKey()))
List<Map.Entry<String, String>> entries = allMapStaffName.entrySet()
.stream()
.filter(entry -> !submitted.contains(entry.getKey()))
.collect(Collectors.toList());
statistics.setUnSubmittedStaffNames(entries.stream()
.map(Map.Entry::getValue)
.collect(Collectors.toList()));
statistics.getUnSubmittedStaffUuidMapName().putAll(unSubmittedStaffUuidMapName);
return statistics;
}
......
......@@ -385,4 +385,35 @@
ORDER BY t3.report_type, t3.code
</select>
<select id="selectSubmitCountAssignRange"
resultType="cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.SubmitCountDTO">
select
staff_uuid uuid, count(0) submitCount
from digital_management_staff_record
where
staff_uuid in
<foreach item="item" collection="uuids" separator="," open="(" close=")" index="">
#{item}
</foreach>
and deleted_flag = 'N'
and DATE_FORMAT(created_date, '%Y%m%d') between #{startDate} and #{endDate}
and template_code = #{templateCode}
group by staff_uuid
</select>
<select id="selectRecentlySubmitDate"
resultType="cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.SubmitCountDTO">
select
staff_uuid uuid, created_date recentlySubmitDate
from digital_management_staff_record
where
staff_uuid in
<foreach item="item" collection="uuids" separator="," open="(" close=")" index="">
#{item}
</foreach>
and template_code = #{templateCode}
and deleted_flag = 'N'
group by staff_uuid
</select>
</mapper>
\ No newline at end of file
......@@ -23,7 +23,7 @@ public class ReportUnSummitStatisticsHandlerTest extends BaseServiceTest {
GoodNewsTemplateReportTypeEnum reportType2 = GoodNewsTemplateReportTypeEnum.MONTH;
reportUnSummitStatisticsHandler.statisticsThenPush(reportType2);
GoodNewsTemplateReportTypeEnum reportType3 = GoodNewsTemplateReportTypeEnum.WEEK;
reportUnSummitStatisticsHandler.statisticsThenPush(reportType3);
// GoodNewsTemplateReportTypeEnum reportType3 = GoodNewsTemplateReportTypeEnum.WEEK;
// reportUnSummitStatisticsHandler.statisticsThenPush(reportType3);
}
}
package cn.com.glsx.dj.mindworkplate.remote;
import cn.com.glsx.dj.mindworkplate.constant.DigitalManagementConstants;
import cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementStaffRecordDTO;
import cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.DigitalManagementTemplateDTO;
import cn.com.glsx.dj.mindworkplate.dto.digitalmanagement.SaveStaffRecordRequestDTO;
import cn.com.glsx.dj.mindworkplate.service.BaseServiceTest;
......@@ -21,6 +22,8 @@ public class DigitalManagementRecordRemoteImplTest extends BaseServiceTest {
@Autowired
private DigitalManagementRecordRemote digitalManagementRecordRemote;
@Test
public void testSave() throws InterruptedException {
String uuid = "68766685445611ecb088000c29c0b837";
......@@ -127,23 +130,35 @@ public class DigitalManagementRecordRemoteImplTest extends BaseServiceTest {
@Test
public void testRecordSummary() throws InterruptedException {
DigitalManagementTemplateDTO templateDTO1 = new DigitalManagementTemplateDTO();
templateDTO1.setCode("uuid-temp-001");
templateDTO1.setStartTime(DateUtil.parse("2026-01-01 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
templateDTO1.setEndTime(DateUtil.parse("2026-01-13 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO1));
DigitalManagementTemplateDTO templateDTO2 = new DigitalManagementTemplateDTO();
templateDTO2.setCode("uuid-temp-014");
templateDTO2.setStartTime(DateUtil.parse("2026-01-11 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
templateDTO2.setEndTime(DateUtil.parse("2026-01-11 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO2));
DigitalManagementTemplateDTO templateDTO3 = new DigitalManagementTemplateDTO();
templateDTO3.setCode("uuid-temp-019");
templateDTO3.setStartTime(DateUtil.parse("2026-01-01 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
templateDTO3.setEndTime(DateUtil.parse("2026-01-13 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO3));
// DigitalManagementTemplateDTO templateDTO1 = new DigitalManagementTemplateDTO();
// templateDTO1.setCode("uuid-temp-001");
// templateDTO1.setStartTime(DateUtil.parse("2026-01-01 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
// templateDTO1.setEndTime(DateUtil.parse("2026-01-13 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
// System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO1));
//
// DigitalManagementTemplateDTO templateDTO2 = new DigitalManagementTemplateDTO();
// templateDTO2.setCode("uuid-temp-014");
// templateDTO2.setStartTime(DateUtil.parse("2026-01-11 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
// templateDTO2.setEndTime(DateUtil.parse("2026-01-11 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
// System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO2));
//
// DigitalManagementTemplateDTO templateDTO3 = new DigitalManagementTemplateDTO();
// templateDTO3.setCode("uuid-temp-019");
// templateDTO3.setStartTime(DateUtil.parse("2026-01-01 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
// templateDTO3.setEndTime(DateUtil.parse("2026-01-13 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
// System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO3));
DigitalManagementStaffRecordDTO templateDTO4 = new DigitalManagementStaffRecordDTO();
templateDTO4.setTemplateCode("qinggai-temp-001");
templateDTO4.setStartTime(DateUtil.parse("2025-12-17 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
templateDTO4.setEndTime(DateUtil.parse("2026-01-14 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
System.out.println(digitalManagementRecordRemote.staffRecordSummary(templateDTO4));
DigitalManagementTemplateDTO templateDTO5 = new DigitalManagementTemplateDTO();
templateDTO5.setCode("qinggai-temp-001");
templateDTO5.setStartTime(DateUtil.parse("2025-12-17 00:00:00", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
templateDTO5.setEndTime(DateUtil.parse("2026-01-14 23:59:59", cn.com.glsx.framework.core.util.DateUtils.DEFAULT_DATE_FORMAT4));
System.out.println(digitalManagementRecordRemote.recordSummary(templateDTO5));
Thread.sleep(1000 * 60 * 60);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!