From 391eec3114a17e68652434c6eae610799d80290e Mon Sep 17 00:00:00 2001 From: ludc <ludc@vci-tech.com> Date: 星期四, 16 一月 2025 11:13:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebFlowServiceImpl.java | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebFlowServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebFlowServiceImpl.java new file mode 100644 index 0000000..6ca01fb --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebFlowServiceImpl.java @@ -0,0 +1,142 @@ +package com.vci.web.service.impl; + +import com.vci.corba.common.PLException; +import com.vci.corba.wf.data.ProcessCategoryInfo; +import com.vci.corba.wf.data.ProcessDefinitionInfo; +import com.vci.starter.web.exception.VciBaseException; +import com.vci.starter.web.pagemodel.BaseQueryObject; +import com.vci.starter.web.pagemodel.DataGrid; +import com.vci.starter.web.util.Lcm.Func; +import com.vci.starter.web.util.VciBaseUtil; +import com.vci.web.dao.WebProcessDaoI; +import com.vci.web.service.WebFlowServiceI; +import com.vci.web.util.PlatformClientUtil; +import com.vci.web.util.WebUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 娴佺▼鏈嶅姟 + * @author ludc + * @date 2025/1/14 17:28 + */ +@Service +public class WebFlowServiceImpl implements WebFlowServiceI { + + /** + * 骞冲彴璋冪敤瀹㈡埛绔� + */ + @Autowired + private PlatformClientUtil platformClientUtil; + + @Autowired + private WebProcessDaoI webProcessDaoI; + + /** + * 娴佺▼鍒嗙被鍏ㄦ煡璇� + * @param parentId + * @return + * @throws PLException + */ + @Override + public List<ProcessCategoryInfo> getProcessCategories(String parentId) throws PLException { + VciBaseUtil.alertNotNull(parentId,"娴佺▼鍒嗙被鐖朵富閿�"); + ProcessCategoryInfo[] processCategories = platformClientUtil.getWFService().getProcessCategories(parentId); + List<ProcessCategoryInfo> processCategoryInfoList = Arrays.asList(processCategories).stream().sorted((Comparator.comparing(o -> o.id))).collect(Collectors.toList()); + return processCategoryInfoList; + } + + /** + * 娴佺▼鍒嗙被鍒嗛〉鏌ヨ + * @param baseQueryObject + * @return + */ + @Override + public DataGrid<ProcessCategoryInfo> getProcessCategoriesByPage(BaseQueryObject baseQueryObject) throws PLException { + String parentId = baseQueryObject.getConditionMap().get("parentId"); + VciBaseUtil.alertNotNull(parentId,"娴佺▼鍒嗙被鐖朵富閿�"); + int page = baseQueryObject.getPage(); + int limit = baseQueryObject.getLimit(); + ProcessCategoryInfo[] processCategories = platformClientUtil.getWFService().getProcessCategoriesByPage(parentId,limit,page); + List<ProcessCategoryInfo> processCategoryInfoList = Arrays.asList(processCategories).stream().sorted((Comparator.comparing(o -> o.id))).collect(Collectors.toList()); + DataGrid<ProcessCategoryInfo> dataGrid = new DataGrid<>(); + dataGrid.setData(processCategoryInfoList); + dataGrid.setPage(page); + dataGrid.setLimit(limit); + //dataGrid.setTotal(); + return dataGrid; + } + + /** + * 淇濆瓨娴佺▼鍒嗙被 + * @param category + * @return 杩斿洖涓婚敭 + */ + @Override + public String saveProcessCategory(ProcessCategoryInfo category) throws PLException { + VciBaseUtil.alertNotNull(category,"娴佺▼鍒嗙被瀵硅薄",category.name,"娴佺▼鍒嗙被鍚嶇О"); + this.checkNameExisted(category); + if(Func.isBlank(category.parentId)){ + category.parentId = "root"; + } + long time = new Date().getTime(); + String userId = WebUtil.getCurrentUserId(); + category.createTime = time; + category.modifyTime = time; + category.creator = userId; + category.modifer = userId; + return platformClientUtil.getWFService().saveProcessCategory(category); + } + + /** + * 淇敼娴佺▼鍒嗙被 + * @param category + * @return + */ + @Override + public boolean updateProcessCategory(ProcessCategoryInfo category) throws PLException { + VciBaseUtil.alertNotNull(category,"娴佺▼鍒嗙被瀵硅薄",category.name,"娴佺▼鍒嗙被鍚嶇О"); + if(Func.isBlank(category.parentId)){ + category.parentId = "root"; + } + this.checkNameExisted(category); + category.modifyTime = new Date().getTime(); + category.modifer = WebUtil.getCurrentUserId(); + return platformClientUtil.getWFService().updateProcessCategory(category); + } + + /** + * 鍒犻櫎娴佺▼鍒嗙被 + * @param id + * @return + * @throws Exception + */ + @Override + public boolean deleteProcessCategory(String id) throws Exception { + VciBaseUtil.alertNotNull(id,"寰呭垹闄ゆ祦绋嬪垎绫荤殑涓婚敭"); + ProcessDefinitionInfo[] processDefinitions = platformClientUtil.getWFService().getProcessDefinitions(id); + if(processDefinitions.length>0){ + new VciBaseException( "鍒嗙被涓嬫湁妯℃澘锛岃鍏堝垹闄ゆā鐗堬紒"); + } + return platformClientUtil.getWFService().deleteProcessCategory(id); + } + + /** + * 鏍规嵁涓婚敭鍜屽悕绉版煡璇㈡祦绋嬪垎绫绘槸鍚﹀瓨鍦� + * @param category + * @return + */ + private void checkNameExisted(ProcessCategoryInfo category) throws PLException{ + //鍒ゆ柇鏄惁瀛樺湪鐩稿悓鍚嶇О鐨勬ā鏉垮垎绫� + if(platformClientUtil.getWFService().existProcessCategory(category.id, category.name)){ + throw new VciBaseException("妯℃澘鍒嗙被鐨勫悕绉颁笉鑳介噸澶嶏紒"); + } + } + +} -- Gitblit v1.9.3