¶Ô±ÈÐÂÎļþ |
| | |
| | | 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("模æ¿åç±»çåç§°ä¸è½éå¤ï¼"); |
| | | } |
| | | } |
| | | |
| | | } |