Browse Source

# 站点新增补充排序字段自增

zhongwei
haungxing 7 months ago
parent
commit
9af51c29eb
  1. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java
  2. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml
  3. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java

@ -285,4 +285,10 @@ public interface StationMapper extends UserDataScopeBaseMapper<StationEntity> {
*/ */
List<StationEntity> listWithOutAuth(@Param(Constants.WRAPPER) Wrapper wrapper); List<StationEntity> listWithOutAuth(@Param(Constants.WRAPPER) Wrapper wrapper);
List<StationsVo> stationVoCount(); List<StationsVo> stationVoCount();
/**
* 获取站点排序最大值
* @return 排序最大值
*/
Integer getMaxSort();
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml

@ -464,4 +464,7 @@
</if> </if>
</where> </where>
</select> </select>
<select id="getMaxSort" resultType="java.lang.Integer">
select max(`sort`) from `hzims_station` where `is_deleted` = 0
</select>
</mapper> </mapper>

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -75,8 +75,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
private final IStationAttributeService stationAttributeService; private final IStationAttributeService stationAttributeService;
private final IStationPushConfigService stationPushConfigService; private final IStationPushConfigService stationPushConfigService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void buildStation(StationEntity req) { public void buildStation(StationEntity req) {
@ -683,7 +681,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
} }
@Override @Override
public boolean save(StationEntity entity) { public synchronized boolean save(StationEntity entity) {
// 检查两票标识唯一性 // 检查两票标识唯一性
if(StringUtil.isNotBlank(entity.getSignage())) { if(StringUtil.isNotBlank(entity.getSignage())) {
LambdaQueryWrapper<StationEntity> wq = Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getSignage, entity.getSignage()); LambdaQueryWrapper<StationEntity> wq = Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getSignage, entity.getSignage());
@ -692,6 +690,8 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
throw new ServiceException("站点两票标识平台已存在,请检查后重新填入!"); throw new ServiceException("站点两票标识平台已存在,请检查后重新填入!");
}); });
} }
Integer maxSort = this.baseMapper.getMaxSort();
entity.setSort(Optional.ofNullable(maxSort).map(sort -> sort + 1).orElse(1));
// 创建站点机构 // 创建站点机构
this.createStationDept(entity); this.createStationDept(entity);
return super.save(entity); return super.save(entity);

Loading…
Cancel
Save