diff --git a/hh-admin/src/main/java/com/hh/test/domain/TestTree.java b/hh-admin/src/main/java/com/hh/test/domain/TestTree.java index 8ae11568d5ed82ac2363e62db1935c61da9fa7d1..7c15eec6553a4d7bfb5f8d2900ca4c2c741730e5 100644 --- a/hh-admin/src/main/java/com/hh/test/domain/TestTree.java +++ b/hh-admin/src/main/java/com/hh/test/domain/TestTree.java @@ -27,7 +27,7 @@ public class TestTree extends TreeEntity @Excel(name = "版本") private Long version; - /** 删除标志 */ - private Long delFlag; + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; } diff --git a/hh-admin/src/main/java/com/hh/test/mapper/TestMaterMapper.java b/hh-admin/src/main/java/com/hh/test/mapper/TestMaterMapper.java index 21440b77e8fcada1291e2d8c0507da53ba948fb2..37c8325a61129698f0e7f223a6f8b86c8971d226 100644 --- a/hh-admin/src/main/java/com/hh/test/mapper/TestMaterMapper.java +++ b/hh-admin/src/main/java/com/hh/test/mapper/TestMaterMapper.java @@ -2,14 +2,43 @@ package com.hh.test.mapper; import com.hh.mybatis.mapper.BaseMapper; import com.hh.test.domain.TestMater; +import com.hh.test.domain.TestSub; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; /** * 主子演示Mapper接口 * * @author hh - * @date 2023-04-07 + * @date 2023-04-13 */ public interface TestMaterMapper extends BaseMapper { + /** + * 批量删除子 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteTestSubByLegalIds(Collection ids); + + /** + * 批量新增子 + * + * @param testSubList 子列表 + * @return 结果 + */ + public int batchTestSub(List testSubList); + + + /** + * 通过主子演示主键删除子信息 + * + * @param id 主子演示ID + * @return 结果 + */ + public int deleteTestSubByLegalId(Serializable id); } diff --git a/hh-admin/src/main/java/com/hh/test/service/impl/TestMaterServiceImpl.java b/hh-admin/src/main/java/com/hh/test/service/impl/TestMaterServiceImpl.java index 884d369600c9e753e28868789df4403ef14f28ae..0ba64e2dfa6ff708b0ced6aca5bb71e7cdf1a3b0 100644 --- a/hh-admin/src/main/java/com/hh/test/service/impl/TestMaterServiceImpl.java +++ b/hh-admin/src/main/java/com/hh/test/service/impl/TestMaterServiceImpl.java @@ -1,19 +1,29 @@ package com.hh.test.service.impl; +import cn.hutool.core.util.ObjectUtil; +import com.hh.common.utils.DateUtils; +import com.hh.common.utils.StringUtils; import com.hh.mybatis.service.impl.BaseServiceImpl; +import com.hh.security.utils.SecurityUtils; import org.springframework.stereotype.Service; import com.hh.test.domain.TestSub; import com.hh.test.mapper.TestMaterMapper; import com.hh.test.domain.TestMater; import com.hh.test.service.ITestMaterService; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; /** * 主子演示Service业务层处理 * * @author hh - * @date 2023-04-07 + * @date 2023-04-13 */ @Service public class TestMaterServiceImpl extends BaseServiceImpl implements ITestMaterService @@ -25,4 +35,96 @@ public class TestMaterServiceImpl extends BaseServiceImpl implements public TestMaterMapper getBaseMapper() { return testMaterMapper; } + + /** + * 新增主子演示 + * + * @param testMater 主子演示 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int insert(TestMater testMater) + { + int rows = super.insert(testMater); + insertTestSub(testMater); + return rows; + } + + /** + * 修改主子演示 + * + * @param testMater 主子演示 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int updateById(TestMater testMater) + { + testMaterMapper.deleteTestSubByLegalId(testMater.getId()); + insertTestSub(testMater); + return super.updateById(testMater); + } + + /** + * 批量删除主子演示 + * + * @param ids 需要删除的主子演示主键 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int deleteByIds(Collection ids) + { + testMaterMapper.deleteTestSubByLegalIds(ids); + return super.deleteByIds(ids); + } + + /** + * 删除主子演示信息 + * + * @param id 主子演示主键 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int deleteById(Serializable id) + { + testMaterMapper.deleteTestSubByLegalId(id); + return super.deleteById(id); + } + + /** + * 新增子信息 + * + * @param testMater 主子演示对象 + */ + private void insertTestSub(TestMater testMater) + { + List testSubList = testMater.getTestSubList(); + Long id = testMater.getId(); + if (StringUtils.isNotNull(testSubList)) + { + List list = new ArrayList<>(); + for (TestSub testSub : testSubList) + { + Date date = ObjectUtil.isNotNull(testSub.getCreateTime()) + ? testSub.getCreateTime() : DateUtils.getNowDate(); + String username = StringUtils.isNotBlank(testSub.getCreateBy()) + ? testSub.getCreateBy() : SecurityUtils.getUsernameNe(); + + testSub.setLegalId(id); + testSub.setCreateTime(date); + testSub.setUpdateTime(date); + testSub.setCreateBy(username); + testSub.setUpdateBy(username); + testSub.setDelFlag("0"); + list.add(testSub); + } + if (list.size() > 0) + { + testMaterMapper.batchTestSub(list); + } + } + } } diff --git a/hh-admin/src/main/resources/application.yml b/hh-admin/src/main/resources/application.yml index 7fba974b49173eede16c6e9ba0299e18f0f5baf9..770d0790d0122e3712987507914198f76c318fcb 100644 --- a/hh-admin/src/main/resources/application.yml +++ b/hh-admin/src/main/resources/application.yml @@ -93,6 +93,7 @@ mybatis: # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml + # PageHelper分页插件 pagehelper: helperDialect: mysql diff --git a/hh-admin/src/main/resources/i18n/messages.properties b/hh-admin/src/main/resources/i18n/messages.properties index f561d733c7a501b330293fe803edf1f3d6ddf9a8..d75fbe3d2a56678c682592f147efe452c65ba21a 100644 --- a/hh-admin/src/main/resources/i18n/messages.properties +++ b/hh-admin/src/main/resources/i18n/messages.properties @@ -42,6 +42,7 @@ no.view.permission=\u60A8\u6CA1\u6709\u67E5\u770B\u6570\u636E\u7684\u6743\u9650\ controller.page=\u5206\u9875\u67E5\u8BE2\u5931\u8D25 controller.list=\u67E5\u8BE2\u5217\u8868\u5931\u8D25 controller.add=\u65B0\u589E\u5931\u8D25 +controller.save=\u4FDD\u5B58\u5931\u8D25 controller.update=\u66F4\u65B0\u5931\u8D25 controller.delete=\u5220\u9664\u5931\u8D25 controller.export=\u5BFC\u51FA\u5931\u8D25 diff --git a/hh-admin/src/main/resources/mapper/test/TestCommonMapper.xml b/hh-admin/src/main/resources/mapper/test/TestCommonMapper.xml index a1c0e74b958b690990b88c6a5d866e624adab849..fbb3a26ff10160c30604fe26ab7229f00fb1c70e 100644 --- a/hh-admin/src/main/resources/mapper/test/TestCommonMapper.xml +++ b/hh-admin/src/main/resources/mapper/test/TestCommonMapper.xml @@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update test_common create_by = #{createBy}, @@ -120,6 +120,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update test_common + + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + title = #{title}, + level = #{level}, + send_doc_no = #{sendDocNo}, + send_doc_unit = #{sendDocUnit}, + publish_time = #{publishTime}, + deadline = #{deadline}, + label = #{label}, + content = #{content}, + money = #{money}, + views = #{views}, + newfileId = #{newfileId}, + imageId = #{imageId}, + + + delete from test_common where id = #{id} diff --git a/hh-admin/src/main/resources/mapper/test/TestLeaveMapper.xml b/hh-admin/src/main/resources/mapper/test/TestLeaveMapper.xml index 2af98dc2fbc562c7e9da69b8824c3e2312d717f2..dc16935bf5bfa517ac7d38f8c7f46312708fa933 100644 --- a/hh-admin/src/main/resources/mapper/test/TestLeaveMapper.xml +++ b/hh-admin/src/main/resources/mapper/test/TestLeaveMapper.xml @@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update test_leave type = #{type}, @@ -93,6 +93,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update test_leave + + type = #{type}, + reason = #{reason}, + start_time = #{startTime}, + end_time = #{endTime}, + day = #{day}, + instance_id = #{instanceId}, + flow_status = #{flowStatus}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + + delete from test_leave where id = #{id} diff --git a/hh-admin/src/main/resources/mapper/test/TestMaterMapper.xml b/hh-admin/src/main/resources/mapper/test/TestMaterMapper.xml index 650ff1168f06d8cc7c4a944919389e8b77118476..b6e788e1e779c39cdbb5029822ab788ac4573850 100644 --- a/hh-admin/src/main/resources/mapper/test/TestMaterMapper.xml +++ b/hh-admin/src/main/resources/mapper/test/TestMaterMapper.xml @@ -1,7 +1,7 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -52,10 +52,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -73,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time, update_by, update_time, - + #{id}, #{lawFirmName}, @@ -86,9 +85,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createTime}, #{updateBy}, #{updateTime}, - + + + update test_mater + + law_firm_name = #{lawFirmName}, + address = #{address}, + file_id = #{fileId}, + del_flag = #{delFlag}, + state = #{state}, + publish_time = #{publishTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + update test_mater @@ -119,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from test_sub where legal_id in - + #{legalId} @@ -130,7 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into test_sub( id, legal_id, lawyer_name, phone, brief_introduction, del_flag, create_by, create_time, update_by, update_time) values - + ( #{item.id}, #{item.legalId}, #{item.lawyerName}, #{item.phone}, #{item.briefIntroduction}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}) diff --git a/hh-admin/src/main/resources/mapper/test/TestTreeMapper.xml b/hh-admin/src/main/resources/mapper/test/TestTreeMapper.xml index 3d98c624c3b6ba4bbb916d0036a209b6dff1a03a..f3f41b3a021afd6e3a70b09413194cb6683444fd 100644 --- a/hh-admin/src/main/resources/mapper/test/TestTreeMapper.xml +++ b/hh-admin/src/main/resources/mapper/test/TestTreeMapper.xml @@ -60,6 +60,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update test_tree + + parent_id = #{parentId}, + tree_name = #{treeName}, + version = #{version}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + del_flag = #{delFlag}, + + where id = #{id} + + update test_tree diff --git a/hh-admin/src/test/java/com/hh/test/service/impl/FlowTest.java b/hh-admin/src/test/java/com/hh/test/service/impl/FlowTest.java index 1df8fc4b87649205a32419e1db8f4a92fd6ef843..25fd74d8b505a68d2cc548ab8dbd12d63aaf18e6 100644 --- a/hh-admin/src/test/java/com/hh/test/service/impl/FlowTest.java +++ b/hh-admin/src/test/java/com/hh/test/service/impl/FlowTest.java @@ -46,7 +46,7 @@ public class FlowTest { public void skipFlow() throws Exception { // flowManagerService.skipFlow(1642241652926058496L, "驳回", getUser()); // flowManagerService.skipFlow(1642241652926058496L, null, getUser()); - flowManagerService.skipFlow(1643082052721053696L, "审批通过", getUser()); + flowManagerService.skipFlow(1646900555861331968L, "审批通过", getUser()); // flowManagerService.skipFlow(1643081321913913344L, "审批通过", getUser()); // flowManagerService.skipFlow(1643081321913913344L, "审批通过", getUser()); // flowManagerService.skipFlow(1641692115014651904L, "审批通过", getUser()); diff --git a/hh-admin/src/test/java/com/hh/test/service/impl/Test.java b/hh-admin/src/test/java/com/hh/test/service/impl/Test.java index 395483dcbd09c1efd441878891401c4a01e0a94f..2c2b2529a4effb596fda521b13ebec3eb9b67daf 100644 --- a/hh-admin/src/test/java/com/hh/test/service/impl/Test.java +++ b/hh-admin/src/test/java/com/hh/test/service/impl/Test.java @@ -1,5 +1,7 @@ package com.hh.test.service.impl; +import com.hh.test.domain.TestCommon; + import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; @@ -9,19 +11,5 @@ public class Test { @org.junit.jupiter.api.Test public void test1() { -// 1为 int 类型、0代表前面要补位的字符、2代表字符串的长度、d表示参数为整数类型 - String s = String.format("0.%0" + "2" + "d", 1); - System.out.println(s); - int a = 20; - String bb = String.format("%-" + a + "s", 10).replace(" ", "0"); - System.out.println(bb); - BigDecimal aLong = new BigDecimal(bb); - System.out.println(aLong.subtract(new BigDecimal(1))); - // BigDecimal pow = BigDecimal.valueOf(Math.pow(10, 18)); - // int a = 18; - // for (int i = 0; i < a; i++) { - // - // } - // System.out.println(pow); } } diff --git a/hh-common/src/main/java/com/hh/common/utils/AssertUtil.java b/hh-common/src/main/java/com/hh/common/utils/AssertUtil.java index c47bf86ff2d7221a11371914460c96e92471637d..44e2db43774e800d432ca43595c672c50842c97a 100644 --- a/hh-common/src/main/java/com/hh/common/utils/AssertUtil.java +++ b/hh-common/src/main/java/com/hh/common/utils/AssertUtil.java @@ -15,25 +15,37 @@ public class AssertUtil { } - public static void notNull(Object obj, String errorMsg) { + public static void isNull(Object obj, String errorMsg) { if (obj == null) { throw new ServiceException(errorMsg); } } - public static void notBlank(String obj, String errorMsg) { + public static void isNotNull(Object obj, String errorMsg) { + if (obj != null) { + throw new ServiceException(errorMsg); + } + } + + public static void isBlank(String obj, String errorMsg) { if (StringUtil.isEmpty(obj)) { throw new ServiceException(errorMsg); } } - public static void isTrue(boolean obj, String errorMsg) { - if (!obj) { + public static void isNotBlank(String obj, String errorMsg) { + if (StringUtil.isNotEmpty(obj)) { throw new ServiceException(errorMsg); } } public static void isFalse(boolean obj, String errorMsg) { + if (!obj) { + throw new ServiceException(errorMsg); + } + } + + public static void isTrue(boolean obj, String errorMsg) { if (obj) { throw new ServiceException(errorMsg); } diff --git a/hh-common/src/main/java/com/hh/common/utils/StringUtils.java b/hh-common/src/main/java/com/hh/common/utils/StringUtils.java index f1e2e12a186415704358f8aaabc99cc1c11ec82c..95129e7f820d81594cd84cb38eec56ce375c6e78 100644 --- a/hh-common/src/main/java/com/hh/common/utils/StringUtils.java +++ b/hh-common/src/main/java/com/hh/common/utils/StringUtils.java @@ -325,9 +325,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } /** - * 判断给定的set列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value + * 判断给定的collection列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value * - * @param set 给定的集合 + * @param collection 给定的集合 * @param array 给定的数组 * @return boolean 结果 */ diff --git a/hh-framework/hh-banner/src/main/resources/banner.txt b/hh-framework/hh-banner/src/main/resources/banner.txt index 366813dc084dc83b4a2c465963c8f00c920797b1..6db88aa58de71d996d9186a968956d3b9f1f293d 100644 --- a/hh-framework/hh-banner/src/main/resources/banner.txt +++ b/hh-framework/hh-banner/src/main/resources/banner.txt @@ -1,6 +1,8 @@ Application Version: ${hh.version} Spring Boot Version: ${spring-boot.version} +======================================================== + ▄▄ ▄▄ ▄▄ ▄▄ ▐░░▌ ▐░░▌▐░░▌ ▐░░▌ ▐░░▌ ▐░░▌▐░░▌ ▐░░▌ @@ -12,3 +14,5 @@ Spring Boot Version: ${spring-boot.version} ▐░░▌ ▐░░▌▐░░▌ ▐░░▌ ▐░░▌ ▐░░▌▐░░▌ ▐░░▌ ▀▀ ▀▀ ▀▀ ▀▀ + +======================================================== diff --git a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/controller/BaseController.java b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/controller/BaseController.java index df6a3ecc771433ecd8fa61baae480346a92aeb15..8486aff3117e20f9dd5fe951cfdcc8648e45f585 100644 --- a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/controller/BaseController.java +++ b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/controller/BaseController.java @@ -77,7 +77,7 @@ public class BaseController public R baseAdd(T entity) { try { - return toR(getBaseService().insert(entity)); + return toR(getBaseService().save(entity)); } catch (Exception e) { String msg = MessageUtils.message("controller.add"); logger.error(msg, e); @@ -88,7 +88,7 @@ public class BaseController public R baseEit(T entity) { try { - return toR(getBaseService().update(entity)); + return toR(getBaseService().edit(entity)); } catch (Exception e) { String msg = MessageUtils.message("controller.update"); logger.error(msg, e); diff --git a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/mapper/BaseMapper.java b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/mapper/BaseMapper.java index 0db474e2c6dd406aa75d4e807952942e23ea9e41..fea9ab6837bca44e80c9b24570f85f649cd66f75 100644 --- a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/mapper/BaseMapper.java +++ b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/mapper/BaseMapper.java @@ -22,6 +22,14 @@ public interface BaseMapper */ T selectById(Serializable id); + /** + * 根据ids查询 + * + * @param ids 主键 + * @return 实体 + */ + List selectByIds(Collection ids); + /** * 查询列表 * @@ -38,6 +46,14 @@ public interface BaseMapper */ int insert(T entity); + /** + * 根据id修改 + * + * @param entity 实体 + * @return 结果 + */ + int updateById(T entity); + /** * 修改 * diff --git a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/IBaseService.java b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/IBaseService.java index 25fec44f550e207a9980bf1bd885d265c36e2400..3244c449e92c1f18076e2862580c01a9e540f17d 100644 --- a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/IBaseService.java +++ b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/IBaseService.java @@ -1,6 +1,7 @@ package com.hh.mybatis.service; import com.hh.common.core.domain.BaseEntity; +import com.hh.mybatis.mapper.BaseMapper; import java.io.Serializable; import java.util.Collection; @@ -14,6 +15,7 @@ import java.util.List; */ public interface IBaseService { + /** * 根据id查询 * @@ -22,6 +24,14 @@ public interface IBaseService */ T selectById(Serializable id); + /** + * 根据ids查询 + * + * @param ids 主键 + * @return 实体 + */ + List selectByIds(Collection ids); + /** * 查询列表 * @@ -30,6 +40,14 @@ public interface IBaseService */ List selectList(T entity); + /** + * 查询一条记录 + * + * @param entity 实体列表 + * @return 结果 + */ + T selectOne(T entity); + /** * 新增 * @@ -38,6 +56,21 @@ public interface IBaseService */ int insert(T entity); + /** + * 新增 + * @param entity + * @return + */ + int save(T entity); + + /** + * 根据id修改 + * + * @param entity 实体 + * @return 结果 + */ + int updateById(T entity); + /** * 修改 * @@ -46,6 +79,14 @@ public interface IBaseService */ int update(T entity); + /** + * 先校验后修改 + * + * @param entity 实体 + * @return 结果 + */ + int edit(T entity); + /** * 根据id删除 * diff --git a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/impl/BaseServiceImpl.java b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/impl/BaseServiceImpl.java index 1c69d7c001bd6ba95b62091c4c752e4bc262143b..b2684ba9c0aaf369337cbaa8e49ed106cbeadfd1 100644 --- a/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/impl/BaseServiceImpl.java +++ b/hh-framework/hh-mybatis/src/main/java/com/hh/mybatis/service/impl/BaseServiceImpl.java @@ -53,6 +53,17 @@ public abstract class BaseServiceImpl implements IBaseServ return getBaseMapper().selectById(id); } + /** + * 根据ids查询 + * + * @param ids 主键 + * @return 实体 + */ + @Override + public List selectByIds(Collection ids) { + return getBaseMapper().selectByIds(ids); + } + /** * 查询列表 * @@ -64,6 +75,18 @@ public abstract class BaseServiceImpl implements IBaseServ return getBaseMapper().selectList(entity); } + /** + * 查询一条记录 + * + * @param entity 实体列表 + * @return 结果 + */ + @Override + public T selectOne(T entity) { + List list = getBaseMapper().selectList(entity); + return CollUtil.isEmpty(list) ? null: list.get(0); + } + /** * 新增 * @@ -72,6 +95,7 @@ public abstract class BaseServiceImpl implements IBaseServ */ @Override public int insert(T entity) { + DataFillHandler dataFillHandler = SpringUtils.getBeanNoException(DataFillHandler.class); if (ObjectUtil.isNotNull(dataFillHandler)) { dataFillHandler.insertFill(entity); @@ -79,6 +103,43 @@ public abstract class BaseServiceImpl implements IBaseServ return getBaseMapper().insert(entity); } + /** + * 先校验后修改 + * + * @param entity 实体 + * @return 结果 + */ + @Override + public int save(T entity) { + + checkSave(entity); + return insert(entity); + } + + /** + * 新增前校验 + * @param entity + */ + protected void checkSave(T entity) + { + + } + + /** + * 根据id修改 + * + * @param entity 实体 + * @return 结果 + */ + @Override + public int updateById(T entity) { + DataFillHandler dataFillHandler = SpringUtils.getBeanNoException(DataFillHandler.class); + if (ObjectUtil.isNotNull(dataFillHandler)) { + dataFillHandler.updateFill(entity); + } + return getBaseMapper().updateById(entity); + } + /** * 修改 * @@ -94,6 +155,24 @@ public abstract class BaseServiceImpl implements IBaseServ return getBaseMapper().update(entity); } + /** + * 先校验后修改 + * + * @param entity 实体 + * @return 结果 + */ + @Override + public int edit(T entity) + { + checkEdit(entity); + return updateById(entity); + } + + public void checkEdit(T entity) + { + + } + /** * 根据id删除 * @@ -165,7 +244,7 @@ public abstract class BaseServiceImpl implements IBaseServ if (ObjectUtil.isNotNull(dataFillHandler)) { dataFillHandler.updateFill(record); } - mapper.update(record); + mapper.updateById(record); batch++; if (batch == 800) { session.commit(); diff --git a/hh-modules/hh-flow/pom.xml b/hh-modules/hh-flow/pom.xml index 32efdd81d94e8f1f61af8c46198ec5ecf151d65d..6dd5e86ea0b4ea19399e8d4741b8867b05912719 100644 --- a/hh-modules/hh-flow/pom.xml +++ b/hh-modules/hh-flow/pom.xml @@ -25,5 +25,9 @@ com.hh hh-operatelog + + com.hh + hh-swagger + diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/constant/FlowConstant.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/constant/FlowConstant.java index 439a79549e31902c2f65fdf8cb30e9bd9b2e899d..c78c26eddfa89f731a0332bc050d64f882c26878 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/constant/FlowConstant.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/constant/FlowConstant.java @@ -12,7 +12,7 @@ public class FlowConstant { public static final String SAME_CONDITION_VALUE = "同一个结点不能有相同的跳转条件!"; - public static final String SAME_DEST_NODE = "同一起点下多个跳转指向同一个目标结点!"; + public static final String SAME_DEST_NODE = "同一结点不能跳转同一个目标结点!"; public static final String SAME_FLOW_CODE = "相同流程的编码的不能重复,!"; @@ -32,6 +32,10 @@ public class FlowConstant { public static final String NULL_DEST_NODE = "无法跳转到结点,请检查跳转条件和当前角色是否匹配!"; + public static final String NULL_CONDITIONVALUE_NODE = "无法跳转到结点,请检查跳转条件是否匹配!"; + + public static final String NULL_ROLE_NODE = "无法跳转到结点,请检查当前角色是否匹配!"; + public static final String MEANINGLESS_CONDITION = "开始结点不需要设置跳转条件和角色!"; public static final String MUL_BUSINESS_ID = "当前业务id已经创建过流程!"; @@ -58,6 +62,8 @@ public class FlowConstant { public static final String NOT_NODE_DATA = "流程结点数据缺失!"; + public static final String NOT_PUBLISH_NODE = "不存在已发布的流程定义!"; + public static final String NOT_FOUNT_HIS = "实例历史记录缺失!"; public static final String MSG_OVER_LENGTH = "意见长度过长!"; diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/controller/FlowDefinitionController.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/controller/FlowDefinitionController.java index 99fcacdd08674c4d1efe4944a862b62009cc1118..e96bf5f9cd3a917a94e5d8bc4b04b86a57302492 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/controller/FlowDefinitionController.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/controller/FlowDefinitionController.java @@ -3,16 +3,16 @@ package com.hh.flow.controller; import java.util.List; import javax.annotation.Resource; +import com.hh.common.utils.ExceptionUtil; +import com.hh.common.utils.MessageUtils; +import com.hh.flow.domain.FlowNode; +import com.hh.flow.domain.FlowSkip; +import com.hh.flow.service.IFlowNodeService; +import com.hh.flow.service.IFlowSkipService; +import io.swagger.annotations.Api; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.hh.log.annotaion.Log; import com.hh.mybatis.controller.BaseController; import com.hh.mybatis.domain.R; @@ -28,17 +28,24 @@ import com.hh.mybatis.domain.TableDataInfo; * @date 2023-04-11 */ @Validated +@Api(value = "流程定义控制器", tags = {"流程定义管理"}) @RestController @RequestMapping("/flow/definition") public class FlowDefinitionController extends BaseController { @Resource - private IFlowDefinitionService flowDefinitionService; + private IFlowDefinitionService definitionService; + + @Resource + private IFlowNodeService nodeService; + + @Resource + private IFlowSkipService skipService; @Override public IFlowDefinitionService getBaseService() { - return flowDefinitionService; + return definitionService; } /** @@ -62,6 +69,28 @@ public class FlowDefinitionController extends BaseController return getBaseInfo(id); } + /** + * 获取流程定义详细信息 + */ + @PreAuthorize("@ss.hasPermi('flow:definition:query')") + @GetMapping(value = "/getNodeList/{definitionId}") + public R> getNodeList(@PathVariable("definitionId") Long definitionId) + { + return R.ok(definitionService.getNodeList(definitionId)); + } + + /** + * 获取流程定义详细信息 + */ + @PreAuthorize("@ss.hasPermi('flow:definition:query')") + @GetMapping(value = "/getSkipList/{nodeId}") + public R> getSkipList(@PathVariable("nodeId") Long nodeId) + { + FlowSkip skip = new FlowSkip(); + skip.setNodeId(nodeId); + return R.ok(skipService.selectList(skip)); + } + /** * 新增流程定义 */ @@ -73,6 +102,64 @@ public class FlowDefinitionController extends BaseController return baseAdd(flowDefinition); } + /** + * 发布流程定义 + */ + @PreAuthorize("@ss.hasPermi('flow:definition:publish')") + @Log(title = "流程定义", businessType = BusinessType.INSERT) + @GetMapping("/publish/{id}") + public R publish(@PathVariable("id") Long id) + { + return toR(definitionService.publish(id)); + } + + /** + * 取消发布流程定义 + */ + @PreAuthorize("@ss.hasPermi('flow:definition:publish')") + @Log(title = "流程定义", businessType = BusinessType.INSERT) + @GetMapping("/unPublish/{id}") + public R unPublish(@PathVariable("id") Long id) + { + return toR(definitionService.unPublish(id)); + } + + /** + * 保存流程结点 + */ + @PreAuthorize("@ss.hasPermi('flow:definition:saveNode')") + @Log(title = "流程定义", businessType = BusinessType.INSERT) + @PostMapping("/saveNode") + public R saveNode(@RequestBody List nodeList, Long definitionId) + { + try { + definitionService.saveNode(nodeList, definitionId); + return R.ok(); + } catch (Exception e) { + String msg = MessageUtils.message("controller.save"); + logger.error(msg, e); + return R.fail(ExceptionUtil.handleMsg(msg, e)); + } + } + + /** + * 保存流程跳转 + */ + @PreAuthorize("@ss.hasPermi('flow:definition:saveNode')") + @Log(title = "流程定义", businessType = BusinessType.INSERT) + @PostMapping("/saveSkip") + public R saveSkip(@RequestBody List skipList, Long nodeId) + { + try { + definitionService.saveSkip(skipList, nodeId); + return R.ok(); + } catch (Exception e) { + String msg = MessageUtils.message("controller.save"); + logger.error(msg, e); + return R.fail(ExceptionUtil.handleMsg(msg, e)); + } + } + /** * 修改流程定义 */ @@ -92,6 +179,12 @@ public class FlowDefinitionController extends BaseController @DeleteMapping("/{ids}") public R remove(@PathVariable List ids) { - return baserRemove(ids); + try { + return toR(definitionService.remove(ids)); + } catch (Exception e) { + String msg = MessageUtils.message("controller.delete"); + logger.error(msg, e); + return R.fail(ExceptionUtil.handleMsg(msg, e)); + } } } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowNode.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowNode.java index 6c8bf45f67c3763edc1e43ba5a0189fd10dff523..74ae3f62462d1c9d0f3e9943bdde1e1097320d5d 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowNode.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowNode.java @@ -4,6 +4,7 @@ import com.hh.common.core.domain.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.List; @@ -33,7 +34,19 @@ public class FlowNode extends BaseEntity { /** * 流程结点编码 每个流程的nodeCode是唯一的,即definitionId+nodeCode唯一,在数据库层面做了控制 */ + @NotBlank(message = "流程结点编码不能为空") private String nodeCode; + + /** + * 角色编码(该结点能被哪些角色审核) + */ + private String roleCode; + + /** + * 角色名称 + */ + private String roleName; + /** * 版本 */ @@ -44,6 +57,11 @@ public class FlowNode extends BaseEntity { */ private String delFlag; + /** + * 跳转规则描述 + */ + private String skipDescribe; + /** * 跳转条件 */ diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowSkip.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowSkip.java index 1eb83a4e1321cdce22fa5de150e3943a57a05096..6d2990a4b5bad19cd9b9a7fbad725be616f57e63 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowSkip.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/domain/FlowSkip.java @@ -30,16 +30,6 @@ public class FlowSkip extends BaseEntity { */ private String nowNodeCode; - /** - * 角色编码(该结点能被哪些角色审核) - */ - private String roleCode; - - /** - * 角色名称 - */ - private String roleName; - /** * 下一个流程结点的编码 */ diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/NodeTypeEnum.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/NodeType.java similarity index 79% rename from hh-modules/hh-flow/src/main/java/com/hh/flow/enums/NodeTypeEnum.java rename to hh-modules/hh-flow/src/main/java/com/hh/flow/enums/NodeType.java index 99cdd56515d17f7ae4dbd62a915abe335fa739d0..aa5cb3f74210439e0ac84705c9afa8e7363e4500 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/NodeTypeEnum.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/NodeType.java @@ -5,7 +5,7 @@ package com.hh.flow.enums; * @author minliuhua * @date: 2023/3/31 12:16 */ -public enum NodeTypeEnum { +public enum NodeType { start(0,"start"), between(1,"between"), end(2,"end"); @@ -13,7 +13,7 @@ public enum NodeTypeEnum { private Integer key; private String value; - private NodeTypeEnum(Integer key, String value) + private NodeType(Integer key, String value) { this.key = key; this.value = value; @@ -31,7 +31,7 @@ public enum NodeTypeEnum { public static Integer getKeyByValue(String value) { - for (NodeTypeEnum item : NodeTypeEnum.values()) + for (NodeType item : NodeType.values()) { if (item.getValue().equals(value)) { @@ -43,7 +43,7 @@ public enum NodeTypeEnum { public static String getValueByKey(Integer key) { - for (NodeTypeEnum item : NodeTypeEnum.values()) + for (NodeType item : NodeType.values()) { if (item.getKey().equals(key)) { diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/PublishStatus.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/PublishStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..d5e7ea930b5c77369d313aff181b35ae59089d08 --- /dev/null +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/enums/PublishStatus.java @@ -0,0 +1,55 @@ +package com.hh.flow.enums; + +/** + * @description: 结点类型 + * @author minliuhua + * @date: 2023/3/31 12:16 + */ +public enum PublishStatus { + EXPIRED(9,"已失效"), + UNPUBLISHED(0,"未发布"), + PUBLISHED(1,"已发布"); + + private Integer key; + private String value; + + private PublishStatus(Integer key, String value) + { + this.key = key; + this.value = value; + } + + public Integer getKey() + { + return key; + } + + public String getValue() + { + return value; + } + + public static Integer getKeyByValue(String value) + { + for (PublishStatus item : PublishStatus.values()) + { + if (item.getValue().equals(value)) + { + return item.getKey(); + } + } + return null; + } + + public static String getValueByKey(Integer key) + { + for (PublishStatus item : PublishStatus.values()) + { + if (item.getKey().equals(key)) + { + return item.getValue(); + } + } + return null; + } +} diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/facade/FlowManagerServiceImpl.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/facade/FlowManagerServiceImpl.java index d1ab4bd977b85d8c3fd6a8d0f4904e906ff37f46..da79537576f8a93e2b9839d5cbe406716294a3a8 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/facade/FlowManagerServiceImpl.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/facade/FlowManagerServiceImpl.java @@ -1,17 +1,19 @@ package com.hh.flow.facade; +import cn.hutool.core.collection.CollUtil; import com.hh.common.exception.ServiceException; import com.hh.common.utils.AssertUtil; import com.hh.common.utils.uuid.IdUtils; import com.hh.flow.constant.FlowConstant; import com.hh.flow.domain.*; -import com.hh.flow.enums.NodeTypeEnum; +import com.hh.flow.enums.NodeType; import com.hh.flow.service.*; import com.hh.flow.utils.FlowConfigUtil; import com.hh.flow.vo.FlowCombine; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.*; @@ -59,10 +61,11 @@ public class FlowManagerServiceImpl implements FlowManagerService { public FlowInstance startFlow(String businessId , FlowParams flowUser) { - AssertUtil.notNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); - AssertUtil.notBlank(businessId, FlowConstant.NULL_BUSINESS_ID); + AssertUtil.isNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); + AssertUtil.isBlank(businessId, FlowConstant.NULL_BUSINESS_ID); // 根据流程编码获取开启的唯一流程的流程结点集合 List nodes = nodeService.queryNewVersionFlowNodeByFlowCode(flowUser.getFlowCode()); + AssertUtil.isTrue(nodes.size() == 0, FlowConstant.NOT_PUBLISH_NODE); // 获取开始结点 FlowNode startNode = getFirstNode(nodes); return startFlow(startNode, Arrays.asList(businessId), flowUser).get(0); @@ -72,10 +75,11 @@ public class FlowManagerServiceImpl implements FlowManagerService { @Transactional(rollbackFor = Exception.class) public List startFlow(List businessIds , FlowParams flowUser) { - AssertUtil.notNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); - AssertUtil.isFalse(businessIds == null || businessIds.size() == 0, FlowConstant.NULL_BUSINESS_ID); + AssertUtil.isNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); + AssertUtil.isTrue(businessIds == null || businessIds.size() == 0, FlowConstant.NULL_BUSINESS_ID); // 根据流程编码获取开启的唯一流程的流程结点集合 List nodes = nodeService.queryNewVersionFlowNodeByFlowCode(flowUser.getFlowCode()); + AssertUtil.isTrue(nodes.size() == 0, FlowConstant.NOT_PUBLISH_NODE); // 获取开始结点 FlowNode startNode = getFirstNode(nodes); return startFlow(startNode, businessIds, flowUser); @@ -85,11 +89,12 @@ public class FlowManagerServiceImpl implements FlowManagerService { @Transactional(rollbackFor = Exception.class) public FlowInstance startFlow(String businessId, String version , FlowParams flowUser) { - AssertUtil.notNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); - AssertUtil.notBlank(businessId, FlowConstant.NULL_BUSINESS_ID); - AssertUtil.notBlank(version, FlowConstant.NULL_FLOW_VERSION); + AssertUtil.isNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); + AssertUtil.isBlank(businessId, FlowConstant.NULL_BUSINESS_ID); + AssertUtil.isBlank(version, FlowConstant.NULL_FLOW_VERSION); // 根据流程编码+版本号确定唯一的流程结点集合 List nodes = nodeService.queryFlowNodeByFlowCodeAndVersion(flowUser.getFlowCode(), version); + AssertUtil.isTrue(nodes.size() == 0, FlowConstant.NOT_PUBLISH_NODE); // 获取开始结点 FlowNode startNode = getFirstNode(nodes); return startFlow(startNode, Arrays.asList(businessId), flowUser).get(0); @@ -99,11 +104,12 @@ public class FlowManagerServiceImpl implements FlowManagerService { @Transactional(rollbackFor = Exception.class) public List startFlow(List businessIds, String version , FlowParams flowUser) { - AssertUtil.notNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); - AssertUtil.isFalse(businessIds == null || businessIds.size() == 0, FlowConstant.NULL_BUSINESS_ID); - AssertUtil.notBlank(version, FlowConstant.NULL_FLOW_VERSION); + AssertUtil.isNull(flowUser.getFlowCode(), FlowConstant.NULL_FLOW_CODE); + AssertUtil.isTrue(businessIds == null || businessIds.size() == 0, FlowConstant.NULL_BUSINESS_ID); + AssertUtil.isBlank(version, FlowConstant.NULL_FLOW_VERSION); // 根据流程编码+版本号确定唯一的流程结点集合 List nodes = nodeService.queryFlowNodeByFlowCodeAndVersion(flowUser.getFlowCode(), version); + AssertUtil.isTrue(nodes.size() == 0, FlowConstant.NOT_PUBLISH_NODE); // 获取开始结点 FlowNode startNode = getFirstNode(nodes); return startFlow(startNode, businessIds, flowUser); @@ -131,11 +137,11 @@ public class FlowManagerServiceImpl implements FlowManagerService { @Transactional(rollbackFor = Exception.class) public List skipFlow(List definitionIds, String conditionValue, String message , FlowParams flowUser) { - AssertUtil.isFalse(message != null && message.length() > 500, FlowConstant.MSG_OVER_LENGTH); + AssertUtil.isTrue(message != null && message.length() > 500, FlowConstant.MSG_OVER_LENGTH); // 获取当前流程 List instances = instanceService.queryByidWithUpdateLock(definitionIds); - AssertUtil.isFalse(instances == null || instances.size() == 0, FlowConstant.NOT_FOUNT_INSTANCE); - AssertUtil.isFalse(instances.size() < definitionIds.size(), FlowConstant.LOST_FOUNT_FLOW); + AssertUtil.isTrue(instances == null || instances.size() == 0, FlowConstant.NOT_FOUNT_INSTANCE); + AssertUtil.isTrue(instances.size() < definitionIds.size(), FlowConstant.LOST_FOUNT_FLOW); // 校验这些流程的流程状态是否相同,只有相同的情况下,下面才好做统一处理 checkSameStatus(instances); List insHisList = new ArrayList<>(); @@ -191,7 +197,7 @@ public class FlowManagerServiceImpl implements FlowManagerService { List insHisList = new ArrayList<>(); for (int i = 0; i < ids.size(); i++) { String businessId = ids.get(i); - AssertUtil.notBlank(businessId, FlowConstant.NULL_BUSINESS_ID); + AssertUtil.isBlank(businessId, FlowConstant.NULL_BUSINESS_ID); // 设置流程实例对象 FlowInstance instance = setStartInstance(startNode, businessId, flowUser); // 设置流程实例历史记录对象 @@ -314,45 +320,28 @@ public class FlowManagerServiceImpl implements FlowManagerService { if (skips == null || skips.size() == 0) { return null; } + // TODO min 后续抽取用户角色 + List roleList = flowUser.getRoles(); + AssertUtil.isTrue(roleList == null || roleList.size() == 0, FlowConstant.NOT_ROLE_PERMISSIONS); + List roleKeys = roleList.stream().map(FlowRole::getRoleKey).collect(Collectors.toList()); + FlowNode flowNode = new FlowNode(); + flowNode.setDefinitionId(instance.getDefinitionId()); + flowNode.setNodeCode(instance.getNodeCode()); + FlowNode node = nodeService.selectOne(flowNode); + AssertUtil.isTrue(StringUtils.isNotBlank(node.getRoleCode()) && (CollUtil.isEmpty(roleKeys) + || !roleKeys.contains(node.getRoleCode())), FlowConstant.NULL_ROLE_NODE); + // 第一个结点不需要过滤 - if (!NodeTypeEnum.start.getKey().equals(instance.getFlowStatus())) { + if (!NodeType.start.getKey().equals(instance.getFlowStatus())) { if (StringUtils.isBlank(conditionValue)) { skips = skips.stream().filter(t -> StringUtils.isBlank(t.getConditionValue())).collect(Collectors.toList()); } else { skips = skips.stream().filter(t -> conditionValue.equals(t.getConditionValue())).collect(Collectors.toList()); } } - - // TODO min 后续抽取用户角色 - List roleList = flowUser.getRoles(); - AssertUtil.isFalse(roleList == null || roleList.size() == 0, FlowConstant.NOT_ROLE_PERMISSIONS); - for (int i = skips.size() - 1; i >= 0; i--) - { - int j = 0; - for (; j < roleList.size(); j++) - { - if (StringUtils.isBlank(skips.get(i).getRoleCode())) - { - break;// 无需做角色过滤 - } - else if (skips.get(i).getRoleCode().equals(roleList.get(j).getRoleKey())) - { - break; - } - } - if (j == roleList.size()) - {// 未匹配到角色 - skips.remove(i); - } - } - AssertUtil.isFalse(skips.size() > 1, FlowConstant.MUL_DEST_NODE); - AssertUtil.isFalse(skips.size() == 0, FlowConstant.NULL_DEST_NODE); - if (skips.size() == 0) { - return null; - } else { - // 第一个结点 - return skips.get(0); - } + AssertUtil.isTrue(skips.size() == 0, FlowConstant.NULL_CONDITIONVALUE_NODE); + // 第一个结点 + return skips.get(0); } /** @@ -366,8 +355,8 @@ public class FlowManagerServiceImpl implements FlowManagerService { */ private FlowNode getNextNode(FlowInstance instance, String conditionValue , FlowParams flowUser) { - AssertUtil.notNull(instance.getDefinitionId(), FlowConstant.NOT_DEFINITION_ID); - AssertUtil.notBlank(instance.getNodeCode(), FlowConstant.LOST_NODE_CODE); + AssertUtil.isNull(instance.getDefinitionId(), FlowConstant.NOT_DEFINITION_ID); + AssertUtil.isBlank(instance.getNodeCode(), FlowConstant.LOST_NODE_CODE); FlowSkip skipCondition = new FlowSkip(); skipCondition.setDefinitionId(instance.getDefinitionId()); List skips = skipService.selectList(skipCondition); @@ -387,13 +376,13 @@ public class FlowManagerServiceImpl implements FlowManagerService { } List flowSkips = skipMap.get(instance.getNodeCode()); FlowSkip nextSkip = checkAuthAndCondition(instance, flowSkips, conditionValue, flowUser); - AssertUtil.isFalse(nextSkip == null, FlowConstant.NULL_DEST_NODE); + AssertUtil.isTrue(nextSkip == null, FlowConstant.NULL_DEST_NODE); FlowNode query = new FlowNode(); query.setDefinitionId(instance.getDefinitionId()); query.setNodeCode(nextSkip.getNextNodeCode()); List nodes = nodeService.selectList(query); - AssertUtil.isFalse(nodes.size() == 0, FlowConstant.NOT_NODE_DATA); - AssertUtil.isFalse(nodes.size() > 1, "[" + nextSkip.getNextNodeCode() + "]" + FlowConstant.SAME_NODE_CODE); + AssertUtil.isTrue(nodes.size() == 0, FlowConstant.NOT_NODE_DATA); + AssertUtil.isTrue(nodes.size() > 1, "[" + nextSkip.getNextNodeCode() + "]" + FlowConstant.SAME_NODE_CODE); return nodes.get(0); } @@ -406,7 +395,7 @@ public class FlowManagerServiceImpl implements FlowManagerService { */ private FlowNode getFirstNode(List nodes) { for (int i = 0; i < nodes.size(); i++) { - if (NodeTypeEnum.start.getKey().equals(nodes.get(i).getNodeType())) { + if (NodeType.start.getKey().equals(nodes.get(i).getNodeType())) { return nodes.get(i); } } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowDefinitionMapper.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowDefinitionMapper.java index 645c9a23efb847f02e738e657a7ca41fed082b08..34ef54f170d51e4cda379f900eeb44e6be5b7676 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowDefinitionMapper.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowDefinitionMapper.java @@ -1,8 +1,11 @@ package com.hh.flow.mapper; import com.hh.flow.domain.FlowDefinition; +import com.hh.flow.domain.FlowNode; import com.hh.mybatis.mapper.BaseMapper; +import java.io.Serializable; +import java.util.Collection; import java.util.List; /** @@ -15,4 +18,38 @@ public interface FlowDefinitionMapper extends BaseMapper { List queryByCodeList(List flowCodeList); void closeFlowByCodeList(List flowCodeList); + + /** + * 批量删除流程结点 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteFlowNodeByDefinitionIds(Collection ids); + + /** + * 通过流程定义主键删除流程结点信息 + * + * @param id 流程定义ID + * @return 结果 + */ + public int deleteFlowNodeByDefinitionId(Serializable id); + + /** + * 批量删除结点跳转关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteFlowSkipByDefinitionIds(Collection ids); + + + /** + * 通过流程定义主键删除结点跳转关联信息 + * + * @param id 流程定义ID + * @return 结果 + */ + public int deleteFlowSkipByDefinitionId(Serializable id); + } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowNodeMapper.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowNodeMapper.java index dc25730a3f8e1217c740575451b4fc8e9d122c82..6de5282684be032d4f008a1d128585769318439b 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowNodeMapper.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowNodeMapper.java @@ -4,6 +4,8 @@ import com.hh.flow.domain.FlowNode; import com.hh.mybatis.mapper.BaseMapper; import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Collection; import java.util.List; /** @@ -16,4 +18,12 @@ public interface FlowNodeMapper extends BaseMapper { List queryNewVersionFlowNodeByFlowCode(String flowCode); List queryFlowNodeByFlowCodeAndVersion(@NotBlank String flowCode, @NotBlank String version); + + /** + * 根据definitionId删除 + * + * @param definitionId 需要删除的definitionId + * @return 结果 + */ + int deleteByDefinitionId(Long definitionId); } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowSkipMapper.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowSkipMapper.java index 5d52a3a12bbaa98940000c79656473a82f5ac1de..de990175f7609348eb3f9bdd45fb63b39456c524 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowSkipMapper.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/mapper/FlowSkipMapper.java @@ -3,6 +3,8 @@ package com.hh.flow.mapper; import com.hh.flow.domain.FlowSkip; import com.hh.mybatis.mapper.BaseMapper; +import java.util.List; + /** * 结点跳转关联Mapper接口 * @@ -11,4 +13,19 @@ import com.hh.mybatis.mapper.BaseMapper; */ public interface FlowSkipMapper extends BaseMapper { + /** + * 根据nodeId删除 + * + * @param nodeId 需要删除的nodeId + * @return 结果 + */ + int deleteByNodeId(Long nodeId); + + /** + * 根据nodeIds删除 + * + * @param nodeIds 需要删除的nodeIds + * @return 结果 + */ + int deleteByNodeIds(List nodeIds); } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowDefinitionService.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowDefinitionService.java index 49dacb7939c904351e7de680ea208d5005457d64..79db843af041b2d6bc6faf9a2cf5abb2b760ad0a 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowDefinitionService.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowDefinitionService.java @@ -1,7 +1,11 @@ package com.hh.flow.service; import com.hh.flow.domain.FlowDefinition; +import com.hh.flow.domain.FlowNode; +import com.hh.flow.domain.FlowSkip; import com.hh.mybatis.service.IBaseService; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -15,4 +19,45 @@ public interface IFlowDefinitionService extends IBaseService { List queryByCodeList(List flowCodeList); void closeFlowByCodeList(List flowCodeList); + + /** + * 查询流程节点列表 + * @param definitionId + * @return + */ + List getNodeList(Long definitionId); + + /** + * 保存流程结点 + * @param flowNodeList + * @param definitionId + */ + void saveNode(@RequestBody List flowNodeList, Long definitionId); + + /** + * 保存流程跳转 + * @param skipList + * @param nodeId + */ + void saveSkip(List skipList, Long nodeId); + + /** + * 删除流程定义 + * @param ids + */ + int remove(List ids); + + /** + * 发布流程定义 + * @param id + * @return + */ + int publish(Long id); + + /** + * 取消发布流程定义 + * @param id + * @return + */ + int unPublish(Long id); } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowNodeService.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowNodeService.java index ccdd64c2daf5458d5afc4367ff3ad26e4a1381f0..5fd1dcc486486b068f20920b665ac7ac9c0e6915 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowNodeService.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowNodeService.java @@ -4,6 +4,8 @@ import com.hh.flow.domain.FlowNode; import com.hh.mybatis.service.IBaseService; import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Collection; import java.util.List; /** @@ -29,4 +31,12 @@ public interface IFlowNodeService extends IBaseService { * @return */ List queryFlowNodeByFlowCodeAndVersion(@NotBlank String flowCode, @NotBlank String version); + + /** + * 根据definitionId删除 + * + * @param definitionId 需要删除的definitionId + * @return 结果 + */ + int deleteByDefinitionId(Long definitionId); } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowSkipService.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowSkipService.java index f6978243d0068e1b9f45473e6855820c6da95a02..72c6cb2538e0c471949711394b40e4a9e6c8fcbe 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowSkipService.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/IFlowSkipService.java @@ -2,6 +2,9 @@ package com.hh.flow.service; import com.hh.flow.domain.FlowSkip; import com.hh.mybatis.service.IBaseService; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; /** * 结点跳转关联Service接口 @@ -11,4 +14,19 @@ import com.hh.mybatis.service.IBaseService; */ public interface IFlowSkipService extends IBaseService { + /** + * 根据nodeId删除 + * + * @param nodeId 需要删除的nodeId + * @return 结果 + */ + int deleteByNodeId(Long nodeId); + + /** + * 根据nodeIds删除 + * + * @param nodeIds 需要删除的nodeIds + * @return 结果 + */ + int deleteByNodeIds(List nodeIds); } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowDefinitionServiceImpl.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowDefinitionServiceImpl.java index 8b5964d20e36400a67df1c0cfd9427b23ae1901c..70c508be1f105dbb0f3c8773a0ef18bfe5cccead 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowDefinitionServiceImpl.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowDefinitionServiceImpl.java @@ -1,13 +1,28 @@ package com.hh.flow.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.hh.common.exception.ServiceException; +import com.hh.common.utils.AssertUtil; +import com.hh.common.utils.StringUtils; +import com.hh.flow.constant.FlowConstant; import com.hh.flow.domain.FlowDefinition; +import com.hh.flow.domain.FlowNode; +import com.hh.flow.domain.FlowSkip; +import com.hh.flow.enums.NodeType; +import com.hh.flow.enums.PublishStatus; import com.hh.flow.mapper.FlowDefinitionMapper; import com.hh.flow.service.IFlowDefinitionService; +import com.hh.flow.service.IFlowNodeService; +import com.hh.flow.service.IFlowSkipService; import com.hh.mybatis.service.impl.BaseServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import javax.annotation.Resource; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * 流程定义Service业务层处理 @@ -20,6 +35,12 @@ public class FlowDefinitionServiceImpl extends BaseServiceImpl i @Resource private FlowDefinitionMapper definitionMapper; + @Resource + private IFlowNodeService nodeService; + + @Resource + private IFlowSkipService skipService; + @Override public FlowDefinitionMapper getBaseMapper() { return definitionMapper; @@ -34,4 +55,176 @@ public class FlowDefinitionServiceImpl extends BaseServiceImpl i public void closeFlowByCodeList(List flowCodeList) { definitionMapper.closeFlowByCodeList(flowCodeList); } + + @Override + public void checkSave(FlowDefinition flowDefinition) + { + List flowCodeList = Arrays.asList(flowDefinition.getFlowCode()); + List flowDefinitions = queryByCodeList(flowCodeList); + for (FlowDefinition beforeDefinition : flowDefinitions) { + if (flowDefinition.getFlowCode().equals(beforeDefinition.getFlowCode()) && flowDefinition.getVersion().equals(beforeDefinition.getVersion())) { + throw new ServiceException(flowDefinition.getFlowCode() + "(" + flowDefinition.getVersion() + ")" + FlowConstant.ALREADY_EXIST); + } + } + } + + @Override + public List getNodeList(Long definitionId) + { + FlowNode flowNode = new FlowNode(); + flowNode.setDefinitionId(definitionId); + List flowNodes = nodeService.selectList(flowNode); + StringBuffer skipDescribe; + Map nodeMap = flowNodes.stream().collect(Collectors.toMap(FlowNode::getNodeCode, FlowNode::getNodeName)); + for (FlowNode node : flowNodes) { + skipDescribe = new StringBuffer(); + FlowSkip skip = new FlowSkip(); + skip.setNodeId(node.getId()); + List skips = skipService.selectList(skip); + for (FlowSkip flowSkip : skips) { + skipDescribe.append("【").append(flowSkip.getConditionValue()).append("】").append("后跳转到").append("【") + .append(nodeMap.get(flowSkip.getNextNodeCode())).append("】; "); + } + if (StringUtils.isEmpty(skipDescribe.toString())) { + node.setSkipDescribe("无"); + } else { + node.setSkipDescribe(skipDescribe.toString()); + } + } + + return flowNodes; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveNode(@RequestBody List flowNodeList, Long definitionId) + { + // TODO min 需要关联skip,最好区间删除、新增、更新类型 + List nodeTypes = flowNodeList.stream().map(FlowNode::getNodeType).collect(Collectors.toList()); + AssertUtil.isFalse(nodeTypes.contains(NodeType.start.getKey()) + && nodeTypes.contains(NodeType.end.getKey()), "必须有开始结点和结束结点"); + FlowNode nodeQuery = new FlowNode(); + nodeQuery.setDefinitionId(definitionId); + // 获取原始结点 + List flowNodesOrig = nodeService.selectList(nodeQuery); + + Set origNodeIds = flowNodesOrig.stream().map(FlowNode::getId).collect(Collectors.toSet()); + Set tarNodeIds = flowNodeList.stream().map(FlowNode::getId).collect(Collectors.toSet()); + + // 新增结点 + List nodesAdd = new ArrayList<>(); + // 更新结点 + List nodesUpdate = new ArrayList<>(); + for (FlowNode flowNode : flowNodeList) { + if (ObjectUtil.isNull(flowNode.getId())) { + nodesAdd.add(flowNode); + } else if (origNodeIds.contains(flowNode.getId())) { + nodesUpdate.add(flowNode); + } + } + + // 删除结点 + List nodesDelete = new ArrayList<>(); + for (Long origNodeId : origNodeIds) { + if (!tarNodeIds.contains(origNodeId)) + { + nodesDelete.add(origNodeId); + } + } + + // 执行新增 + FlowDefinition flowDefinition = selectById(definitionId); + for (FlowNode flowNode : nodesAdd) { + flowNode.setDefinitionId(definitionId); + flowNode.setVersion(flowDefinition.getVersion()); + } + + if (CollUtil.isNotEmpty(nodesAdd)) { + nodeService.batchInsert(nodesAdd); + } + + // 执行更新 + if (CollUtil.isNotEmpty(nodesUpdate)) { + + nodeService.batchUpdate(nodesUpdate); + } + + // 执行删除 + if (CollUtil.isNotEmpty(nodesDelete)) { + skipService.deleteByNodeIds(nodesDelete); + nodeService.batchDelete(nodesDelete); + } + + } + + /** + * 保存流程跳转 + * @param skipList + * @param nodeId + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveSkip(List skipList, Long nodeId) + { + FlowNode node = nodeService.selectById(nodeId); + //跳转条件的集合 + Set conditionSet = new HashSet<>(); + //目标结点的集合 这两个集合都不能重复 + Set targetSet = new HashSet<>(); + //遍历结点下的跳转条件 + for (int i = 0; i < skipList.size(); i++) { + FlowSkip skip = skipList.get(i); + //目标结点 + String target = skip.getNextNodeCode(); + AssertUtil.isBlank(target, FlowConstant.LOST_DEST_NODE); + AssertUtil.isTrue(targetSet.contains(target), FlowConstant.SAME_DEST_NODE); + targetSet.add(target); + String value = skip.getConditionValue(); + AssertUtil.isTrue(conditionSet.contains(value), FlowConstant.SAME_CONDITION_VALUE); + conditionSet.add(value); + + skip.setNodeId(node.getId()); + skip.setDefinitionId(node.getDefinitionId()); + skip.setNowNodeCode(node.getNodeCode()); + } + skipService.deleteByNodeId(nodeId); + skipService.batchInsert(skipList); + } + + + /** + * 删除流程定义 + * @param ids + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int remove(List ids) + { + definitionMapper.deleteFlowNodeByDefinitionIds(ids); + definitionMapper.deleteFlowSkipByDefinitionIds(ids); + return deleteByIds(ids); + } + + @Override + public int publish(Long id) + { + FlowDefinition definition = selectById(id); + List flowCodeList = Arrays.asList(definition.getFlowCode()); + // 把之前的流程定义改为已失效 + closeFlowByCodeList(flowCodeList); + + FlowDefinition flowDefinition = new FlowDefinition(); + flowDefinition.setId(id); + flowDefinition.setIsPublish(PublishStatus.PUBLISHED.getKey()); + return updateById(flowDefinition); + } + + @Override + public int unPublish(Long id) + { + FlowDefinition flowDefinition = new FlowDefinition(); + flowDefinition.setId(id); + flowDefinition.setIsPublish(PublishStatus.UNPUBLISHED.getKey()); + return updateById(flowDefinition); + } } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowInstanceServiceImpl.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowInstanceServiceImpl.java index f1edd36c2673a2b0664e3622ebd54af917ae31c1..d31c33134ef408df7910db59e1b6729c00f2ecc4 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowInstanceServiceImpl.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowInstanceServiceImpl.java @@ -29,9 +29,9 @@ public class FlowInstanceServiceImpl extends BaseServiceImpl imple @Override public List queryByidWithUpdateLock(List definitionIds) { - AssertUtil.isFalse(definitionIds == null || definitionIds.size() == 0, FlowConstant.NOT_FOUNT_FLOW); + AssertUtil.isTrue(definitionIds == null || definitionIds.size() == 0, FlowConstant.NOT_FOUNT_FLOW); for (int i = 0; i < definitionIds.size(); i++) { - AssertUtil.notNull(definitionIds.get(i), "流程定义id不能为空!"); + AssertUtil.isNull(definitionIds.get(i), "流程定义id不能为空!"); } return instanceMapper.queryByidWithUpdateLock(definitionIds); } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowNodeServiceImpl.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowNodeServiceImpl.java index 523eeaa9c41c0b6e19285b99f249471fc87e6b69..290d9b4084b130f8c994b0755e88a6b4aff5da4c 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowNodeServiceImpl.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowNodeServiceImpl.java @@ -8,6 +8,8 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Collection; import java.util.List; /** @@ -35,4 +37,9 @@ public class FlowNodeServiceImpl extends BaseServiceImpl implements IF public List queryFlowNodeByFlowCodeAndVersion(@NotBlank String flowCode, @NotBlank String version) { return nodeMapper.queryFlowNodeByFlowCodeAndVersion(flowCode, version); } + + @Override + public int deleteByDefinitionId(Long definitionId){ + return nodeMapper.deleteByDefinitionId(definitionId); + } } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowSkipServiceImpl.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowSkipServiceImpl.java index 0260de246f26ffd54ba88380b5aac491c6736e89..ecc6ca8478e670dd16569544aee42d5b9c1eaadd 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowSkipServiceImpl.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/service/impl/FlowSkipServiceImpl.java @@ -1,12 +1,25 @@ package com.hh.flow.service.impl; +import cn.hutool.core.collection.CollUtil; +import com.hh.common.exception.ServiceException; +import com.hh.common.utils.AssertUtil; +import com.hh.common.utils.uuid.IdUtils; +import com.hh.flow.constant.FlowConstant; +import com.hh.flow.domain.FlowNode; import com.hh.flow.domain.FlowSkip; import com.hh.flow.mapper.FlowSkipMapper; +import com.hh.flow.service.IFlowNodeService; import com.hh.flow.service.IFlowSkipService; +import com.hh.mybatis.domain.R; import com.hh.mybatis.service.impl.BaseServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import javax.annotation.Resource; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * 结点跳转关联Service业务层处理 @@ -23,4 +36,21 @@ public class FlowSkipServiceImpl extends BaseServiceImpl implements IF public FlowSkipMapper getBaseMapper() { return flowSkipMapper; } + + @Override + public int deleteByNodeId(Long nodeId) { + return flowSkipMapper.deleteByNodeId(nodeId); + } + + /** + * 根据nodeIds删除 + * + * @param nodeIds 需要删除的nodeIds + * @return 结果 + */ + @Override + public int deleteByNodeIds(List nodeIds) + { + return flowSkipMapper.deleteByNodeIds(nodeIds); + } } diff --git a/hh-modules/hh-flow/src/main/java/com/hh/flow/utils/FlowConfigUtil.java b/hh-modules/hh-flow/src/main/java/com/hh/flow/utils/FlowConfigUtil.java index 540dc07abdbc0e54a8b3ee273419fddfd78b0e2f..146d530b65a386840429224dfb21e5f09d8803c1 100644 --- a/hh-modules/hh-flow/src/main/java/com/hh/flow/utils/FlowConfigUtil.java +++ b/hh-modules/hh-flow/src/main/java/com/hh/flow/utils/FlowConfigUtil.java @@ -6,7 +6,7 @@ import com.hh.flow.constant.FlowConstant; import com.hh.flow.domain.FlowDefinition; import com.hh.flow.domain.FlowNode; import com.hh.flow.domain.FlowSkip; -import com.hh.flow.enums.NodeTypeEnum; +import com.hh.flow.enums.NodeType; import com.hh.flow.vo.FlowCombine; import org.springframework.util.CollectionUtils; @@ -48,8 +48,8 @@ public class FlowConfigUtil { List allSkips = combine.getAllSkips(); String flowName = definition.getFlowName(); - AssertUtil.notBlank(definition.getFlowCode(), "【" + flowName + "】流程flowCode为空!"); - AssertUtil.notBlank(definition.getVersion(), "【" + flowName + "】流程version为空!"); + AssertUtil.isBlank(definition.getFlowCode(), "【" + flowName + "】流程flowCode为空!"); + AssertUtil.isBlank(definition.getVersion(), "【" + flowName + "】流程version为空!"); Long id = IdUtils.snowflakeId(); //发布 definition.setIsPublish(1); @@ -64,19 +64,19 @@ public class FlowConfigUtil { for (FlowNode node : nodeList) { initNodeAndCondition(node, id, definition.getVersion()); - if (NodeTypeEnum.start.getKey().equals(node.getNodeType())) { + if (NodeType.start.getKey().equals(node.getNodeType())) { startNum++; - AssertUtil.isFalse(startNum > 1, "[" + NodeTypeEnum.getValueByKey(node.getNodeType()) + "]" + FlowConstant.MUL_START_NODE); + AssertUtil.isTrue(startNum > 1, "[" + NodeType.getValueByKey(node.getNodeType()) + "]" + FlowConstant.MUL_START_NODE); } //保证不存在重复的nodeCode - AssertUtil.isFalse(nodeCodeSet.contains(node.getNodeCode()), - "【" + NodeTypeEnum.getValueByKey(node.getNodeType()) + "】" + FlowConstant.SAME_NODE_CODE); + AssertUtil.isTrue(nodeCodeSet.contains(node.getNodeCode()), + "【" + NodeType.getValueByKey(node.getNodeType()) + "】" + FlowConstant.SAME_NODE_CODE); nodeCodeSet.add(node.getNodeCode()); allNodes.add(node); allSkips.addAll(node.getSkipList()); } - AssertUtil.isFalse(startNum == 0, "[" + flowName + "]" + FlowConstant.LOST_START_NODE); + AssertUtil.isTrue(startNum == 0, "[" + flowName + "]" + FlowConstant.LOST_START_NODE); //校验所有目标结点是否都存在 validaIsExistDestNode(allSkips, nodeCodeSet); return combine; @@ -86,14 +86,14 @@ public class FlowConfigUtil { FlowDefinition definition = new FlowDefinition(); definition.setFlowCode("leaveFlow"); definition.setFlowName("请假流程"); - definition.setVersion("5.0"); + definition.setVersion("8.0"); List nodeList = new ArrayList<>(); definition.setNodeList(nodeList); FlowNode start = new FlowNode(); nodeList.add(start); - start.setNodeType(NodeTypeEnum.getKeyByValue("start")); + start.setNodeType(NodeType.getKeyByValue("start")); start.setNodeCode("1"); start.setNodeName("待审批"); List startSkipList = new ArrayList<>(); @@ -104,14 +104,14 @@ public class FlowConfigUtil { FlowNode end = new FlowNode(); nodeList.add(end); - end.setNodeType(NodeTypeEnum.getKeyByValue("end")); + end.setNodeType(NodeType.getKeyByValue("end")); end.setNodeCode("5"); end.setNodeName("审批完成"); end.setSkipList(new ArrayList<>()); FlowNode betweenNode1 = new FlowNode(); nodeList.add(betweenNode1); - betweenNode1.setNodeType(NodeTypeEnum.getKeyByValue("between")); + betweenNode1.setNodeType(NodeType.getKeyByValue("between")); betweenNode1.setNodeCode("2"); betweenNode1.setNodeName("组长审批"); List betweenSkipList1 = new ArrayList<>(); @@ -130,7 +130,7 @@ public class FlowConfigUtil { FlowNode betweenNode2 = new FlowNode(); nodeList.add(betweenNode2); - betweenNode2.setNodeType(NodeTypeEnum.getKeyByValue("between")); + betweenNode2.setNodeType(NodeType.getKeyByValue("between")); betweenNode2.setNodeCode("3"); betweenNode2.setNodeName("部门经理审批"); List betweenSkipList2 = new ArrayList<>(); @@ -149,7 +149,7 @@ public class FlowConfigUtil { FlowNode betweenNode3 = new FlowNode(); nodeList.add(betweenNode3); - betweenNode3.setNodeType(NodeTypeEnum.getKeyByValue("between")); + betweenNode3.setNodeType(NodeType.getKeyByValue("between")); betweenNode3.setNodeCode("4"); betweenNode3.setNodeName("hr审批"); List betweenSkipList3 = new ArrayList<>(); @@ -178,7 +178,7 @@ public class FlowConfigUtil { private static void validaIsExistDestNode(List allSkips, Set nodeCodeSet) { for (int i = 0; i < allSkips.size(); i++) { String nextNodeCode = allSkips.get(i).getNextNodeCode(); - AssertUtil.isFalse(!nodeCodeSet.contains(nextNodeCode), "【" + nextNodeCode + "】" + FlowConstant.NULL_NODE_CODE); + AssertUtil.isTrue(!nodeCodeSet.contains(nextNodeCode), "【" + nextNodeCode + "】" + FlowConstant.NULL_NODE_CODE); } } @@ -195,10 +195,10 @@ public class FlowConfigUtil { String nodeName = node.getNodeName(); String nodeCode = node.getNodeCode(); List skipList = node.getSkipList(); - if (!NodeTypeEnum.end.getKey().equals(node.getNodeType())) { - AssertUtil.isFalse(CollectionUtils.isEmpty(skipList), "开始和中间结点必须有子结点"); + if (!NodeType.end.getKey().equals(node.getNodeType())) { + AssertUtil.isTrue(CollectionUtils.isEmpty(skipList), "开始和中间结点必须有跳转规则"); } - AssertUtil.notBlank(nodeCode, "[" + nodeName + "]" + FlowConstant.LOST_NODE_CODE); + AssertUtil.isBlank(nodeCode, "[" + nodeName + "]" + FlowConstant.LOST_NODE_CODE); node.setId(IdUtils.snowflakeId()); node.setVersion(version); @@ -221,12 +221,11 @@ public class FlowConfigUtil { skip.setNowNodeCode(nodeCode); //目标结点 String target = skip.getNextNodeCode(); - AssertUtil.notBlank(target, "【" + nodeName + "】" + FlowConstant.LOST_DEST_NODE); - AssertUtil.isFalse(targetSet.contains(target), "[" + nodeName + "]" + FlowConstant.SAME_DEST_NODE); + AssertUtil.isBlank(target, "【" + nodeName + "】" + FlowConstant.LOST_DEST_NODE); + AssertUtil.isTrue(targetSet.contains(target), "[" + nodeName + "]" + FlowConstant.SAME_DEST_NODE); targetSet.add(target); - String roleCode = skip.getRoleCode(); String value = skip.getConditionValue(); - AssertUtil.isFalse(conditionSet.contains(value), "[" + nodeName + "]" + FlowConstant.SAME_CONDITION_VALUE); + AssertUtil.isTrue(conditionSet.contains(value), "[" + nodeName + "]" + FlowConstant.SAME_CONDITION_VALUE); conditionSet.add(value); } } diff --git a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowDefinitionMapper.xml b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowDefinitionMapper.xml index 69b6b9dc1e1ae6f92e80ed7b6bdfa127a7c2ed77..da84b96af1c4d2fa4673aeb2d8bfb4c4b383ed8e 100644 --- a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowDefinitionMapper.xml +++ b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowDefinitionMapper.xml @@ -37,13 +37,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + @@ -74,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update flow_definition flow_code = #{flowCode}, @@ -90,6 +97,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update flow_definition + + flow_code = #{flowCode}, + flow_name = #{flowName}, + version = #{version}, + is_publish = #{isPublish}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + + update flow_definition set is_publish = 9 where flow_code in @@ -108,4 +130,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + delete from flow_node where definition_id in + + #{definitionId} + + + + + delete from flow_node where definition_id = #{definitionId} + + + + delete from flow_skip where definition_id in + + #{definitionId} + + + + + delete from flow_skip where definition_id = #{definitionId} + + diff --git a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInsHisMapper.xml b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInsHisMapper.xml index eea14465b295eb454897c3057b7911cebea44c4b..96868fe64a9799831ef422134605fcdcd0a9e646 100644 --- a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInsHisMapper.xml +++ b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInsHisMapper.xml @@ -104,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update flow_ins_his node_from = #{nodeFrom}, @@ -125,6 +125,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update flow_ins_his + + node_from = #{nodeFrom}, + node_from_name = #{nodeFromName}, + node_to = #{nodeTo}, + node_to_name = #{nodeToName}, + user_code = #{userCode}, + user_name = #{userName}, + instance_id = #{instanceId}, + message = #{message}, + condition_value = #{conditionValue}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + + delete from flow_ins_his where id = #{id} diff --git a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInstanceMapper.xml b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInstanceMapper.xml index ced8bb947a60056274037c6912e18e5229fd66ad..d5c23bad02efd81d766ae6205e282883da339977 100644 --- a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInstanceMapper.xml +++ b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowInstanceMapper.xml @@ -90,6 +90,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update flow_instance + + business_id = #{businessId}, + node_code = #{nodeCode}, + node_name = #{nodeName}, + flow_status = #{flowStatus}, + flow_version = #{flowVersion}, + user_code = #{userCode}, + user_name = #{userName}, + definition_id = #{definitionId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + where id = #{id} + + update flow_instance diff --git a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowNodeMapper.xml b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowNodeMapper.xml index 21ef62012e9d563eb413851ec565ce1701dd85f2..0cdd7423097ed43378deb1db1c738638cdaa982d 100644 --- a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowNodeMapper.xml +++ b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowNodeMapper.xml @@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -19,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select t.id, t.node_type, t.definition_id, t.node_name, t.node_code, t.version, t.create_by, t.create_time, + select t.id, t.node_type, t.definition_id, t.node_name, t.node_code, t.role_code, role_name, t.version, t.create_by, t.create_time, t.update_by, t.update_time, t.del_flag from flow_node t @@ -38,6 +40,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and t.node_code = #{nodeCode} + + and t.role_code = #{roleCode} + + + and t.role_name like concat('%',#{roleName}, '%') + and t.version = #{version} @@ -79,6 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" definition_id, node_name, node_code, + role_code, + role_name, version, create_by, create_time, @@ -92,6 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{definitionId}, #{nodeName}, #{nodeCode}, + #{roleCode}, + #{roleName}, #{version}, #{createBy}, #{createTime}, @@ -101,13 +113,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update flow_node node_type = #{nodeType}, definition_id = #{definitionId}, node_name = #{nodeName}, node_code = #{nodeCode}, + role_code = #{roleCode}, + role_name = #{roleName}, version = #{version}, create_by = #{createBy}, create_time = #{createTime}, @@ -118,6 +132,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update flow_node + + node_type = #{nodeType}, + definition_id = #{definitionId}, + node_name = #{nodeName}, + node_code = #{nodeCode}, + role_code = #{roleCode}, + role_name = #{roleName}, + version = #{version}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + + delete from flow_node where id = #{id} @@ -128,4 +160,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + delete from flow_node where definition_id = #{definitionId} + diff --git a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowSkipMapper.xml b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowSkipMapper.xml index 5eaf0bf4300f7c4a26e892187acc0ff8f07a0546..2359f977be488fa8346b6e9b8f3dd482d383371b 100644 --- a/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowSkipMapper.xml +++ b/hh-modules/hh-flow/src/main/resources/mapper/flow/FlowSkipMapper.xml @@ -9,8 +9,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - @@ -21,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select t.id, t.definition_id, t.node_id, t.now_node_code, t.role_code, t.role_name, t.next_node_code, t.condition_value, t.create_by, t.create_time, + select t.id, t.definition_id, t.node_id, t.now_node_code, t.next_node_code, t.condition_value, t.create_by, t.create_time, t.update_by, t.update_time, t.del_flag from flow_skip t @@ -37,12 +35,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and t.now_node_code = #{nowNodeCode} - - and t.role_code = #{roleCode} - - - and t.role_name like concat('%',#{roleName}, '%') - and t.next_node_code = #{nextNodeCode} @@ -64,8 +56,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" definition_id, node_id, now_node_code, - role_code, - role_name, next_node_code, condition_value, create_by, @@ -79,8 +69,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{definitionId}, #{nodeId}, #{nowNodeCode}, - #{roleCode}, - #{roleName}, #{nextNodeCode}, #{conditionValue}, #{createBy}, @@ -91,14 +79,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update flow_skip + + definition_id = #{definitionId}, + node_id = #{nodeId}, + now_node_code = #{nowNodeCode}, + next_node_code = #{nextNodeCode}, + condition_value = #{conditionValue}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + + where id = #{id} + + update flow_skip definition_id = #{definitionId}, node_id = #{nodeId}, now_node_code = #{nowNodeCode}, - role_code = #{roleCode}, - role_name = #{roleName}, next_node_code = #{nextNodeCode}, condition_value = #{conditionValue}, create_by = #{createBy}, @@ -120,4 +123,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + delete from flow_skip where node_id = #{nodeId} + + + + delete from flow_skip where node_id in + + #{item} + + diff --git a/hh-modules/hh-generator/src/main/resources/templates/java/mapper.java.ftlh b/hh-modules/hh-generator/src/main/resources/templates/java/mapper.java.ftlh index 04c775f6c876ed223ef2f7d665c571f0a3c45e14..05c856bd94e8000d91e8aaf67030df6c70a777c7 100644 --- a/hh-modules/hh-generator/src/main/resources/templates/java/mapper.java.ftlh +++ b/hh-modules/hh-generator/src/main/resources/templates/java/mapper.java.ftlh @@ -2,6 +2,13 @@ package ${packageName}.mapper; import com.hh.mybatis.mapper.BaseMapper; import ${packageName}.domain.${ClassName}; +<#if table.sub> +import ${packageName}.domain.${subClassName}; + + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; /** * ${functionName}Mapper接口 @@ -11,5 +18,31 @@ import ${packageName}.domain.${ClassName}; */ public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { +<#if table.sub> + + /** + * 批量删除${subTable.functionName} + * + * @param ${pkColumn.javaField}s 需要删除的数据主键集合 + * @return 结果 + */ + public int delete${subClassName}By${subTableFkClassName}s(Collection ${pkColumn.javaField}s); + + /** + * 批量新增${subTable.functionName} + * + * @param ${subclassName}List ${subTable.functionName}列表 + * @return 结果 + */ + public int batch${subClassName}(List<${subClassName}> ${subclassName}List); + + /** + * 通过${functionName}主键删除${subTable.functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}ID + * @return 结果 + */ + public int delete${subClassName}By${subTableFkClassName}(Serializable ${pkColumn.javaField}); + } diff --git a/hh-modules/hh-generator/src/main/resources/templates/java/serviceImpl.java.ftlh b/hh-modules/hh-generator/src/main/resources/templates/java/serviceImpl.java.ftlh index e6d0751ca7531839cb628e9cd8178dfd9c1b58d8..da42ea7e60e27fb8435ed8cd9730f2cbabfb0f8d 100644 --- a/hh-modules/hh-generator/src/main/resources/templates/java/serviceImpl.java.ftlh +++ b/hh-modules/hh-generator/src/main/resources/templates/java/serviceImpl.java.ftlh @@ -1,6 +1,10 @@ package ${packageName}.service.impl; +import cn.hutool.core.util.ObjectUtil; +import com.hh.common.utils.DateUtils; +import com.hh.common.utils.StringUtils; import com.hh.mybatis.service.impl.BaseServiceImpl; +import com.hh.security.utils.SecurityUtils; <#list columns as column> <#if column.javaField == 'createTime' || column.javaField == 'updateTime'> <#break> @@ -13,8 +17,14 @@ import ${packageName}.domain.${subClassName}; import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; /** * ${functionName}Service业务层处理 @@ -32,4 +42,98 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}> imple public ${ClassName}Mapper getBaseMapper() { return ${className}Mapper; } + +<#if table.sub> + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int insert(${ClassName} ${className}) + { + int rows = super.insert(${className}); + insert${subClassName}(${className}); + return rows; + } + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int update(${ClassName} ${className}) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); + insert${subClassName}(${className}); + return super.update(${className}); + } + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int deleteBy${pkColumn.capJavaField}s(Collection ${pkColumn.javaField}s) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); + return super.deleteByIds(${pkColumn.javaField}s); + } + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int deleteBy${pkColumn.capJavaField}(Serializable ${pkColumn.javaField}) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); + return super.deleteById(${pkColumn.javaField}); + } + + /** + * 新增${subTable.functionName}信息 + * + * @param ${className} ${functionName}对象 + */ + private void insert${subClassName}(${ClassName} ${className}) + { + List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); + ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); + if (StringUtils.isNotNull(${subclassName}List)) + { + List<${subClassName}> list = new ArrayList<>(); + for (${subClassName} ${subclassName} : ${subclassName}List) + { + Date date = ObjectUtil.isNotNull(${subclassName}.getCreateTime()) + ? ${subclassName}.getCreateTime() : DateUtils.getNowDate(); + String username = StringUtils.isNotBlank(testSub.getCreateBy()) + ? ${subclassName}.getCreateBy() : SecurityUtils.getUsernameNe(); + + ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); + ${subclassName}.setCreateTime(date); + ${subclassName}.setUpdateTime(date); + ${subclassName}.setCreateBy(username); + ${subclassName}.setUpdateBy(username); + ${subclassName}.setDelFlag("0"); + list.add(${subclassName}); + } + if (list.size() > 0) + { + ${className}Mapper.batch${subClassName}(list); + } + } + } + } diff --git a/hh-modules/hh-generator/src/main/resources/templates/vue/index.vue.ftlh b/hh-modules/hh-generator/src/main/resources/templates/vue/index.vue.ftlh index 1bf46458ca44598fa991328f721b17fbed8aecaa..741778a51590bb25d01c06208099c0490b022fda 100644 --- a/hh-modules/hh-generator/src/main/resources/templates/vue/index.vue.ftlh +++ b/hh-modules/hh-generator/src/main/resources/templates/vue/index.vue.ftlh @@ -88,6 +88,7 @@ v-hasPermi="['${moduleName}:${businessName}:remove']" >删除 + <#if table.exportEnable == 'Y'> 导出 + diff --git a/hh-modules/hh-generator/src/main/resources/templates/xml/mapper.xml.ftlh b/hh-modules/hh-generator/src/main/resources/templates/xml/mapper.xml.ftlh index 59e3356c72a83d9a565cb95264c9f725f26f3301..62bfdc8818a5ad13398dab705298d4ee0f6f98f5 100644 --- a/hh-modules/hh-generator/src/main/resources/templates/xml/mapper.xml.ftlh +++ b/hh-modules/hh-generator/src/main/resources/templates/xml/mapper.xml.ftlh @@ -64,14 +64,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where t.${pkColumn.columnName} = ${r"#"}{${pkColumn.javaField}} <#elseIf table.sub> select<#list columns as column> a.${column.columnName}<#if column_index + 1 != columns?size>,, - <#list subTable.columns as column> b.${column.columnName} as sub_${column.columnName}<#if column_index + 1 != subTable.columns?size>, - + <#list subTable.columns as column> b.${column.columnName} as sub_${column.columnName}<#if column_index + 1 != subTable.columns?size>, from ${tableName} a - left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName} + left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName} where a.${pkColumn.columnName} = ${r"#"}{${pkColumn.javaField}} + + insert into ${tableName} @@ -86,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update ${tableName} <#list columns as column> @@ -97,6 +106,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where ${pkColumn.columnName} = ${r"#"}{${pkColumn.javaField}} + + + update ${tableName} + +<#list columns as column> +<#if column.columnName != pkColumn.columnName> + ${column.columnName} = ${r"#"}{${column.javaField}}, + + + + delete from ${tableName} where ${pkColumn.columnName} = ${r"#"}{${pkColumn.javaField}} @@ -112,7 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from ${subTableName} where ${subTableFkName} in - + ${r"#"}{${subTableFkclassName}} diff --git a/hh-modules/hh-quartz/src/main/java/com/hh/quartz/util/JobInvokeUtil.java b/hh-modules/hh-quartz/src/main/java/com/hh/quartz/util/JobInvokeUtil.java index 742e6dc6c2a9ed733ceae4c435346da2401dc584..3e2445684a6379e03ce51fc8e68d737287db0aed 100644 --- a/hh-modules/hh-quartz/src/main/java/com/hh/quartz/util/JobInvokeUtil.java +++ b/hh-modules/hh-quartz/src/main/java/com/hh/quartz/util/JobInvokeUtil.java @@ -34,7 +34,7 @@ public class JobInvokeUtil } else { - Object bean = Class.forName(beanName).newInstance(); + Object bean = Class.forName(beanName).getDeclaredConstructor().newInstance(); invokeMethod(bean, methodName, methodParams); } } diff --git a/hh-modules/hh-system/hh-system-biz/src/main/java/com/hh/system/service/impl/SysUserServiceImpl.java b/hh-modules/hh-system/hh-system-biz/src/main/java/com/hh/system/service/impl/SysUserServiceImpl.java index 7c8ddc37bebc78540a08f0202bc93f262ac01ed1..338daee5517706107e175013361dfc8c4a0f5f1d 100644 --- a/hh-modules/hh-system/hh-system-biz/src/main/java/com/hh/system/service/impl/SysUserServiceImpl.java +++ b/hh-modules/hh-system/hh-system-biz/src/main/java/com/hh/system/service/impl/SysUserServiceImpl.java @@ -498,17 +498,18 @@ public class SysUserServiceImpl implements ISysUserService BeanValidators.validateWithException(validator, user); user.setPassword(SecurityUtils.encryptPassword(password)); user.setCreateBy(operName); - this.insertUser(user); + userMapper.insertUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); } else if (isUpdateSupport) { BeanValidators.validateWithException(validator, user); - checkUserAllowed(user); - checkUserDataScope(user.getUserId()); + checkUserAllowed(u); + checkUserDataScope(u.getUserId()); + user.setUserId(u.getUserId()); user.setUpdateBy(operName); - this.updateUser(user); + userMapper.updateUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); } diff --git a/hh-ui/src/api/flow/definition.js b/hh-ui/src/api/flow/definition.js index 31366ebe1b69a146f5e63814bc4325af09ad2ceb..50ae0eb1f9aec169c51568d921113d67439d87a1 100644 --- a/hh-ui/src/api/flow/definition.js +++ b/hh-ui/src/api/flow/definition.js @@ -42,3 +42,53 @@ export function delDefinition(id) { method: 'delete' }) } + +// 保存流程结点 +export function saveNode(data, definitionId) { + return request({ + url: '/flow/definition/saveNode?definitionId=' + definitionId, + method: 'post', + data: data + }) +} + +// 查询流程结点详细 +export function getNodeList(definitionId) { + return request({ + url: '/flow/definition/getNodeList/' + definitionId, + method: 'get' + }) +} + +// 查询流程跳转详细 +export function getSkipList(nodeId) { + return request({ + url: '/flow/definition/getSkipList/' + nodeId, + method: 'get' + }) +} + +// 保存流程跳转 +export function saveSkip(data, nodeId) { + return request({ + url: '/flow/definition/saveSkip?nodeId=' + nodeId, + method: 'post', + data: data + }) +} + +// 发布流程定义 +export function publish(id) { + return request({ + url: '/flow/definition/publish/' + id, + method: 'get' + }) +} + +// 取消发布流程定义 +export function unPublish(id) { + return request({ + url: '/flow/definition/unPublish/' + id, + method: 'get' + }) +} diff --git a/hh-ui/src/assets/styles/sidebar.scss b/hh-ui/src/assets/styles/sidebar.scss index ed308b8dc59238b195b9fe1d095943a519537038..abe5b6317741f27c5541591db83487798721bc72 100644 --- a/hh-ui/src/assets/styles/sidebar.scss +++ b/hh-ui/src/assets/styles/sidebar.scss @@ -1,7 +1,7 @@ #app { .main-container { - min-height: 100%; + height: 100%; transition: margin-left .28s; margin-left: $base-sidebar-width; position: relative; diff --git a/hh-ui/src/components/IconSelect/index.vue b/hh-ui/src/components/IconSelect/index.vue index 2ace1224f5bb47a5695858a29c91d67675dc2f65..a9df6fde5cd4ce645427fce36f83fd736490040f 100644 --- a/hh-ui/src/components/IconSelect/index.vue +++ b/hh-ui/src/components/IconSelect/index.vue @@ -1,14 +1,20 @@ @@ -17,6 +23,11 @@ import icons from './requireIcons' export default { name: 'IconSelect', + props: { + activeIcon: { + type: String + } + }, data() { return { name: '', @@ -43,26 +54,59 @@ export default { diff --git a/hh-ui/src/components/TopNav/index.vue b/hh-ui/src/components/TopNav/index.vue index 5f0edbef857dd49d3ff3e0372a726cf47889e8e2..9fb8dd81d5f7eb7799c6b450d22687ca877e7ca6 100644 --- a/hh-ui/src/components/TopNav/index.vue +++ b/hh-ui/src/components/TopNav/index.vue @@ -127,7 +127,13 @@ export default { window.open(key, "_blank"); } else if (!route || !route.children) { // 没有子路由路径内部打开 - this.$router.push({ path: key }); + const routeMenu = this.childrenMenus.find(item => item.path === key); + if (routeMenu && routeMenu.query) { + let query = JSON.parse(routeMenu.query); + this.$router.push({ path: key, query: query }); + } else { + this.$router.push({ path: key }); + } this.$store.dispatch('app/toggleSideBarHide', true); } else { // 显示左侧联动菜单 diff --git a/hh-ui/src/layout/index.vue b/hh-ui/src/layout/index.vue index a8a6d1df6995df67d7a3ed4bb6e1e7b02e596230..eadbb147f07c7858c66a436ef59b83569905c7cb 100644 --- a/hh-ui/src/layout/index.vue +++ b/hh-ui/src/layout/index.vue @@ -1,9 +1,9 @@ diff --git a/hh-ui/src/router/index.js b/hh-ui/src/router/index.js index b370bdd92fa1a9602dac42b38c3f3837e4a2e058..b4043c5533544afb8368eb8fbb69f949013d7ad8 100644 --- a/hh-ui/src/router/index.js +++ b/hh-ui/src/router/index.js @@ -161,6 +161,20 @@ export const dynamicRoutes = [ meta: { title: '修改生成配置', activeMenu: '/tool/gen' } } ] + }, + { + path: '/flow/flow-design', + component: Layout, + hidden: true, + permissions: ['flow:definition:design'], + children: [ + { + path: 'index/:id(\\d+)', + component: () => import('@/views/flow/definition/design'), + name: 'Design', + meta: { title: '流程设计', activeMenu: '/flow/definition' } + } + ] } ] diff --git a/hh-ui/src/views/flow/definition/design.vue b/hh-ui/src/views/flow/definition/design.vue new file mode 100644 index 0000000000000000000000000000000000000000..e3cf68d2059561391d7a313e562cf8be2561622a --- /dev/null +++ b/hh-ui/src/views/flow/definition/design.vue @@ -0,0 +1,182 @@ + + + + + diff --git a/hh-ui/src/views/flow/definition/dialog.vue b/hh-ui/src/views/flow/definition/dialog.vue index b1f42e78462a0640d9251d623a21083b712b4c7c..f6482a065b7cd0b77a5c4a6b7f88e8099ebc1c3f 100644 --- a/hh-ui/src/views/flow/definition/dialog.vue +++ b/hh-ui/src/views/flow/definition/dialog.vue @@ -12,7 +12,7 @@ - + 新增 - - 修改 - - - 删除 - - - 导出 - @@ -98,23 +66,47 @@ {{ parseTime(scope.row.createTime) }} - + + diff --git a/hh-ui/src/views/system/menu/index.vue b/hh-ui/src/views/system/menu/index.vue index 2ee25af3ccd12206a5026a22c07d2e1ef06204b2..2a83f9e9d47631657106c7b9812b5d97679a4e0b 100644 --- a/hh-ui/src/views/system/menu/index.vue +++ b/hh-ui/src/views/system/menu/index.vue @@ -134,7 +134,7 @@ trigger="click" @show="$refs['iconSelect'].reset()" > - +