feat(bpm): 调整流程实例抄送服务中的日期时间处理

- 引入 LocalDateTimeUtil 工具类优化日期处理
- 将 ReceiveCCRequestDTO 和 ReceiveTodoRequestDTO 中的时间字段类型从 LocalDateTime 改为 Date
- 添加 JsonFormat 注解以统一前后端日期格式化
- 修正 BpmProcessInstanceCopyServiceImpl 中日期转换逻辑,确保时区一致性
- 在 DemoController 中增加获取当前时间接口用于测试时间序列功能
- 更新相关导入包及调整代码格式提升可读性
This commit is contained in:
2025-12-11 10:51:08 +08:00
parent 3754d9340f
commit 0b48e4d785
6 changed files with 62 additions and 32 deletions

View File

@@ -1,18 +1,15 @@
package com.jeelowcode.module.biz.controller;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
import com.jeelowcode.framework.utils.model.global.BaseWebResult;
import com.jeelowcode.module.biz.dto.RequestDTO;
import com.jeelowcode.module.biz.service.IDemoService;
import com.jeelowcode.framework.utils.model.global.BaseWebResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jeelowcode.service.infra.entity.ConfigDO;
import com.jeelowcode.service.infra.service.IConfigService;
import com.jeelowcode.tool.framework.common.model.ContentModel;
import com.jeelowcode.tool.framework.common.model.PartModel;
import com.jeelowcode.tool.framework.common.pojo.CommonResult;
import com.jeelowcode.tool.framework.common.util.http.HttpUtils;
@@ -23,12 +20,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.jeelowcode.tool.framework.common.pojo.CommonResult.error;
import static com.jeelowcode.tool.framework.common.pojo.CommonResult.success;
@@ -42,15 +36,20 @@ import static com.jeelowcode.tool.framework.common.pojo.CommonResult.success;
@Tag(name = "低代码框架 - 个性化接口")
@RestController
@AllArgsConstructor
@RequestMapping(JeeLowCodeBaseConstant.REQUEST_URL_START +"/demo")
@RequestMapping(JeeLowCodeBaseConstant.REQUEST_URL_START + "/demo")
public class DemoController {
private final IDemoService demoService;
@Operation(summary = "获取当前时间")
@GetMapping({"/getJsonLocalDateTime"})
public CommonResult<Boolean> getJsonLocalDateTime() {
return success(demoService.testLocalDateTime());
}
@Autowired
private IConfigService configService;
@GetMapping({"/getData"})
@ApiOperationSupport(order = 2)
@Operation(summary = "获取demo数据")
@@ -63,18 +62,18 @@ public class DemoController {
@ApiOperationSupport(order = 3)
@Operation(summary = "取阿里平台Token")
public CommonResult<String> getAliToken() {
try{
try {
ConfigDO configUrl = configService.getConfigByKey("aliUrl");
ConfigDO configKey = configService.getConfigByKey("aliAppkey");
ConfigDO configSecret = configService.getConfigByKey("aliAppSecret");
if(Objects.isNull(configUrl) || Objects.isNull(configKey) || Objects.isNull(configSecret)
|| StringUtils.isEmpty(configUrl.getValue()) || StringUtils.isEmpty(configKey.getValue()) || StringUtils.isEmpty(configSecret.getValue())){
if (Objects.isNull(configUrl) || Objects.isNull(configKey) || Objects.isNull(configSecret)
|| StringUtils.isEmpty(configUrl.getValue()) || StringUtils.isEmpty(configKey.getValue()) || StringUtils.isEmpty(configSecret.getValue())) {
throw new JeeLowCodeException("缺少阿里平台必要参数配置");
}
String token = HttpUtils.getToken(configUrl.getValue()+"/_campus/open/accessToken.json",configKey.getValue(),configSecret.getValue());
String token = HttpUtils.getToken(configUrl.getValue() + "/_campus/open/accessToken.json", configKey.getValue(), configSecret.getValue());
return success(token);
}catch (Exception e){
return error(500,e.getMessage());
} catch (Exception e) {
return error(500, e.getMessage());
}
}
@@ -92,7 +91,7 @@ public class DemoController {
" }\n" +
" ]\n" +
"}";
List<PartModel> contentModels = HttpUtils.getTokenDate(configUrl.getValue()+"/_campus/open/api/invoked.json?access_token="+token,bodyString);
List<PartModel> contentModels = HttpUtils.getTokenDate(configUrl.getValue() + "/_campus/open/api/invoked.json?access_token=" + token, bodyString);
return success(contentModels);
}
@@ -101,11 +100,11 @@ public class DemoController {
@ApiOperationSupport(order = 5)
@Operation(summary = "取阿里平台通用接口取数")
public CommonResult<String> getCustomerInterface(@RequestBody RequestDTO params) {
try{
String result = HttpUtils.getInterfaceData(params.getUrl(),params.getParams(),params.getBody(),params.getMethod(),params.getAuthorization());
try {
String result = HttpUtils.getInterfaceData(params.getUrl(), params.getParams(), params.getBody(), params.getMethod(), params.getAuthorization());
return success(result);
}catch (Exception e){
return error(500,e.getMessage());
} catch (Exception e) {
return error(500, e.getMessage());
}
}
}

View File

@@ -12,4 +12,7 @@ public interface IDemoService {
List<Map<String, Object>> getDemoData();
void testAsync();
boolean testLocalDateTime();
}

View File

@@ -6,11 +6,14 @@ import com.jeelowcode.framework.plus.SqlHelper;
import com.jeelowcode.framework.plus.build.buildmodel.wrapper.SqlInfoQueryWrapper;
import com.jeelowcode.module.biz.mapper.DemoMapper;
import com.jeelowcode.module.biz.service.IDemoService;
import com.jeelowcode.service.bpm.config.framework.portal.core.dto.ReceiveCCRequestDTO;
import com.jeelowcode.tool.framework.common.util.json.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -30,7 +33,7 @@ public class DemoServiceImpl implements IDemoService {
@Override
public List<Map<String, Object>> getDemoData(){
public List<Map<String, Object>> getDemoData() {
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
wrapper.setTableName("tbl_lin_class");
List<Map<String, Object>> dataMapList = sqlService.getDataListByPlus(wrapper);
@@ -39,7 +42,17 @@ public class DemoServiceImpl implements IDemoService {
@Async("asyncPoolTaskExecutor")
@Override
public void testAsync(){
public void testAsync() {
log.info("哈哈哈");
}
@Override
public boolean testLocalDateTime() {
ReceiveCCRequestDTO request = new ReceiveCCRequestDTO()
.setReceiveDateTime(new Date())
.setCreateDateTime(new Date());
log.info("request: {}", JsonUtils.toJsonString(request));
return true;
}
}

View File

@@ -1,9 +1,13 @@
package com.jeelowcode.service.bpm.config.framework.portal.core.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
import static com.jeelowcode.tool.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.jeelowcode.tool.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/**
* 描述:接收待阅流程请求参数
@@ -54,7 +58,8 @@ public class ReceiveCCRequestDTO {
* 创建时间
*/
@JsonProperty("createdatetime")
private LocalDateTime createDateTime;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date createDateTime;
/**
* 接收人
*/
@@ -63,11 +68,12 @@ public class ReceiveCCRequestDTO {
* 接收时间
*/
@JsonProperty("receivedatetime")
private LocalDateTime receiveDateTime;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date receiveDateTime;
/**
* 接收时间戳
*/
@JsonProperty("receivets")
private Long receiveTs;
}

View File

@@ -1,9 +1,13 @@
package com.jeelowcode.service.bpm.config.framework.portal.core.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
import static com.jeelowcode.tool.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.jeelowcode.tool.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/**
* 描述:接收待办流程请求参数
@@ -56,7 +60,8 @@ public class ReceiveTodoRequestDTO {
* 创建时间
*/
@JsonProperty("createdatetime")
private LocalDateTime createDateTime;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date createDateTime;
/**
* 接收人
*/
@@ -65,7 +70,8 @@ public class ReceiveTodoRequestDTO {
* 接收时间
*/
@JsonProperty("receivedatetime")
private LocalDateTime receiveDateTime;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date receiveDateTime;
/**
* 接收时间戳
*/

View File

@@ -3,6 +3,7 @@ package com.jeelowcode.service.bpm.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
@@ -34,7 +35,9 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.sql.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -167,9 +170,9 @@ public class BpmProcessInstanceCopyServiceImpl implements IBpmProcessInstanceCop
.setNodeName(copy.getTaskName())
.setPcUrl("/process-instance/detail?id=" + copy.getProcessInstanceId())
.setCreator(creatorUser.getUsername())
.setCreateDateTime(copy.getCreateTime())
.setCreateDateTime(Date.from(copy.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()))
.setReceiver(receiverUser.getUsername())
.setReceiveDateTime(copy.getCreateTime())
.setReceiveDateTime(Date.from(copy.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()))
.setReceiveTs(System.currentTimeMillis());
}
).forEach(request -> {