|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.start.tz.module.pressure2.service.pipetaskordersecuritycheck;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.start.tz.framework.common.pojo.PageResult;
|
|
|
import cn.start.tz.framework.common.util.object.BeanUtils;
|
|
|
import cn.start.tz.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
@@ -19,11 +20,13 @@ import cn.start.tz.module.pressure2.dal.mysql.boilerconnecttbservice.BoilerConne
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.dynamictb.DynamicTbMapper;
|
|
|
import cn.start.tz.module.pressure2.dal.mysql.pipetaskordersecuritycheck.PipeTaskOrderSecurityCheckMapper;
|
|
|
import cn.start.tz.module.pressure2.service.dynamictbins.DynamicTbInsService;
|
|
|
+import cn.start.tz.module.pressure2.util.OADateFormat;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import jakarta.annotation.Resource;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -45,6 +48,7 @@ import static cn.start.tz.module.pressure2.enums.ErrorCodeConstants.PIPE_TASK_OR
|
|
|
*/
|
|
|
@Service
|
|
|
@Validated
|
|
|
+@Slf4j
|
|
|
public class PipeTaskOrderSecurityCheckServiceImpl extends ServiceImpl<PipeTaskOrderSecurityCheckMapper, PipeTaskOrderSecurityCheckDO> implements PipeTaskOrderSecurityCheckService {
|
|
|
|
|
|
@Resource
|
|
|
@@ -204,4 +208,83 @@ public class PipeTaskOrderSecurityCheckServiceImpl extends ServiceImpl<PipeTaskO
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void validateTaskOrderSecurityCheckExists(String id) {
|
|
|
+ if (pipeTaskOrderSecurityCheckMapper.selectById(id) == null) {
|
|
|
+ // throw exception(TASK_ORDER_SECURITY_CHECK_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateTaskOrderSecurityCheck(PipeTaskOrderSecurityCheckSaveReqVO updateReqVO) {
|
|
|
+ String userId = getLoginUserId();
|
|
|
+ // 校验存在
|
|
|
+ validateTaskOrderSecurityCheckExists(updateReqVO.getId());
|
|
|
+ // 更新
|
|
|
+ PipeTaskOrderSecurityCheckDO updateObj = BeanUtils.toBean(updateReqVO,PipeTaskOrderSecurityCheckDO.class);
|
|
|
+ try {
|
|
|
+ if(StringUtils.isNotBlank(updateReqVO.getJsonData())){
|
|
|
+ Map map = objectMapper.readValue(updateReqVO.getJsonData(), Map.class);
|
|
|
+ Object date = map.get("value15");
|
|
|
+ if(date != null){
|
|
|
+ LocalDateTime localDateTime = parseToLocalDateTime(date.toString());
|
|
|
+ updateObj.setDate(localDateTime);
|
|
|
+ }
|
|
|
+ Object yxDateObj = map.get("value16");
|
|
|
+ if(yxDateObj != null){
|
|
|
+ LocalDateTime localDateTime = parseToLocalDateTime(yxDateObj.toString());
|
|
|
+ updateObj.setValidityDate(localDateTime);
|
|
|
+ }
|
|
|
+ Object checkConclusion = map.get("checkConclusion");
|
|
|
+ if(checkConclusion != null){
|
|
|
+ updateObj.setConclusion(checkConclusion.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析默认模板失败!", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ pipeTaskOrderSecurityCheckMapper.updateById(updateObj);
|
|
|
+ //记录版本信息
|
|
|
+// addVersion(updateReqVO, updateReqVO.getId(), userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将日期字符串解析为 LocalDateTime
|
|
|
+ * 支持格式:
|
|
|
+ * - "2026-05-18" (纯日期格式)
|
|
|
+ * - "2026-05-18 10:30:00" (日期时间格式)
|
|
|
+ * - 其他常见日期格式
|
|
|
+ */
|
|
|
+ private LocalDateTime parseToLocalDateTime(String dateStr) {
|
|
|
+ if (dateStr == null || dateStr.trim().isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 检查是否为OA日期格式 /OADate(xxxxxx)/
|
|
|
+ if (dateStr != null && dateStr.matches("/OADate\\(([^)]+)\\)/")) {
|
|
|
+ try {
|
|
|
+ // 提取括号内的数字
|
|
|
+ String numberStr = dateStr.replaceAll("/OADate\\(([^)]+)\\)/", "$1");
|
|
|
+ double oaDate = Double.parseDouble(numberStr);
|
|
|
+ // 转换为LocalDateTime并格式化为年-月-日
|
|
|
+ return OADateFormat.convertOADateToLocalDateTime(oaDate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("OADATE日期格式转换失败: {}", dateStr, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 尝试直接解析为 LocalDateTime
|
|
|
+ return DateUtil.parseLocalDateTime(dateStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ try {
|
|
|
+ // 如果失败,尝试解析为 Date,然后转换为 LocalDateTime
|
|
|
+ java.util.Date date = DateUtil.parse(dateStr);
|
|
|
+ return DateUtil.toLocalDateTime(date);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("日期字符串解析失败: {}", dateStr, ex);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|