Commit 75421801 by 284718418@qq.com

1、执行修改批处理优化

2、修改查询数据走索引
parent f9fc005e
package cn.timer.api.service;
import cn.timer.api.bean.kqgl.PunchCardDetails;
import cn.timer.api.bean.kqgl.PunchRecord;
import java.util.List;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021/11/12
*/
public interface KqglAssoDkjlService{
/**
* 打卡记录修改批处理
* @param entityList
* @return
*/
void updateKqglAssoDkjlById(List<PunchRecord> entityList);
/**
* 打卡明细修改批处理
* @param entityList
* @return
*/
void updateKqglAssoDkmxById(List<PunchCardDetails> entityList);
}
package cn.timer.api.service.impl;
import cn.timer.api.bean.kqgl.PunchCardDetails;
import cn.timer.api.bean.kqgl.PunchRecord;
import cn.timer.api.bean.kqmk.KqglAssoDkjl;
import cn.timer.api.dao.kqgl.PunchCardDetailsMapper;
import cn.timer.api.dao.kqgl.PunchRecordMapper;
import cn.timer.api.dao.kqmk.KqglAssoDkjlMapper;
import cn.timer.api.service.KqglAssoDkjlService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2021/11/12
*/
@Slf4j
@Service
public class KqglAssoDkjlServiceImpl implements KqglAssoDkjlService {
@Autowired
private SqlSessionFactory sqlSessionFactory;
@Transactional
@Override
public void updateKqglAssoDkjlById(List<PunchRecord> entityList) {
SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
PunchRecordMapper mapper = session.getMapper(PunchRecordMapper.class);
for (int i = 0; i < entityList.size(); i++) {
mapper.updateByPrimaryKeySelective(entityList.get(i));
//每100条提交一次
if(i%100==99){
session.commit();
session.clearCache();
}
}
session.commit();
session.clearCache();
}
@Override
public void updateKqglAssoDkmxById(List<PunchCardDetails> entityList) {
SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
PunchCardDetailsMapper mapper = session.getMapper(PunchCardDetailsMapper.class);
for (int i = 0; i < entityList.size(); i++) {
mapper.updateByPrimaryKeySelective(entityList.get(i));
//每100条提交一次
if(i%100==99){
session.commit();
session.clearCache();
}
}
session.commit();
session.clearCache();
}
}
......@@ -410,10 +410,11 @@
where dkjl.attime &gt;= #{start}
and dkjl.attime &lt;= #{end}
and dkjl.user_id = #{userId,jdbcType=INTEGER}
and dkjl.`status` != 0
and dkjl.sort != 0
and dkjl.`status` > 0
and dkjl.sort > 0
and dkjl.qyid = #{qyid}
and dkjl.dkmxid != 0
and dkjl.dkmxid > 0
and dkjl.id > 0
ORDER BY dkjl.id ASC
</select>
......
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