From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-flowable/jnpf-flowable-biz/src/main/java/jnpf/flowable/util/ServiceUtil.java | 541 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 541 insertions(+), 0 deletions(-)
diff --git a/jnpf-flowable/jnpf-flowable-biz/src/main/java/jnpf/flowable/util/ServiceUtil.java b/jnpf-flowable/jnpf-flowable-biz/src/main/java/jnpf/flowable/util/ServiceUtil.java
new file mode 100644
index 0000000..1458fa7
--- /dev/null
+++ b/jnpf-flowable/jnpf-flowable-biz/src/main/java/jnpf/flowable/util/ServiceUtil.java
@@ -0,0 +1,541 @@
+package jnpf.flowable.util;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.google.common.collect.ImmutableList;
+import jnpf.base.entity.AiEntity;
+import jnpf.base.model.flow.FlowStateModel;
+import jnpf.base.*;
+import jnpf.base.entity.DictionaryDataEntity;
+import jnpf.base.entity.SystemEntity;
+import jnpf.base.entity.VisualdevEntity;
+import jnpf.base.model.VisualDevJsonModel;
+import jnpf.base.model.base.SystemApiByIdsModel;
+import jnpf.base.model.flow.DataModel;
+import jnpf.base.model.flow.FlowFormDataModel;
+import jnpf.base.model.schedule.ScheduleNewCrForm;
+import jnpf.base.model.systemconfig.SysConfigModel;
+import jnpf.base.vo.DownloadVO;
+import jnpf.config.ConfigValueUtil;
+import jnpf.constant.*;
+import jnpf.emnus.ModuleTypeEnum;
+import jnpf.emnus.SysParamEnum;
+import jnpf.exception.WorkFlowException;
+import jnpf.file.DocumentApi;
+import jnpf.file.FileApi;
+import jnpf.flowable.entity.TemplateEntity;
+import jnpf.flowable.model.template.TemplateExportModel;
+import jnpf.flowable.model.util.FlowContextHolder;
+import jnpf.flowable.model.util.FlowNature;
+import jnpf.message.SentMessageApi;
+import jnpf.message.model.SentMessageForm;
+import jnpf.model.ExportModel;
+import jnpf.model.document.FlowFileModel;
+import jnpf.onlinedev.VisualdevOnlineApi;
+import jnpf.onlinedev.model.PaginationModel;
+import jnpf.onlinedev.model.VisualParamModel;
+import jnpf.permission.*;
+import jnpf.permission.entity.*;
+import jnpf.permission.model.SystemParamModel;
+import jnpf.permission.model.authorize.AuthorizeVO;
+import jnpf.permission.model.rolerelaiton.RoleRelationModel;
+import jnpf.permission.model.sign.SignForm;
+import jnpf.permission.model.user.UserModel;
+import jnpf.util.StringUtil;
+import jnpf.util.enums.DictionaryDataEnum;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static jnpf.util.Constants.ADMIN_KEY;
+
+@Component
+@RequiredArgsConstructor
+public class ServiceUtil {
+
+ private final DictionaryDataApi dictionaryDataApi;
+
+ private final UserRelationApi userRelationApi;
+
+ private final UserApi userApi;
+
+ private final RoleApi roleApi;
+
+ private final RoleRelationApi roleRelationApi;
+
+ private final OrganizeApi organizeApi;
+
+ private final PositionApi positionApi;
+
+ private final CodeNumApi codeNumApi;
+
+ private final DataInterFaceApi dataInterFaceApi;
+
+ private final SentMessageApi sentMessageApi;
+
+ private final FileApi fileExport;
+
+ private final ConfigValueUtil configValueUtil;
+
+ private final UserSettingApi signApi;
+
+ private final AiApi aiApi;
+
+ private final AuthorizeApi authorizeApi;
+
+ private final VisualdevOnlineApi visualdevApi;
+
+ private final DocumentApi documentApi;
+
+ private final BillRuleApi billRuleApi;
+
+ private final SysConfigApi systemConfigApi;
+
+ private final SystemApi systemApi;
+
+ private final ScheduleNewApi scheduleNewApi;
+
+ // 鍒涘缓鏃ョ▼
+ public void createSchedule(ScheduleNewCrForm fo) throws WorkFlowException {
+ ActionResult<Object> result = scheduleNewApi.create(fo);
+ if (result.getCode() != 200) {
+ throw new WorkFlowException(result.getMsg());
+ }
+ }
+
+ // 鑾峰彇绯荤粺閰嶇疆
+ public SysConfigModel getSysConfig() {
+ ActionResult<SysConfigModel> actionResult = systemConfigApi.list();
+ return actionResult.getData();
+ }
+
+ // 鑾峰彇绯荤粺閰嶇疆锛屾祦绋嬬鏀�
+ public Boolean getFlowSign() {
+ ActionResult<SysConfigModel> actionResult = systemConfigApi.list();
+ SysConfigModel data = actionResult.getData();
+ return data.getFlowSign() == 0;
+ }
+
+ // 鑾峰彇绯荤粺閰嶇疆锛屾祦绋嬪姙鐞�
+ public Boolean getFlowTodo() {
+ ActionResult<SysConfigModel> actionResult = systemConfigApi.list();
+ SysConfigModel data = actionResult.getData();
+ return data.getFlowTodo() == 0;
+ }
+
+ // 娴佹按鍙�
+ public String getBillNumber() {
+ return billRuleApi.getBillNumber(FlowNature.REVOKE_BILL_CODE).getData();
+ }
+
+ // -------------------------------绛惧悕-----------------------------
+ public void updateSign(String signId, String signImg) {
+ SignEntity signEntity = signApi.getSignInfo(signId);
+ if (null != signEntity) {
+ signApi.uptateDefault(signId);
+ } else {
+ SignForm signForm = new SignForm();
+ signForm.setIsDefault(1);
+ signForm.setSignImg(signImg);
+ signApi.create(signForm);
+ }
+ }
+
+ // -------------------------------娴佺▼缂栫爜-----------------------------
+ public String getCode() {
+ return codeNumApi.getCodeOnce(CodeConst.LC);
+ }
+
+ // -------------------------------甯哥敤璇�-----------------------------
+ public void addCommonWordsNum(String handleOpinion) {
+ systemApi.addCommonWordsNum(handleOpinion);
+ }
+
+ // -------------------------------鏂囦欢-----------------------------
+ // 鍒ゆ柇鏄惁瀛樺湪褰掓。鏂囦欢锛屼笉瀛樺湪涓簍rue
+ public Boolean checkFlowFile(String taskId) {
+ return documentApi.checkFlowFile(taskId);
+ }
+
+ // 鑾峰彇褰掓。鏂囦欢
+ public List<Map<String, Object>> getFlowFile(FlowFileModel model) {
+ return documentApi.getFlowFile(model);
+ }
+
+ // -------------------------------娴佺▼鍏ㄩ儴鏉冮檺-----------------------------
+ public List<String> getPermission(String userId) {
+ return getPermission(userId, AuthorizeConst.FLOW);
+ }
+
+ public List<String> getPermission(String userId, String itmeType) {
+ List<String> userIdList = ImmutableList.of(userId);
+ List<String> objectIdList = new ArrayList<>();
+ List<String> posId = getListByUserIdAll(userIdList).stream().filter(e -> Objects.equals(PermissionConst.POSITION, e.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
+ objectIdList.addAll(posId);
+ List<String> roleId = getRoleObjectId(userIdList).stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList());
+ objectIdList.addAll(roleId);
+ List<String> resList = new ArrayList<>();
+ if (!objectIdList.isEmpty()) {
+ resList = getAuthorizeObjectId(objectIdList).stream().filter(e -> e.getItemType().equals(itmeType)).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
+ }
+ return resList;
+ }
+
+ // -------------------------------鍙戣捣鏉冮檺-----------------------------
+ public List<String> getLaunchPermission() {
+ AuthorizeVO authorizeByUser = getAuthorizeByUser();
+ return authorizeByUser.getFlowIdList();
+ }
+
+ // true鏄櫘閫氱敤鎴�
+ public boolean isCommonUser(String userId) {
+ UserEntity userInfo = getUserInfo(userId);
+ return userInfo == null || !Objects.equals(userInfo.getAccount(), ADMIN_KEY);
+ }
+
+ // 鑾峰彇娴佺▼鏈夊彂璧锋潈闄愮殑浜哄憳
+ public List<UserEntity> getLaunchUserByTemplateId(TemplateEntity template, Pagination pagination) {
+ if (ObjectUtil.equals(template.getVisibleType(), FlowNature.ALL)) {
+ // 鍏紑鐩存帴杩斿洖鐢ㄦ埛鍒嗛〉
+ return userApi.getUserPage(pagination);
+ }
+ // 鏍规嵁娴佺▼涓婚敭銆佹潈闄愪负娴佺▼绫诲瀷 鑾峰彇鏉冮檺鍏宠仈
+ List<String> userIdList = new ArrayList<>();
+ List<AuthorizeEntity> authorizeList = getListByObjectAndItemIdAndType(template.getId()).stream().filter(e -> !Objects.equals(PermissionConst.ORGANIZE, e.getObjectType())).collect(Collectors.toList());
+ for (AuthorizeEntity entity : authorizeList) {
+ String objectType = PermissionConst.POSITION.equals(entity.getObjectType()) ? SysParamEnum.POS.getCode() : SysParamEnum.ROLE.getCode();
+ userIdList.add(entity.getObjectId() + "--" + objectType);
+ }
+ List<String> userListAll = this.getUserListAll(userIdList);
+ return this.getUserName(userListAll, pagination);
+ }
+
+ //--------------------------------琛ㄥ崟------------------------------
+ public VisualdevEntity getFormInfo(String id) {
+ return visualdevApi.getFormConfig(id);
+ }
+
+ public List<VisualdevEntity> getFormList(List<String> formIds) {
+ if (formIds.isEmpty()) {
+ return new ArrayList<>();
+ }
+ return visualdevApi.getFormConfigList(formIds);
+ }
+
+ public void saveOrUpdateFormData(FlowFormDataModel model) throws WorkFlowException {
+ ActionResult<Object> actionResult = visualdevApi.saveOrUpdate(model);
+ if (actionResult.getCode() != 200) {
+ throw new WorkFlowException(actionResult.getMsg());
+ }
+ }
+
+ public void deleteFormData(String formId, String id) {
+ if (StringUtils.isBlank(formId) || StringUtils.isBlank(id)) {
+ return;
+ }
+ try {
+ visualdevApi.delete(formId, id);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Map<String, Object> infoData(String formId, String id) {
+ // 娴佺▼璋冪敤琛ㄥ崟鎺ュ彛
+ Map<String, Object> dataAll = new HashMap<>();
+ if (StringUtils.isNotEmpty(formId) && StringUtils.isNotEmpty(id)) {
+ ActionResult<Object> result = visualdevApi.info(formId, id);
+ if (null != result && null != result.getData()) {
+ dataAll = (Map<String, Object>) result.getData();
+ }
+ }
+ return dataAll;
+ }
+
+ public void handleFormData(String flowId, Boolean isTransfer) throws WorkFlowException {
+ try {
+ Map<String, Map<String, Object>> allData = FlowContextHolder.getAllData();
+ Map<String, List<Map<String, Object>>> formOperates = FlowContextHolder.getFormOperates();
+ List<String> writeIdList = FlowContextHolder.getWriteIdList();
+ for (String key : writeIdList) {
+ String[] idList = key.split(JnpfConst.SIDE_MARK);
+ List<Map<String, Object>> operates = formOperates.get(key);
+ Map<String, Object> formData = allData.get(key);
+ formData = formData == null ? new HashMap<>() : formData;
+ FlowFormDataModel formDataModel = FlowFormDataModel.builder().formId(idList[1]).id(idList[0]).map(formData).formOperates(operates)
+ .flowId(flowId).isTransfer(isTransfer).build();
+ this.saveOrUpdateFormData(formDataModel);
+ }
+ } finally {
+ FlowContextHolder.clearAll();
+ }
+ }
+
+ public List<Map<String, Object>> getListWithTableList(VisualDevJsonModel visualDevJsonModel, PaginationModel pagination, UserInfo userInfo) {
+ VisualParamModel visualParamModel = VisualParamModel.builder().visualDevJsonModel(visualDevJsonModel).pagination(pagination).userInfo(userInfo).build();
+ return visualdevApi.getListWithTableList(visualParamModel);
+ }
+
+ public VisualdevEntity getReleaseInfo(String formId) {
+ return visualdevApi.getReleaseInfo(formId);
+ }
+
+ public DataModel visualCreate(VisualdevEntity visualdevEntity, Map<String, Object> data) throws WorkFlowException {
+ VisualParamModel visualParamModel = VisualParamModel.builder().visualdevEntity(visualdevEntity).data(data).build();
+ ActionResult<Object> result = visualdevApi.visualCreate(visualParamModel);
+ if (null == result) {
+ throw new WorkFlowException(MsgCode.SYS122.getCode());
+ }
+ if (!ObjectUtil.equals(result.getCode(), 200)) {
+ throw new WorkFlowException(result.getMsg());
+ }
+ if (result.getData() instanceof DataModel) {
+ return (DataModel) result.getData();
+ }
+ return null;
+ }
+
+ public DataModel visualUpdate(VisualdevEntity visualdevEntity, Map<String, Object> data, String id) throws WorkFlowException {
+ VisualParamModel visualParamModel = VisualParamModel.builder().visualdevEntity(visualdevEntity).data(data).id(id).onlyUpdate(true).build();
+ ActionResult<Object> result = visualdevApi.visualUpdate(visualParamModel);
+ if (null == result) {
+ throw new WorkFlowException(MsgCode.SYS122.get());
+ }
+ if (!ObjectUtil.equals(result.getCode(), 200)) {
+ throw new WorkFlowException(result.getMsg());
+ }
+ if (result.getData() instanceof DataModel) {
+ return (DataModel) result.getData();
+ }
+ return null;
+ }
+
+ public void visualDelete(VisualdevEntity visualdevEntity, List<Map<String, Object>> dataList) throws WorkFlowException {
+ VisualParamModel visualParamModel = VisualParamModel.builder().visualdevEntity(visualdevEntity).dataList(dataList).build();
+ ActionResult<Object> result = visualdevApi.visualDelete(visualParamModel);
+ if (null == result) {
+ throw new WorkFlowException(MsgCode.SYS122.get());
+ }
+ if (!ObjectUtil.equals(result.getCode(), 200)) {
+ throw new WorkFlowException(result.getMsg());
+ }
+ }
+
+ public void deleteSubTable(FlowFormDataModel model) throws WorkFlowException {
+ ActionResult<Object> result = visualdevApi.deleteByTableName(model);
+ if (null == result) {
+ throw new WorkFlowException(MsgCode.SYS122.get());
+ }
+ if (!ObjectUtil.equals(result.getCode(), 200)) {
+ throw new WorkFlowException(result.getMsg());
+ }
+ }
+
+ public void saveState(FlowStateModel stateModel){
+ visualdevApi.saveState(stateModel);
+ }
+
+ //--------------------------------鏁版嵁瀛楀吀------------------------------
+ public List<DictionaryDataEntity> getDiList() {
+ ActionResult<List<DictionaryDataEntity>> result = dictionaryDataApi.getListByTypeDataCode(DictionaryDataEnum.BUSINESSTYPE.getDictionaryTypeId());
+ List<DictionaryDataEntity> dictionList = new ArrayList<>();
+ if (result.getData() != null) {
+ dictionList.addAll(result.getData());
+ }
+ return dictionList;
+ }
+
+ public List<DictionaryDataEntity> getDictionName(List<String> id) {
+ return dictionaryDataApi.getDictionName(id);
+ }
+
+ //--------------------------------鐢ㄦ埛鍏崇郴琛�------------------------------
+ public List<UserRelationEntity> getListByUserIdAll(List<String> id) {
+ return userRelationApi.getListByUserIdAll(id).stream().filter(t -> StringUtils.isNotEmpty(t.getObjectId())).collect(Collectors.toList());
+ }
+
+ public List<UserRelationEntity> getListByObjectIdAll(List<String> id) {
+ return userRelationApi.getListByObjectIdAll(id);
+ }
+
+ //--------------------------------鐢ㄦ埛鏉冮檺------------------------------
+
+ public List<AuthorizeEntity> getAuthorizeObjectId(List<String> objectIdList) {
+ return authorizeApi.getListByObjectId(objectIdList);
+ }
+
+ public List<AuthorizeEntity> getListByObjectAndItemIdAndType(String templateId) {
+ return authorizeApi.getListByObjectAndItemIdAndType(templateId, AuthorizeConst.FLOW);
+ }
+
+ public AuthorizeVO getAuthorizeByUser() {
+ return authorizeApi.getAuthorizeByUser(false);
+ }
+
+ //--------------------------------鐢ㄦ埛------------------------------
+
+ public String getAdmin() {
+ UserEntity admin = userApi.getInfoByAccount(ADMIN_KEY);
+ return admin.getId();
+ }
+
+ public List<UserEntity> getUserByAccount(List<String> accountList) {
+ List<UserEntity> list = new ArrayList<>();
+ if (CollUtil.isEmpty(accountList)) {
+ return list;
+ }
+ for (String account : accountList) {
+ UserEntity user = userApi.getInfoByAccount(account);
+ if (null != user) {
+ list.add(user);
+ }
+ }
+ return list;
+ }
+
+ public List<UserEntity> getUserName(List<String> id) {
+ return getUserName(id, false);
+ }
+
+ public List<UserEntity> getUserName(List<String> id, boolean enableMark) {
+ List<UserEntity> list = userApi.getUserName(id);
+ if (enableMark) list = list.stream().filter(t -> t.getEnabledMark() != 0).collect(Collectors.toList());
+ return list;
+ }
+
+ public List<UserEntity> getUserName(List<String> id, Pagination pagination) {
+ UserModel userModel = new UserModel();
+ userModel.setId(id);
+ userModel.setPagination(pagination);
+ return userApi.getUserNamePagination(userModel);
+ }
+
+ public UserEntity getUserInfo(String id) {
+ UserEntity entity = null;
+ if (StringUtils.isNotEmpty(id)) {
+ entity = id.equalsIgnoreCase(ADMIN_KEY) ? userApi.getInfoByAccount(id) : userApi.getInfoById(id);
+ }
+ return entity;
+ }
+
+ public List<String> getUserListAll(List<String> idList) {
+ return userApi.getUserIdList(idList);
+ }
+
+ //--------------------------------瑙掕壊鍏崇郴琛�------------------------------
+
+ public List<RoleRelationEntity> getListByRoleId(List<String> roleIdList) {
+ return roleRelationApi.getListByRoleId(new RoleRelationModel(new ArrayList<>(), PermissionConst.USER, roleIdList));
+ }
+
+ public List<RoleRelationEntity> getRoleObjectId(List<String> userId) {
+ return roleRelationApi.getListByObjectId(new RoleRelationModel(userId, PermissionConst.USER));
+ }
+
+ //--------------------------------瑙掕壊------------------------------
+ public List<RoleEntity> getRoleList(List<String> id) {
+ return roleApi.getListByIds(id);
+ }
+
+
+ //--------------------------------缁勭粐------------------------------
+
+ public OrganizeEntity getOrganizeInfo(String id) {
+ return StringUtils.isNotEmpty(id) ? organizeApi.getInfoById(id) : null;
+ }
+
+ public List<OrganizeEntity> getDepartmentAll(String organizeId) {
+ return organizeApi.getOrganizeDepartmentAll(organizeId);
+ }
+
+ public List<OrganizeEntity> getOrganizeList(List<String> idList) {
+ return organizeApi.getListByIds(idList);
+ }
+
+ //--------------------------------宀椾綅------------------------------
+
+ public PositionEntity getPositionInfo(String id) {
+ return StringUtils.isNotEmpty(id) ? positionApi.queryInfoById(id) : null;
+ }
+
+ public List<PositionEntity> getChildPosition(String id) {
+ return StringUtils.isNotEmpty(id) ? positionApi.getAllChild(id) : new ArrayList<>();
+ }
+
+ public List<PositionEntity> getListByOrgIds(List<String> orgIds) {
+ return positionApi.getListByOrgIds(orgIds);
+ }
+
+ public List<PositionEntity> getPosList(List<String> idList) {
+ return positionApi.getListByIds(idList);
+ }
+
+ //--------------------------------杩滅------------------------------
+ public ActionResult<Object> infoToId(String interId, Map<String, String> parameterMap) {
+ return dataInterFaceApi.infoToIdById(interId, parameterMap);
+ }
+
+ public Map<String, String> getSystemFieldValue() {
+ return userApi.getSystemFieldValue(new SystemParamModel());
+ }
+
+ //--------------------------------搴旂敤------------------------------
+
+ public String getSystemCodeById(String systemCode) {
+ List<String> systemIdList = ImmutableList.of(JnpfConst.MAIN_SYSTEM_CODE, JnpfConst.WORK_FLOW_CODE);
+ String systemId = JnpfConst.MAIN_SYSTEM_CODE;
+ if (StringUtil.isEmpty(systemCode)) {
+ return systemId;
+ }
+ if (systemIdList.contains(systemCode)) {
+ return "";
+ }
+ SystemEntity entity = getInfoByEnCode(systemCode);
+ if (entity != null) {
+ systemId = entity.getId();
+ }
+ return systemId;
+ }
+
+ public SystemEntity getInfoByEnCode(String systemCode) {
+ return systemApi.getInfoByEnCode(systemCode);
+ }
+
+ public List<SystemEntity> getSystemList(List<String> idList) {
+ SystemApiByIdsModel model = new SystemApiByIdsModel(idList, new ArrayList<>(), 0);
+ return systemApi.getListByIds(model);
+ }
+
+ //--------------------------------鍙戦�佹秷鎭�------------------------------
+ public void sendMessage(List<SentMessageForm> messageListAll) {
+ for (SentMessageForm messageForm : messageListAll) {
+ if (messageForm.isSysMessage()) {
+ sentMessageApi.sendMessage(messageForm);
+ }
+ }
+ }
+
+ public List<String> sendDelegateMsg(List<SentMessageForm> messageListAll) {
+ List<String> list = new ArrayList<>();
+ for (SentMessageForm messageForm : messageListAll) {
+ List<String> errList = sentMessageApi.sendScheduleMessage(messageForm);
+ list.addAll(errList);
+ }
+ return list;
+ }
+
+ //--------------------------------Ai------------------------------
+ public AiEntity getDefault() {
+ return aiApi.getDefault();
+ }
+
+ //------------------------------瀵煎嚭-------------------------------
+ public DownloadVO exportData(TemplateExportModel model) {
+ return fileExport.exportFile(new ExportModel(model, FileTypeConstant.TEMPORARY,
+ configValueUtil.getTemporaryFilePath(), model.getTemplate().getFullName(), ModuleTypeEnum.FLOW_FLOWENGINE.getTableName()));
+ }
+}
--
Gitblit v1.8.0