去掉编号函数
This commit is contained in:
@@ -1678,3 +1678,9 @@ CREATE TABLE `jsh_tenant` (
|
|||||||
-- 给租户表增加数据
|
-- 给租户表增加数据
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `jsh_tenant` VALUES ('13', '63', 'jsh', '20', '2000', null);
|
INSERT INTO `jsh_tenant` VALUES ('13', '63', 'jsh', '20', '2000', null);
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- 时间:2019年7月10日
|
||||||
|
-- 删除函数
|
||||||
|
-- ----------------------------
|
||||||
|
DROP FUNCTION IF EXISTS `_nextval`;
|
||||||
@@ -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', '127', '2345123', '2', '200', null);
|
||||||
INSERT INTO `jsh_tenant` VALUES ('17', '128', 'q12341243', '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);
|
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 ;
|
|
||||||
|
|||||||
Binary file not shown.
@@ -111,10 +111,11 @@ public interface DepotHeadMapperEx {
|
|||||||
* */
|
* */
|
||||||
void updatedepotHead(DepotHead depotHead);
|
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[]);
|
int batchDeleteDepotHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
Long buildOnlyNumber=null;
|
||||||
synchronized (this){
|
synchronized (this){
|
||||||
try{
|
try{
|
||||||
|
depotHeadMapperEx.updateBuildOnlyNumber(); //编号+1
|
||||||
buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ);
|
buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
@@ -275,7 +277,6 @@ public class DepotHeadService {
|
|||||||
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(buildOnlyNumber<BusinessConstants.SEQ_TO_STRING_MIN_LENGTH){
|
if(buildOnlyNumber<BusinessConstants.SEQ_TO_STRING_MIN_LENGTH){
|
||||||
StringBuffer sb=new StringBuffer(buildOnlyNumber.toString());
|
StringBuffer sb=new StringBuffer(buildOnlyNumber.toString());
|
||||||
|
|||||||
@@ -434,8 +434,13 @@
|
|||||||
</set>
|
</set>
|
||||||
where Id = #{id,jdbcType=BIGINT}
|
where Id = #{id,jdbcType=BIGINT}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="updateBuildOnlyNumber">
|
||||||
|
update tbl_sequence set current_val = current_val + 1 where seq_name = 'depot_number_seq'
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="getBuildOnlyNumber" resultType="java.lang.Long">
|
<select id="getBuildOnlyNumber" resultType="java.lang.Long">
|
||||||
select _nextval(#{seq_name}) from dual;
|
select current_val from tbl_sequence where seq_name = 'depot_number_seq'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="batchDeleteDepotHeadByIds">
|
<update id="batchDeleteDepotHeadByIds">
|
||||||
|
|||||||
Reference in New Issue
Block a user