Commit 7a86a75e by 林永健

refactor(digitalManagement): 优化myRecordDetail查询逻辑以支持排除模板码

- 在Mapper中为myRecordDetail方法新增excludeTemplateCode参数,实现排除指定模板查询
- 在Service层新增getMyRecordDetail方法,根据templateCode是否为空动态设置excludeTemplateCode参数
- 修改原调用myRecordDetail位置,改为调用getMyRecordDetail方法以适配新逻辑
- 在SQL映射文件中新增excludeTemplateCode的条件判断,排除对应模板码的记录
- 添加myRecordDetail接口的单元测试,验证新增功能的正确性
1 parent 28ee88d5
......@@ -38,7 +38,10 @@ public interface DigitalManagementStaffRecordMapper extends OreMapper<DigitalMan
* @param date
* @return
*/
DigitalManagementStaffRecord myRecordDetail(@Param("uuid") String uuid, @Param("date") Date date, @Param("templateCode") String templateCode);
DigitalManagementStaffRecord myRecordDetail(@Param("uuid") String uuid,
@Param("date") Date date,
@Param("excludeTemplateCode") String excludeTemplateCode,
@Param("templateCode") String templateCode);
List<DigitalManagementStaffRecordSummaryDTO> summaryStaff(DigitalManagementStaffRecordDTO dto);
......
......@@ -241,7 +241,7 @@ public class DigitalManagementStaffRecordService {
String uuid = dto.getUuid();
Integer loginRole = dto.getLoginRole();
String templateCode = dto.getTemplateCode();
DigitalManagementStaffRecord staffRecord = staffRecordMapper.myRecordDetail(uuid, date, templateCode);
DigitalManagementStaffRecord staffRecord = getMyRecordDetail(uuid, date, templateCode);
if (Objects.isNull(staffRecord)) {
return getStaffRecordTemplateInfo(loginRole, uuid, date, templateCode);
}
......@@ -249,6 +249,15 @@ public class DigitalManagementStaffRecordService {
return getDigitalManagementStaffRecordDTO(staffRecord);
}
public DigitalManagementStaffRecord getMyRecordDetail(String uuid, Date date, String templateCode) {
// 轻改入口会指定模板code,如果没有传,应该过滤轻改模板
String excludeTemplateCode = null;
if (StringUtils.isBlank(templateCode)) {
excludeTemplateCode = templateService.getLightChangeTemplateCode();
}
return staffRecordMapper.myRecordDetail(uuid, date, excludeTemplateCode, templateCode);
}
private DigitalManagementStaffRecordDTO getStaffRecordTemplateInfo(Integer loginRole, String uuid, Date date, String templateCode) {
DigitalManagementTemplate template;
if (StringUtils.isNotBlank(templateCode)) {
......@@ -337,7 +346,7 @@ public class DigitalManagementStaffRecordService {
DigitalManagementTemplate template = templateService.getTemplateByStaffUuid(loginRole, uuid, today, templateCode);
RpcAssert.assertNotNull(template, DefaultErrorEnum.VALIDATE_FAILED, "您当前无需提交该日报");
DigitalManagementStaffRecord staffRecord = staffRecordMapper.myRecordDetail(uuid, today, templateCode);
DigitalManagementStaffRecord staffRecord = getMyRecordDetail(uuid, today, templateCode);
// 20251208 区域运营支持当日模板进行编辑
boolean supportEdit = StringUtils.isNotBlank(template.getExtendField())
&& Optional.ofNullable(JSON.parseObject(template.getExtendField())).map(p -> p.getBoolean("supportEdit")).orElse(false);
......
......@@ -165,6 +165,9 @@
<if test="templateCode != null and templateCode != ''">
and template_code = #{templateCode}
</if>
<if test="excludeTemplateCode != null and excludeTemplateCode != ''">
and template_code != #{excludeTemplateCode}
</if>
and staff_uuid = #{uuid}
and date(created_date) = date(#{date})
order by created_date desc
......
......@@ -277,8 +277,9 @@ public class DigitalManagementServiceTest extends BaseServiceTest {
@Test
public void updateTemplateStaffRefTest() {
DigitalManagementStaffRecordDTO condition = new DigitalManagementStaffRecordDTO();
condition.setTemplateCode("uuid-temp-001");
condition.setStaffUuidList(Lists.newArrayList("1d680788c3fe4d2ebcc1e02a92f0a996", "8104840424a0455db573c5fb84ab7383"));
// condition.setTemplateCode("uuid-temp-001");
condition.setTemplateCode("qinggai-temp-001");
condition.setStaffUuidList(Lists.newArrayList("d7de74f36d16498291f0de496afe216e", "44c0e96ebd5f4bbb89460e02a1f7c67a"));
Object res = templateService.updateTemplateStaffRef(condition);
condition.setStaffUuidList(Lists.newArrayList("8104840424a0455db573c5fb84ab7383"));
res = templateService.updateTemplateStaffRef(condition);
......@@ -362,4 +363,19 @@ public class DigitalManagementServiceTest extends BaseServiceTest {
}
}
@Test
public void myRecordDetail(){
try {
StaffRecordDetailRequestDTO req = new StaffRecordDetailRequestDTO();
req.setDate(new Date());
req.setUuid("97859d4569a34d92bfe1f4e697440a66");
req.setTemplateCode("qinggai-temp-001");
req.setLoginRole(1);
Object res = staffRecordService.myRecordDetail(req);
System.out.println(res);
}catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!