package com.billion.main.da.service.impl; import com.billion.main.da.domain.DaTightenCollection; import com.billion.main.da.mapper.DaTightenCollectionMapper; import com.billion.main.da.service.IDaTightenCollectionService; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; /** * 拧紧采集Service业务层处理 * * @author Yi * @date 2025-05-06 */ @Service public class DaTightenCollectionServiceImpl implements IDaTightenCollectionService { private static final Logger logger = LoggerFactory.getLogger(DaTightenCollectionServiceImpl.class); @Resource private SqlSessionFactory sqlSessionFactory; @Autowired private DaTightenCollectionMapper daTightenCollectionMapper; /** * 查询拧紧采集 * * @param id 拧紧采集主键 * @return 拧紧采集 */ @Override public DaTightenCollection selectDaTightenCollectionById(Long id) { return daTightenCollectionMapper.selectDaTightenCollectionById(id); } /** * 查询拧紧采集列表 * * @param daTightenCollection 拧紧采集 * @return 拧紧采集 */ @Override public List selectDaTightenCollectionList(DaTightenCollection daTightenCollection) { return daTightenCollectionMapper.selectDaTightenCollectionList(daTightenCollection); } /** * 新增拧紧采集 * * @param daTightenCollection 拧紧采集 * @return 结果 */ @Override public int insertDaTightenCollection(DaTightenCollection daTightenCollection) { return daTightenCollectionMapper.insertDaTightenCollection(daTightenCollection); } /** * 修改拧紧采集 * * @param daTightenCollection 拧紧采集 * @return 结果 */ @Override public int updateDaTightenCollection(DaTightenCollection daTightenCollection) { return daTightenCollectionMapper.updateDaTightenCollection(daTightenCollection); } /** * 批量删除拧紧采集 * * @param ids 需要删除的拧紧采集主键 * @return 结果 */ @Override public int deleteDaTightenCollectionByIds(Long[] ids) { return daTightenCollectionMapper.deleteDaTightenCollectionByIds(ids); } /** * 删除拧紧采集信息 * * @param id 拧紧采集主键 * @return 结果 */ @Override public int deleteDaTightenCollectionById(Long id) { return daTightenCollectionMapper.deleteDaTightenCollectionById(id); } @Override public void saveBeachDaTightenCollection(List list) { SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); try { DaTightenCollectionMapper userMapper = sqlSession.getMapper(DaTightenCollectionMapper.class); list.stream().forEach(DaTightenCollection -> userMapper.insertDaTightenCollection(DaTightenCollection)); // 提交数据 sqlSession.commit(); } catch (Exception e) { logger.error("批量保存拧紧采集数据失败", e); sqlSession.rollback(); } finally { sqlSession.close(); } } }