diff --git a/docs/jsh_erp(后续更新参考这个更新).sql b/docs/jsh_erp(后续更新参考这个更新).sql index a147130d..7667405b 100644 --- a/docs/jsh_erp(后续更新参考这个更新).sql +++ b/docs/jsh_erp(后续更新参考这个更新).sql @@ -1678,3 +1678,9 @@ CREATE TABLE `jsh_tenant` ( -- 给租户表增加数据 -- ---------------------------- INSERT INTO `jsh_tenant` VALUES ('13', '63', 'jsh', '20', '2000', null); + +-- ---------------------------- +-- 时间:2019年7月10日 +-- 删除函数 +-- ---------------------------- +DROP FUNCTION IF EXISTS `_nextval`; \ No newline at end of file diff --git a/docs/jsh_erp(第一次建库请使用这个).sql b/docs/jsh_erp(第一次建库请使用这个).sql index d9fe1a7f..1747c2a5 100644 --- a/docs/jsh_erp(第一次建库请使用这个).sql +++ b/docs/jsh_erp(第一次建库请使用这个).sql @@ -1908,29 +1908,3 @@ INSERT INTO `jsh_tenant` VALUES ('17', '126', '123123', '2', '200', null); INSERT INTO `jsh_tenant` VALUES ('17', '127', '2345123', '2', '200', null); INSERT INTO `jsh_tenant` VALUES ('17', '128', 'q12341243', '2', '200', null); INSERT INTO `jsh_tenant` VALUES ('17', '130', 'jsh666', '2', '200', null); - --- ---------------------------- --- Function structure for `_nextval` --- ---------------------------- -DROP FUNCTION IF EXISTS `_nextval`; -DELIMITER ;; -CREATE FUNCTION `_nextval`(name varchar(50)) RETURNS mediumtext CHARSET utf8 -begin -declare _cur bigint; -declare _maxvalue bigint; -- 接收最大值 -declare _increment int; -- 接收增长步数 -set _increment = (select increment_val from tbl_sequence where seq_name = name); -set _maxvalue = (select max_value from tbl_sequence where seq_name = name); -set _cur = (select current_val from tbl_sequence where seq_name = name for update); -update tbl_sequence -- 更新当前值 - set current_val = _cur + increment_val - where seq_name = name ; -if(_cur + _increment >= _maxvalue) then -- 判断是都达到最大值 - update tbl_sequence - set current_val = minvalue - where seq_name = name ; -end if; -return _cur; -end -;; -DELIMITER ; diff --git a/docs/华夏ERP数据库设计汇总.xlsx b/docs/华夏ERP数据库设计汇总.xlsx index a9c3a302..2fdc8ba4 100644 Binary files a/docs/华夏ERP数据库设计汇总.xlsx and b/docs/华夏ERP数据库设计汇总.xlsx differ diff --git a/src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java b/src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java index 6cfecf33..10b5e348 100644 --- a/src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java +++ b/src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java @@ -111,10 +111,11 @@ public interface DepotHeadMapperEx { * */ void updatedepotHead(DepotHead depotHead); + void updateBuildOnlyNumber(); /** * 获得一个全局唯一的数作为订单号的追加 * */ - Long getBuildOnlyNumber(@Param("seq_name") String seq_name); + Long getBuildOnlyNumber(@Param("seq_name") String seq_name); int batchDeleteDepotHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]); diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index 1167252b..00030dc6 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -264,10 +264,12 @@ public class DepotHeadService { /** * 创建一个唯一的序列号 * */ - public String buildOnlyNumber()throws Exception{ + @Transactional(value = "transactionManager", rollbackFor = Exception.class) + public String buildOnlyNumber()throws Exception{ Long buildOnlyNumber=null; synchronized (this){ try{ + depotHeadMapperEx.updateBuildOnlyNumber(); //编号+1 buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ); }catch(Exception e){ logger.error("异常码[{}],异常提示[{}],异常[{}]", @@ -275,7 +277,6 @@ public class DepotHeadService { throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, ExceptionConstants.DATA_WRITE_FAIL_MSG); } - } if(buildOnlyNumber where Id = #{id,jdbcType=BIGINT} + + + update tbl_sequence set current_val = current_val + 1 where seq_name = 'depot_number_seq' + +