@ -7,6 +7,7 @@ import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.service.IBasicdataCodeRecordService ;
import com.logpm.basicdata.service.IBasicdataCodeRecordService ;
import com.logpm.basicdata.service.IBasicdataCodeService ;
import com.logpm.basicdata.service.IBasicdataCodeService ;
import com.logpm.basicdata.service.IBasicdataWarehouseService ;
import com.logpm.basicdata.service.IBasicdataWarehouseService ;
import io.swagger.models.auth.In ;
import lombok.AllArgsConstructor ;
import lombok.AllArgsConstructor ;
import lombok.extern.log4j.Log4j2 ;
import lombok.extern.log4j.Log4j2 ;
import org.springblade.common.constant.CodeDesEnum ;
import org.springblade.common.constant.CodeDesEnum ;
@ -38,6 +39,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
/ * *
/ * *
* 根据类型生成编号
* 根据类型生成编号
*
* @param type
* @param type
* @return
* @return
* /
* /
@ -99,31 +101,18 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseService . getWarehouseEntityByWarehouseCode ( warehouseCode ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "############getWayBillNo: 仓库信息不存在 warehouseCode={}" , warehouseCode ) ;
return null ;
}
Calendar calendar = Calendar . getInstance ( ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( CodeNumConstant . PACKAGE , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( CodeNumConstant . PACKAGE ) ;
basicdataCodeRecordEntity . setWarehouseName ( "全仓" ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer oldNum = basicdataCodeRecordEntity . getNum ( ) ;
Integer oldNum = basicdataCodeRecordEntity . getNum ( ) ;
oldNum = oldNum + 1 ;
oldNum = oldNum + 1 ;
String packageCode = "JSD" + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( oldNum . longValue ( ) , 6 ) ;
String packageCode = "JSD" + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + CommonUtil . geFourNumber ( oldNum . longValue ( ) , 6 ) ;
basicdataCodeRecordEntity . setNum ( oldNum ) ;
basicdataCodeRecordEntity . setNum ( oldNum ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
@ -140,43 +129,29 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
log . warn ( "############getBatchPackageCodeByType: 订单号为空orderCode={}" , orderCode ) ;
log . warn ( "############getBatchPackageCodeByType: 订单号为空orderCode={}" , orderCode ) ;
return null ;
return null ;
}
}
//包条 HT+仓库拼音/超管/职能+年月日时分秒+订单索引+包条个数索引
String haxCodeByLong = CommonUtil . getHaxCodeByLong ( orderCode , 8 ) ;
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseService . getWarehouseEntityByWarehouseCode ( warehouseCode ) ;
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseService . getWarehouseEntityByWarehouseCode ( warehouseCode ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "############getWayBillNo: 仓库信息不存在 warehouseCode={}" , warehouseCode ) ;
log . warn ( "############getWayBillNo: 仓库信息不存在 warehouseCode={}" , warehouseCode ) ;
return null ;
return null ;
}
}
//包条 HT+仓库拼音/超管/职能+年月日时分秒+订单索引+包条个数索引CodeNumConstant.PACKAGE
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( CodeDesEnum . PACKAGE . getCodeNum ( ) , basicdataWarehouseEntity ) ;
Calendar calendar = Calendar . getInstance ( ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( CodeNumConstant . PACKAGE , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( CodeNumConstant . PACKAGE ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer oldNum = basicdataCodeRecordEntity . getNum ( ) ;
Integer oldNum = basicdataCodeRecordEntity . getNum ( ) ;
List < String > packageCodes = new ArrayList < > ( ) ;
List < String > packageCodes = new ArrayList < > ( ) ;
int year = Integer . parseInt ( basicdataCodeRecordEntity . getYear ( ) ) % 100 ;
for ( int i = 0 ; i < num ; i + + ) {
for ( int i = 0 ; i < num ; i + + ) {
//获取时间戳后面的时分秒
try {
Thread . sleep ( 1 ) ;
} catch ( InterruptedException e ) {
throw new RuntimeException ( e ) ;
}
String time = new String ( System . currentTimeMillis ( ) + "" ) ;
time = time . substring ( 4 ) ;
oldNum = oldNum + 1 ;
oldNum = oldNum + 1 ;
String packageCode = "HT" + warehouseCode + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + haxCodeByLong + CommonUtil . geFourNumber ( oldNum . longValue ( ) , 6 ) ;
String packageCode = "HT" + warehouseCode + year + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + basicdataCodeRecordEntity . getDay ( ) + time ;
packageCodes . add ( packageCode ) ;
packageCodes . add ( packageCode ) ;
}
}
basicdataCodeRecordEntity . setNum ( oldNum ) ;
basicdataCodeRecordEntity . setNum ( oldNum ) ;
@ -199,34 +174,50 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return warehouseCode + "ZFQS" + basicdataCodeRecordEntity . getYear ( ) + basicdataCodeRecordEntity . getMonth ( ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
/ * *
* 获取编码生成记录
*
* @param type
* @param basicdataWarehouseEntity
* @return
* /
private BasicdataCodeRecordEntity getBasicdataCodeRecordEntity ( Integer type , BasicdataWarehouseEntity basicdataWarehouseEntity ) {
Calendar calendar = Calendar . getInstance ( ) ;
Calendar calendar = Calendar . getInstance ( ) ;
//获取年份
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
Integer day = calendar . get ( Calendar . DAY_OF_MONTH ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , basicdataWarehouseEntity . getWarehouseCode ( ) , year + "" , month + "" , day + "" ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setWarehouseCode ( basicdataWarehouseEntity . getWarehouseCode ( ) ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setDay ( day + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
return basicdataCodeRecordEntity ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return warehouseCode + "ZFQS" + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
}
private String generateTrunklineTripartiteLoadCode ( Integer type , String warehouseCode , String orderCode ) {
private String generateTrunklineTripartiteLoadCode ( Integer type , String warehouseCode , String orderCode ) {
@ -242,33 +233,14 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
Calendar calendar = Calendar . getInstance ( ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return warehouseCode + f + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
return warehouseCode + f + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
}
private String generateTrunklineCarsLineCode ( Integer type , String warehouseCode , String orderCode ) {
private String generateTrunklineCarsLineCode ( Integer type , String warehouseCode , String orderCode ) {
@ -293,33 +265,16 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
Calendar calendar = Calendar . getInstance ( ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return warehouseCode + f + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
return warehouseCode + f + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
}
@ -334,32 +289,13 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
Calendar calendar = Calendar . getInstance ( ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return warehouseCode + "TH" + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
return warehouseCode + "TH" + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
}
private String generateExOrderCode ( Integer type , String warehouseCode , String orderCode ) {
private String generateExOrderCode ( Integer type , String warehouseCode , String orderCode ) {
@ -376,35 +312,15 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
Calendar calendar = Calendar . getInstance ( ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
// 获取日期
Integer day = calendar . get ( Calendar . DAY_OF_MONTH ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return "HTEX" + warehouseCode + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( day . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
return "HTEX" + warehouseCode + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getDay ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
}
private String generateTraysCode ( Integer type , String warehouseCode ) {
private String generateTraysCode ( Integer type , String warehouseCode ) {
@ -431,33 +347,14 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
String abbreviation = basicdataWarehouseEntity . getAbbreviation ( ) ;
String abbreviation = basicdataWarehouseEntity . getAbbreviation ( ) ;
Calendar calendar = Calendar . getInstance ( ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 100000 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
String trayCode = code + warehouseCode + ( year % 100 ) + inrc ;
String trayCode = code + warehouseCode + ( Integer . parseInt ( basicdataCodeRecordEntity . getYear ( ) ) % 100 ) + inrc ;
String trayName = desName + abbreviation + inrc ;
String trayName = desName + abbreviation + inrc ;
return trayCode + "&&" + trayName ;
return trayCode + "&&" + trayName ;
@ -466,6 +363,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
/ * *
/ * *
* 生成仓库对应的运单号
* 生成仓库对应的运单号
*
* @param type
* @param type
* @param warehouseCode
* @param warehouseCode
* @return
* @return
@ -482,33 +380,13 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
Calendar calendar = Calendar . getInstance ( ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return warehouseCode + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
return warehouseCode + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + CommonUtil . geFourNumber ( inrc . longValue ( ) , 5 ) ;
}
}
@ -534,6 +412,7 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
/ * *
/ * *
* 生成配送车次号编码
* 生成配送车次号编码
*
* @param type
* @param type
* /
* /
private String generateDeliveryTrainNumber ( Integer type , String warehouseCode ) {
private String generateDeliveryTrainNumber ( Integer type , String warehouseCode ) {
@ -576,32 +455,12 @@ public class BasicdataCodeServiceImpl implements IBasicdataCodeService {
return null ;
return null ;
}
}
Calendar calendar = Calendar . getInstance ( ) ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = getBasicdataCodeRecordEntity ( type , basicdataWarehouseEntity ) ;
//获取年份
Integer year = calendar . get ( Calendar . YEAR ) ;
// 获取月份(注意月份从0开始计数)
Integer month = calendar . get ( Calendar . MONTH ) + 1 ;
BasicdataCodeRecordEntity basicdataCodeRecordEntity = basicdataCodeRecordService . findEntityByCodeTypeAndWarehouseCodeAndYearAndMonth ( type , warehouseCode , year + "" , month + "" ) ;
if ( Objects . isNull ( basicdataCodeRecordEntity ) ) {
basicdataCodeRecordEntity = new BasicdataCodeRecordEntity ( ) ;
basicdataCodeRecordEntity . setCodeType ( type ) ;
basicdataCodeRecordEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
basicdataCodeRecordEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
basicdataCodeRecordEntity . setWarehouseCode ( warehouseCode ) ;
basicdataCodeRecordEntity . setYear ( year + "" ) ;
basicdataCodeRecordEntity . setMonth ( month + "" ) ;
basicdataCodeRecordEntity . setNum ( 0 ) ;
basicdataCodeRecordService . save ( basicdataCodeRecordEntity ) ;
}
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
Integer inrc = basicdataCodeRecordEntity . getNum ( ) + 1 ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordEntity . setNum ( inrc ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
basicdataCodeRecordService . updateById ( basicdataCodeRecordEntity ) ;
return "HT" + warehouseCode + year + CommonUtil . geFourNumber ( month . longValue ( ) , 2 ) + haxCodeByLong + CommonUtil . geFourNumber ( inrc . longValue ( ) , 6 ) ;
return "HT" + warehouseCode + basicdataCodeRecordEntity . getYear ( ) + CommonUtil . geFourNumberByString ( basicdataCodeRecordEntity . getMonth ( ) , 2 ) + haxCodeByLong + CommonUtil . geFourNumber ( inrc . longValue ( ) , 6 ) ;
}
}
}
}