Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
潘荣晟
2025-09-26 11:12:50 +08:00
5 changed files with 20 additions and 5 deletions

View File

@@ -19,7 +19,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
<revision>3.0.37</revision>
<revision>3.0.38</revision>
<!-- Maven 相关 -->
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>

View File

@@ -27,4 +27,5 @@ public interface FactoryMapper extends BaseMapperX<FactoryDO> {
.orderByDesc(FactoryDO::getId));
}
String selectMaxCode();
}

View File

@@ -36,6 +36,17 @@ public class FactoryServiceImpl implements FactoryService {
public FactoryRespVO createFactory(FactorySaveReqVO createReqVO) {
// 插入
FactoryDO factory = BeanUtils.toBean(createReqVO, FactoryDO.class);
// 工厂编码自动生成,格式 GC-0001,依次新增
String maxCode = factoryMapper.selectMaxCode();
if (maxCode == null) {
factory.setNumber("GC-0001");
} else {
String prefix = "GC-";
String numberPart = maxCode.substring(prefix.length());
int nextNumber = Integer.parseInt(numberPart) + 1;
String nextCode = prefix + String.format("%04d", nextNumber);
factory.setNumber(nextCode);
}
factoryMapper.insert(factory);
// 返回
return BeanUtils.toBean(factory, FactoryRespVO.class);
@@ -59,12 +70,12 @@ public class FactoryServiceImpl implements FactoryService {
}
@Override
public void deleteFactoryListByIds(List<Long> ids) {
public void deleteFactoryListByIds(List<Long> ids) {
// 校验存在
validateFactoryExists(ids);
// 删除
factoryMapper.deleteByIds(ids);
}
}
private void validateFactoryExists(List<Long> ids) {
List<FactoryDO> list = factoryMapper.selectByIds(ids);
@@ -92,7 +103,7 @@ public class FactoryServiceImpl implements FactoryService {
@Override
public void enableFactoryList(List<FactoryRespVO> saveReqVOS) {
List<FactoryDO> updateObj = BeanUtils.toBean(saveReqVOS, FactoryDO.class);
List<BatchResult> count = factoryMapper.updateById(updateObj);
List<BatchResult> count = factoryMapper.updateById(updateObj);
if (CollUtil.isEmpty(count)) {
throw exception(FACTORY_NOT_EXISTS);
}

View File

@@ -9,4 +9,7 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectMaxCode" resultType="java.lang.String">
SELECT MAX(NUM) FROM sply_fact
</select>
</mapper>

View File

@@ -129,7 +129,7 @@
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-module-base-server</artifactId>
<version>3.0.37</version>
<version>3.0.38</version>
<scope>compile</scope>
</dependency>
</dependencies>