From 5440bc84b144bd23d1ad945b873d9731d14b077a Mon Sep 17 00:00:00 2001 From: yjz <3131811435@qq.com> Date: Thu, 8 Aug 2024 16:17:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=A7=A3=E8=AF=BB=E6=B5=81=E7=A8=8B):=20?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E8=8A=82=E7=82=B9=E5=AD=97=E6=AE=B5=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StandardInterpretFlowServiceImpl.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java index b3d03595..327168a8 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java @@ -8,11 +8,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.base.CaseFormat; import com.jero.common.api.SendMessageAPI; import com.jero.common.api.dto.message.SendMessageDTO; import com.jero.common.api.vo.Result; import com.jero.common.api.vo.ResultCommon; import com.jero.common.constant.CommonConstant; +import com.jero.common.constant.enums.LanguageEnum; import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.exception.JeroBootException; import com.jero.common.system.base.controller.JeroController; @@ -64,6 +66,8 @@ import com.jero.modules.split.service.ISarFileSplitInfoService; import com.jero.modules.system.entity.SysDepart; import com.jero.modules.system.service.ISysDepartService; import com.jero.modules.system.service.ISysDictService; +import com.jero.modules.tag.entity.LawsTag; +import com.jero.modules.tag.service.ILawsTagService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.activiti.engine.ManagementService; @@ -91,6 +95,7 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -134,6 +139,7 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe private final ILawsStandardMasterPlanService lawsStandardMasterPlanService; private final ProcessStandardInterpretMapper processStandardInterpretMapper; private final SendMessageAPI sendMessageAPI; + private final ILawsTagService lawsTagService; private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); private final List tempList = new ArrayList<>(); @@ -547,6 +553,43 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe log.info("标准解读流程-流程监听器 结束"); } + private void checkLength(ProcessStandardInterpretClauseSublist clauseSublist, int i) { + List tagList = lawsTagService.list( + new LambdaQueryWrapper() + .eq(LawsTag::getTableName, "laws_document_split") + .eq(LawsTag::getIsShowList, YesOrNoEnum.YES.getValue()) + .ne(LawsTag::getDbFieldName, "is_same_as_prev_version")); + // 反射获取字段名称 + Field[] fields = clauseSublist.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + String name = field.getName(); + // 驼峰转下划线 + String finalName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); + Optional optionalLawsTag = tagList.stream() + .filter(tag -> tag.getDbFieldName().equals(finalName)).findFirst(); + optionalLawsTag.ifPresent(v -> { + String value = null; + try { + value = (String) field.get(clauseSublist); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + if (StringUtils.isNotBlank(value)) { + if (value.length() > v.getDbLength()) { + if(LanguageEnum.CN.equals(MessageUtils.getLanguage())) { + throw new JeroBootException("第" + (i + 1) + "行: 字段 " + + v.getDbFieldTxt() + "长度不能超过" + v.getDbLength() + "
"); + }else { + throw new JeroBootException("Line " + (i + 1) + ": The field " + + v.getDbFieldName() + "length shall not exceed" + v.getDbFieldEnName() + "
"); + } + } + } + }); + } + } + private void distinct(ProcessStandardInterpretClauseSublist data) { data.setPartName(toDistinct(data.getPartName())); data.setKeyController(toDistinct(data.getKeyController())); @@ -1625,6 +1668,9 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe break; // 标准主解读汇总(分发) case StandardInterpretCommon.MASTER_INTERPRET_SUMMARY: + for (int i = 0; i < processStandardInterpretClauseSublistList.size(); i++) { + checkLength(processStandardInterpretClauseSublistList.get(i), i); + } // 保存会签人员、审核人员、批准人员 processStandardInterpretService.updateById(processStandardInterpret); map.put(StandardInterpretCommon.JOINTLY_SIGN_LIST,