Commit 9648ed23 authored by 史志龙's avatar 史志龙

需求2(设备资产-道床管理、轨枕管理、扣件管理,编号用统一命名规则自动生成:拼音首字母+数字。(后端要生成编号,前端要去所有的相关字段))--shizhilong

parent 4ff5cd93
package org.jeecg.config.init;
import org.jeecg.modules.deviceAsset.service.ICurveManagementService;
import org.jeecg.modules.deviceAsset.service.IRailManagementService;
import org.jeecg.modules.deviceAsset.service.ISwitchManagementService;
import org.jeecg.modules.deviceAsset.service.IVerticalCurveManagementService;
import org.jeecg.modules.deviceAsset.service.*;
import org.jeecg.modules.dynamicStaticAnalysis.algorithm.AnalysisAlgorithm;
import org.jeecg.modules.dynamicStaticAnalysis.algorithm.SingleConsumer;
import org.jeecg.modules.subwayNetwork.service.ILineAliasService;
......@@ -36,6 +33,14 @@ public class InitData implements InitializingBean {
@Resource
private IRailManagementService railManagementService;
@Resource
private ITrackBedManagementService trackBedManagementService;
@Resource
private ISleeperManagementService sleeperManagementService;
@Resource
private IFastenerManagementService fastenerManagementService;
@Resource
private AnalysisAlgorithm analysisAlgorithm;
......@@ -49,7 +54,10 @@ public class InitData implements InitializingBean {
switchManagementService,
curveManagementService,
verticalCurveManagementService,
railManagementService);
railManagementService,
trackBedManagementService,
sleeperManagementService,
fastenerManagementService);
RedisLockUtil.setService(redisTemplate);
......
......@@ -19,6 +19,7 @@ import org.jeecg.modules.subwayNetwork.entity.LightRail;
import org.jeecg.modules.subwayNetwork.entity.LineAlias;
import org.jeecg.modules.subwayNetwork.service.ILightRailService;
import org.jeecg.modules.subwayNetwork.service.ILineAliasService;
import org.jeecg.modules.utils.UnitCodeUtil;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -63,6 +64,7 @@ public class FastenerManagementController extends JeecgController<FastenerManage
if (ObjectUtil.isEmpty(fastenerManagement.getId())) {
fastenerManagement.setId(UUIDGenerator.generate());
fastenerManagement.setFastenerCode(UnitCodeUtil.fastenerManagementUtil(fastenerManagement.getLineAliasId()));
this.service.save(fastenerManagement);
} else {
this.service.updateById(fastenerManagement);
......
......@@ -18,6 +18,7 @@ import org.jeecg.modules.deviceAsset.service.ISleeperManagementService;
import org.jeecg.modules.deviceAsset.service.impl.SleeperManagementServiceImpl;
import org.jeecg.modules.deviceAsset.vo.SignBoardManagementVO;
import org.jeecg.modules.deviceAsset.vo.SleeperManagementVO;
import org.jeecg.modules.utils.UnitCodeUtil;
import org.springframework.web.bind.annotation.*;
import org.jeecg.common.system.base.controller.JeecgController;
......@@ -54,6 +55,7 @@ public class SleeperManagementController extends JeecgController<SleeperManageme
public Result<String> edit(@RequestBody SleeperManagement sleeperManagement) {
if (ObjectUtil.isEmpty(sleeperManagement.getId())) {
sleeperManagement.setId(UUIDGenerator.generate());
sleeperManagement.setSleeperCode(UnitCodeUtil.sleeperManagementUtil(sleeperManagement.getLineAliasId()));
this.service.save(sleeperManagement);
} else {
this.service.updateById(sleeperManagement);
......
......@@ -20,6 +20,7 @@ import org.jeecg.modules.subwayNetwork.entity.LightRail;
import org.jeecg.modules.subwayNetwork.entity.LineAlias;
import org.jeecg.modules.subwayNetwork.service.ILightRailService;
import org.jeecg.modules.subwayNetwork.service.ILineAliasService;
import org.jeecg.modules.utils.UnitCodeUtil;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -68,6 +69,7 @@ public class TrackBedManagementController extends JeecgController<TrackBedManage
// 2.执行保存
if (ObjectUtil.isEmpty(trackBedManagement.getId())) {
trackBedManagement.setId(UUIDGenerator.generate());
trackBedManagement.setTrackBedCode(UnitCodeUtil.trackBedManagementUtil(trackBedManagement.getLineAliasId()));
this.service.save(trackBedManagement);
} else {
this.service.updateById(trackBedManagement);
......
package org.jeecg.modules.utils;
import cn.hutool.extra.pinyin.PinyinUtil;
import org.jeecg.modules.deviceAsset.entity.CurveManagement;
import org.jeecg.modules.deviceAsset.entity.RailManagement;
import org.jeecg.modules.deviceAsset.entity.SwitchManagement;
import org.jeecg.modules.deviceAsset.entity.VerticalCurveManagement;
import org.jeecg.modules.deviceAsset.service.ICurveManagementService;
import org.jeecg.modules.deviceAsset.service.IRailManagementService;
import org.jeecg.modules.deviceAsset.service.ISwitchManagementService;
import org.jeecg.modules.deviceAsset.service.IVerticalCurveManagementService;
import org.jeecg.modules.deviceAsset.entity.*;
import org.jeecg.modules.deviceAsset.service.*;
import org.jeecg.modules.subwayNetwork.entity.LineAlias;
import org.jeecg.modules.subwayNetwork.service.ILineAliasService;
......@@ -27,16 +21,28 @@ public class UnitCodeUtil {
private static IRailManagementService railManagementService;
private static ITrackBedManagementService trackBedManagementService;
private static ISleeperManagementService sleeperManagementService;
private static IFastenerManagementService fastenerManagementService;
public static void setService(ILineAliasService lineAliasService,
ISwitchManagementService switchManagementService,
ICurveManagementService curveManagementService,
IVerticalCurveManagementService verticalCurveManagementService,
IRailManagementService railManagementService) {
IRailManagementService railManagementService,
ITrackBedManagementService trackBedManagementService,
ISleeperManagementService sleeperManagementService,
IFastenerManagementService fastenerManagementService) {
UnitCodeUtil.lineAliasService = lineAliasService;
UnitCodeUtil.switchManagementService = switchManagementService;
UnitCodeUtil.curveManagementService = curveManagementService;
UnitCodeUtil.verticalCurveManagementService = verticalCurveManagementService;
UnitCodeUtil.railManagementService = railManagementService;
UnitCodeUtil.trackBedManagementService = trackBedManagementService;
UnitCodeUtil.sleeperManagementService = sleeperManagementService;
UnitCodeUtil.fastenerManagementService = fastenerManagementService;
}
/**
......@@ -170,7 +176,107 @@ public class UnitCodeUtil {
return unitCode + serialNumStr;
}
//------------------------------shizhilong---------------------------------------
/**
* 道床编码:线别码+DC+流水号(5位流水号)
* 实例:SXXDC00001
* DC - 道床编码
* 0001-流水号
*
* @param lineId 线别ID
*/
public static String trackBedManagementUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
String trackBedCode = lineAliasPinyin + "DC";
TrackBedManagement record = trackBedManagementService.lambdaQuery()
.likeRight(TrackBedManagement::getTrackBedCode, trackBedCode)
.orderByDesc(TrackBedManagement::getTrackBedCode)
.last("limit 1")
.one();
// 流水号初始化为1
Integer serialNum = 1;
if (null != record && record.getTrackBedCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getTrackBedCode().substring(record.getTrackBedCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
return trackBedCode + serialNumStr;
}
/**
* 轨枕编码:线别码+GZ+流水号(5位流水号)
* 实例:SXXGZ00001
* GZ - 轨枕编码
* 0001-流水号
*
* @param lineId 线别ID
*/
public static String sleeperManagementUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
String code = lineAliasPinyin + "GZ";
SleeperManagement record = sleeperManagementService.lambdaQuery()
.likeRight(SleeperManagement::getSleeperCode, code)
.orderByDesc(SleeperManagement::getSleeperCode)
.last("limit 1")
.one();
// 流水号初始化为1
Integer serialNum = 1;
if (null != record && record.getSleeperCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getSleeperCode().substring(record.getSleeperCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
return code + serialNumStr;
}
/**
* 扣件编码:线别码+KJ+流水号(5位流水号)
* 实例:SXXKJ00001
* KJ - 扣件编码
* 0001-流水号
*
* @param lineId 线别ID
*/
public static String fastenerManagementUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
String code = lineAliasPinyin + "KJ";
FastenerManagement record = fastenerManagementService.lambdaQuery()
.likeRight(FastenerManagement::getFastenerCode, code)
.orderByDesc(FastenerManagement::getFastenerCode)
.last("limit 1")
.one();
// 流水号初始化为1
Integer serialNum = 1;
if (null != record && record.getFastenerCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getFastenerCode().substring(record.getFastenerCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
return code + serialNumStr;
}
/**
* 将元数据前补零,补后的总长度为指定的长度,以宇符串的形式返回
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment