最大编号生成规则调整

This commit is contained in:
xiang2lin 2025-04-09 11:18:07 +08:00
parent fd6ec2e156
commit 0054805d6b
4 changed files with 55 additions and 24 deletions

View File

@ -22,7 +22,7 @@ public class OerDjmlDaoImpl extends MybatisGenericDao<OerDjmlEntity,String> impl
@DS("#oerDjmlEntity.dataSourceCode")
@Override
public String getMaxDjbgByGsdm(OerDjmlEntity oerDjmlEntity) {
oerDjmlEntity = (OerDjmlEntity) super.selectOne("OerDjmlEntity_list_base_djbhMax",oerDjmlEntity);
oerDjmlEntity = (OerDjmlEntity) super.selectOne("OerDjmlEntity_list_base_djbhMax_wx",oerDjmlEntity);
if(null == oerDjmlEntity){
throw new RuntimeException("查询最大单据号错误!请联系管理员");
}else{

View File

@ -71,6 +71,20 @@ GSDM,KJND,mlId
as djbh from OER_DJML where GSDM=#{gsdm} and DJBH like '%ZYBXD'+#{djdate}+'%';
</select>
<!-- 查询最大单据编号+1 指标占用时候使用-->
<select id="OerDjmlEntity_list_base_djbhMax_wx" resultMap="get-OerDjmlEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity">
select
case when
len(isnull(max(right(DJBH,'4')), '0')+1)=2 then
concat('BXD'+#{djdate}+'00',isnull(max(right(DJBH,'4')), '0')+1)
when len(isnull(max(right(DJBH,'4')), '0')+1)=1 then
concat('BXD'+#{djdate}+'000',isnull(max(right(DJBH,'4')), '0')+1)
when len(isnull(max(right(DJBH,'4')), '0')+1)=3 then
concat('BXD'+#{djdate}+'0',isnull(max(right(DJBH,'4')), '0')+1)
else concat('BXD'+#{djdate}+'',isnull(max(right(DJBH,'4')), '0')+1) end
as djbh from OER_DJML where GSDM=#{gsdm} and DJBH like '%ZYBXD'+#{djdate}+'%';
</select>
<!-- 查询最大mlid+1-->
<!--<select id="OerDjmlEntity_list_base_mlidMax" resultMap="get-OerDjmlEntity-result" parameterType="com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity">
select

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.hzya.frame.grpU8.nxproof.oerdjml.entity.OerDjmlEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
/**
* @Author:hecan
@ -34,5 +35,5 @@ public interface IOerDjmlService {
* @return java.lang.Object
**/
@DSTransactional()
Object handleOerDjml(JSONObject jsonObject);
JsonResultEntity handleOerDjml(JSONObject jsonObject);
}

View File

@ -3,6 +3,7 @@ package com.hzya.frame.grpU8.nxproof.oerdjml.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@ -35,6 +36,7 @@ import com.hzya.frame.grpU8.nxproof.pubobjflow.entity.PubObjFlowEntity;
import com.hzya.frame.mdm.entity.MdmDto;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
@ -740,7 +742,7 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
* @Date 9:54 上午 2024/8/14
**/
@Override
public Object handleOerDjml(JSONObject jsonObject) {
public JsonResultEntity handleOerDjml(JSONObject jsonObject) {
OerDjmlEntity entity = getData("jsonStr", jsonObject, OerDjmlEntity.class);
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
@ -1143,11 +1145,10 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
* @param entity
* @return java.lang.Object
**/
private Object saveOrUpdateData(String dataSourceCode,OerDjmlEntity entity) {
private JsonResultEntity saveOrUpdateData(String dataSourceCode, OerDjmlEntity entity) {
//获取主表数据
logger.info("开始处理数据:------>");
String gsdm = entity.getGsdm();
logger.info("根据公司代码查询最大单据编号,公司代码:------>"+gsdm);
if(StrUtil.isEmpty(gsdm)){
return BaseResult.getFailureMessageEntity("公司代码不能为空请排查参数gsdm");
}
@ -1163,27 +1164,42 @@ public class OerDjmlServiceImpl implements IOerDjmlService {
boolean flag = false;
String maxDjbh = null;
String maxMlId = null;
if (entity.getDjbh() == null || "".equals(entity.getDjbh())) {
OerDjmlEntity oerDjmlEntity = new OerDjmlEntity();
oerDjmlEntity.setDataSourceCode(dataSourceCode);
oerDjmlEntity.setGsdm(gsdm);
oerDjmlEntity.setDjdate(entity.getDjdate());
oerDjmlEntity.setFph(nullConvert(entity.getFph()));
maxDjbh = iOerDjmlDao.getMaxDjbgByGsdm(oerDjmlEntity);
entity.setDjbh(maxDjbh);
}else {
OerDjmlEntity oerDjmlAllEntity = new OerDjmlEntity();
oerDjmlAllEntity.setDataSourceCode(dataSourceCode);
oerDjmlAllEntity.setDjbh(entity.getDjbh());
List<OerDjmlEntity> oerDjmlAllEntities = iOerDjmlDao.queryOerDjml(oerDjmlAllEntity);
if(oerDjmlAllEntities != null && oerDjmlAllEntities.size() == 1){
flag = true;
maxDjbh = oerDjmlAllEntities.get(0).getDjbh();
maxMlId = oerDjmlAllEntities.get(0).getMlId();
}
// if (entity.getDjbh() == null || "".equals(entity.getDjbh())) {
// OerDjmlEntity oerDjmlEntity = new OerDjmlEntity();
// oerDjmlEntity.setDataSourceCode(dataSourceCode);
// oerDjmlEntity.setGsdm(gsdm);
// oerDjmlEntity.setDjdate(entity.getDjdate());
// oerDjmlEntity.setFph(nullConvert(entity.getFph()));
// maxDjbh = iOerDjmlDao.getMaxDjbgByGsdm(oerDjmlEntity);
// entity.setDjbh(maxDjbh);
// }else {
// OerDjmlEntity oerDjmlAllEntity = new OerDjmlEntity();
// oerDjmlAllEntity.setDataSourceCode(dataSourceCode);
// oerDjmlAllEntity.setDjbh(entity.getDjbh());
// List<OerDjmlEntity> oerDjmlAllEntities = iOerDjmlDao.queryOerDjml(oerDjmlAllEntity);
// if(oerDjmlAllEntities != null && oerDjmlAllEntities.size() == 1){
// flag = true;
// maxDjbh = oerDjmlAllEntities.get(0).getDjbh();
// maxMlId = oerDjmlAllEntities.get(0).getMlId();
// }
// }
//查询最大单据号
OerDjmlEntity maxDjml = new OerDjmlEntity();
maxDjml.setDataSourceCode(dataSourceCode);
maxDjml.setGsdm(gsdm);
maxDjml.setDjdate(entity.getDjdate());
maxDjbh = iOerDjmlDao.getMaxDjbgByGsdm(maxDjml);
Assert.notEmpty(maxDjbh,"生成单号出错");
OerDjmlEntity oerDjmlAllEntity = new OerDjmlEntity();
oerDjmlAllEntity.setDataSourceCode(dataSourceCode);
oerDjmlAllEntity.setDjbh(maxDjbh);
List<OerDjmlEntity> oerDjmlAllEntities = iOerDjmlDao.queryOerDjml(oerDjmlAllEntity);
if(oerDjmlAllEntities != null && oerDjmlAllEntities.size() == 1){
flag = true;
maxDjbh = oerDjmlAllEntities.get(0).getDjbh();
maxMlId = oerDjmlAllEntities.get(0).getMlId();
}
if(!flag){
//logger.info("获取最大单据编号");
OerDjmlEntity oerDjmlEntity = new OerDjmlEntity();