|
@@ -2,6 +2,7 @@ package com.usoftchina.saas.commons.service.impl;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
+import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
@@ -52,7 +53,7 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
@Override
|
|
@Override
|
|
|
public String getMaxnumner(String caller, boolean update) {
|
|
public String getMaxnumner(String caller, boolean update) {
|
|
|
if (null == caller) {
|
|
if (null == caller) {
|
|
|
- return null;
|
|
|
|
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_NULLCALLER);
|
|
|
}
|
|
}
|
|
|
//单号
|
|
//单号
|
|
|
String maxcode = null;
|
|
String maxcode = null;
|
|
@@ -67,35 +68,32 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
Long userId = BaseContextHolder.getUserId();
|
|
Long userId = BaseContextHolder.getUserId();
|
|
|
//查询编号规则
|
|
//查询编号规则
|
|
|
- Maxnumbers maxnumbers = getMaxnumbers(caller);
|
|
|
|
|
- if (null != maxnumbers) {
|
|
|
|
|
- rulecode = getRulecode(maxnumbers);
|
|
|
|
|
- length = maxnumbers.getMn_number();
|
|
|
|
|
- //查询从表是否存在该规则数据
|
|
|
|
|
- Maxnumbersdetail detail = getMaxDetail(caller, rulecode);
|
|
|
|
|
- if (null == detail) {
|
|
|
|
|
- //不存在则插入
|
|
|
|
|
- detail = new Maxnumbersdetail();
|
|
|
|
|
- detail.setMd_caller(caller);
|
|
|
|
|
- detail.setMd_leadcode(rulecode);
|
|
|
|
|
- detail.setMd_maxno(maxno);
|
|
|
|
|
- detail.setCompanyId(companyId);
|
|
|
|
|
- detail.setCreateTime(new Date());
|
|
|
|
|
- detail.setCreatorId(userId);
|
|
|
|
|
- maxnumbersdetailMapper.insertSelective(detail);
|
|
|
|
|
- } else {
|
|
|
|
|
- //存在则取最大值
|
|
|
|
|
- maxno = detail.getMd_maxno() + 1;
|
|
|
|
|
- }
|
|
|
|
|
- maxcode = rulecode + createSerialNum(length, maxno);
|
|
|
|
|
- //如果以更新方式取编号
|
|
|
|
|
- if (update) {
|
|
|
|
|
- /*detail.setUpdateTime(new Date());
|
|
|
|
|
- detail.setUpdaterId(userId);
|
|
|
|
|
- detail.setMd_maxno(maxno);
|
|
|
|
|
- maxnumbersdetailMapper.updateByPrimaryKeySelective(detail);*/
|
|
|
|
|
- maxnumbersdetailMapper.updateMaxno(detail.getId(), maxno, BaseContextHolder.getCompanyId());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Maxnumbers maxnumbers = findMaxnumbers(caller);
|
|
|
|
|
+ if (maxnumbers == null) {
|
|
|
|
|
+ throw new BizException(BizExceptionCode.NULL_CODERULE);
|
|
|
|
|
+ }
|
|
|
|
|
+ rulecode = getRulecode(maxnumbers);
|
|
|
|
|
+ length = maxnumbers.getMn_number();
|
|
|
|
|
+ //查询从表是否存在该规则数据
|
|
|
|
|
+ Maxnumbersdetail detail = getMaxDetail(caller, rulecode);
|
|
|
|
|
+ if (null == detail) {
|
|
|
|
|
+ //不存在则插入
|
|
|
|
|
+ detail = new Maxnumbersdetail();
|
|
|
|
|
+ detail.setMd_caller(caller);
|
|
|
|
|
+ detail.setMd_leadcode(rulecode);
|
|
|
|
|
+ detail.setMd_maxno(maxno);
|
|
|
|
|
+ detail.setCompanyId(companyId);
|
|
|
|
|
+ detail.setCreateTime(new Date());
|
|
|
|
|
+ detail.setCreatorId(userId);
|
|
|
|
|
+ maxnumbersdetailMapper.insertSelective(detail);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //存在则取最大值
|
|
|
|
|
+ maxno = detail.getMd_maxno() + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ maxcode = rulecode + createSerialNum(length, maxno);
|
|
|
|
|
+ //如果以更新方式取编号
|
|
|
|
|
+ if (update) {
|
|
|
|
|
+ maxnumbersdetailMapper.updateMaxno(detail.getId(), maxno, BaseContextHolder.getCompanyId());
|
|
|
}
|
|
}
|
|
|
return maxcode;
|
|
return maxcode;
|
|
|
}
|
|
}
|
|
@@ -108,7 +106,7 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
* @Date: 2018/10/18
|
|
* @Date: 2018/10/18
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public String pushMaxnubmer(Integer count, String code, String caller) {
|
|
|
|
|
|
|
+ public Result<String> pushMaxnubmer(Integer count, String code, String caller) {
|
|
|
//单号
|
|
//单号
|
|
|
String maxcode = code;
|
|
String maxcode = code;
|
|
|
//公司Id
|
|
//公司Id
|
|
@@ -120,7 +118,7 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
//流水位数
|
|
//流水位数
|
|
|
Integer length = 0;
|
|
Integer length = 0;
|
|
|
//查询编号规则
|
|
//查询编号规则
|
|
|
- Maxnumbers maxnumbers = getMaxnumbers(caller);
|
|
|
|
|
|
|
+ Maxnumbers maxnumbers = findMaxnumbers(caller);
|
|
|
if (null == maxnumbers) {
|
|
if (null == maxnumbers) {
|
|
|
throw new BizException(BizExceptionCode.NULL_CODERULE);
|
|
throw new BizException(BizExceptionCode.NULL_CODERULE);
|
|
|
}
|
|
}
|
|
@@ -130,11 +128,11 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
|
throw new BizException(BizExceptionCode.CODE_EXISTS);
|
|
throw new BizException(BizExceptionCode.CODE_EXISTS);
|
|
|
}
|
|
}
|
|
|
- return maxcode;
|
|
|
|
|
|
|
+ return Result.success(rulecode);
|
|
|
}
|
|
}
|
|
|
//与规则匹配的编号
|
|
//与规则匹配的编号
|
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
|
- return getMaxnumner(caller, true);
|
|
|
|
|
|
|
+ return Result.success(getMaxnumner(caller, true));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//查询从表是否存在该规则数据
|
|
//查询从表是否存在该规则数据
|
|
@@ -152,7 +150,7 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- return maxcode;
|
|
|
|
|
|
|
+ return Result.success(maxcode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -247,7 +245,7 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
* @Author: guq
|
|
* @Author: guq
|
|
|
* @Date: 2018/10/19
|
|
* @Date: 2018/10/19
|
|
|
*/
|
|
*/
|
|
|
- private Maxnumbers getMaxnumbers(String caller) {
|
|
|
|
|
|
|
+ private Maxnumbers findMaxnumbers(String caller) {
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
return maxnumbersMapper.selectByCaller(caller, companyId);
|
|
return maxnumbersMapper.selectByCaller(caller, companyId);
|
|
|
}
|
|
}
|
|
@@ -292,8 +290,6 @@ public class MaxnumberServiceImpl extends CommonBaseServiceImpl<MaxnumbersMapper
|
|
|
} else {
|
|
} else {
|
|
|
date = "";
|
|
date = "";
|
|
|
}
|
|
}
|
|
|
-/* String date = "YYYYMM".equals(mn_rule) ? DateUtils.format(new Date(), "yyyyMM") :
|
|
|
|
|
- DateUtils.format(new Date(), "yyyyMMdd");*/
|
|
|
|
|
return rulecode += date;
|
|
return rulecode += date;
|
|
|
}
|
|
}
|
|
|
|
|
|