| | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @DS("zt") |
| | | public class AttStBaseServiceImpl extends ServiceImpl<AttStBaseMapper, AttStBase> implements IAttStBaseService { |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateById(AttStBase entity) { |
| | | AttStBase base = new AttStBase(); |
| | | if (ObjectUtil.isNotEmpty(entity.getIsMainRain())&&entity.getIsMainRain().equals(1)){ |
| | | //设置雨情站为主站 |
| | | //获取该水库下的所有雨情站 |
| | | base.setResGuid(entity.getResGuid()); |
| | | base.setIsPptn(1); |
| | | List<AttStBase> list = list(Condition.getQueryWrapper(base)); |
| | | //设置所有雨量站为辅站 |
| | | list.forEach(e->{ |
| | | e.setIsMainRain(0); |
| | | }); |
| | | updateBatchById(list); |
| | | //设置该站为主站 |
| | | }else if (ObjectUtil.isNotEmpty(entity.getIsMainRsvr())&&entity.getIsMainRsvr().equals(1)){ |
| | | //设置水情站为主站 |
| | | //获取该水库下的所有水情站 |
| | | base.setResGuid(entity.getResGuid()); |
| | | base.setIsRsvr(1); |
| | | List<AttStBase> list = list(Condition.getQueryWrapper(base)); |
| | | //设置所有水情站为辅站 |
| | | list.forEach(e->{ |
| | | e.setIsMainRsvr(0); |
| | | }); |
| | | updateBatchById(list); |
| | | //设置该站为主站 |
| | | } |
| | | return super.updateById(entity); |
| | | } |
| | | } |