Commit 5354147dcd9836e0a540c5bd6de0984ef50b606b
1 parent
208d4b01
update...
Showing
1 changed file
with
7 additions
and
34 deletions
src/main/java/com/bsth/server_rs/thread/RfidCardInfoPersistenceThread.java
| ... | ... | @@ -7,7 +7,6 @@ import com.bsth.server_rs.base_info.person.buffer.PersonBufferData; |
| 7 | 7 | import org.slf4j.Logger; |
| 8 | 8 | import org.slf4j.LoggerFactory; |
| 9 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 11 | 10 | import org.springframework.jdbc.core.JdbcTemplate; |
| 12 | 11 | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| 13 | 12 | import org.springframework.stereotype.Component; |
| ... | ... | @@ -15,8 +14,6 @@ import org.springframework.transaction.TransactionDefinition; |
| 15 | 14 | import org.springframework.transaction.TransactionStatus; |
| 16 | 15 | import org.springframework.transaction.support.DefaultTransactionDefinition; |
| 17 | 16 | |
| 18 | -import java.sql.PreparedStatement; | |
| 19 | -import java.sql.SQLException; | |
| 20 | 17 | import java.util.ArrayList; |
| 21 | 18 | import java.util.List; |
| 22 | 19 | |
| ... | ... | @@ -59,7 +56,7 @@ public class RfidCardInfoPersistenceThread extends Thread{ |
| 59 | 56 | |
| 60 | 57 | if(list.size() == 0) |
| 61 | 58 | return; |
| 62 | - final List<Personnel> finalList = list; | |
| 59 | + //final List<Personnel> finalList = list; | |
| 63 | 60 | |
| 64 | 61 | //编程式事务 |
| 65 | 62 | DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); |
| ... | ... | @@ -68,20 +65,9 @@ public class RfidCardInfoPersistenceThread extends Thread{ |
| 68 | 65 | TransactionStatus status = tran.getTransaction(def); |
| 69 | 66 | try{ |
| 70 | 67 | |
| 71 | - jdbcTemplate.update("update bsth_c_personnel set id_rfid=?, tag_rfid=? where job_code=?", new BatchPreparedStatementSetter() { | |
| 72 | - @Override | |
| 73 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 74 | - Personnel p = finalList.get(i); | |
| 75 | - ps.setString(1, p.getIdRfid()); | |
| 76 | - ps.setString(2, p.getTagRfid()); | |
| 77 | - ps.setString(3, p.getJobCode()); | |
| 78 | - } | |
| 79 | - | |
| 80 | - @Override | |
| 81 | - public int getBatchSize() { | |
| 82 | - return finalList.size(); | |
| 83 | - } | |
| 84 | - }); | |
| 68 | + for(Personnel personnel : list){ | |
| 69 | + jdbcTemplate.update("update bsth_c_personnel set id_rfid=?, tag_rfid=? where job_code=?", personnel.getIdRfid(), personnel.getTagRfid(), personnel.getJobCode()); | |
| 70 | + } | |
| 85 | 71 | |
| 86 | 72 | tran.commit(status); |
| 87 | 73 | }catch (Exception e){ |
| ... | ... | @@ -106,7 +92,6 @@ public class RfidCardInfoPersistenceThread extends Thread{ |
| 106 | 92 | |
| 107 | 93 | if(list.size() == 0) |
| 108 | 94 | return; |
| 109 | - final List<Car> finalList = list; | |
| 110 | 95 | |
| 111 | 96 | //编程式事务 |
| 112 | 97 | DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); |
| ... | ... | @@ -114,21 +99,9 @@ public class RfidCardInfoPersistenceThread extends Thread{ |
| 114 | 99 | def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); |
| 115 | 100 | TransactionStatus status = tran.getTransaction(def); |
| 116 | 101 | try{ |
| 117 | - | |
| 118 | - jdbcTemplate.update("update bsth_c_cars set id_rfid=?, tag_rfid=? where nbbm=?", new BatchPreparedStatementSetter() { | |
| 119 | - @Override | |
| 120 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 121 | - Car c = finalList.get(i); | |
| 122 | - ps.setString(1, c.getIdRfid()); | |
| 123 | - ps.setString(2, c.getTagRfid()); | |
| 124 | - ps.setString(3, c.getNbbm()); | |
| 125 | - } | |
| 126 | - | |
| 127 | - @Override | |
| 128 | - public int getBatchSize() { | |
| 129 | - return finalList.size(); | |
| 130 | - } | |
| 131 | - }); | |
| 102 | + for(Car car : list){ | |
| 103 | + jdbcTemplate.update("update bsth_c_cars set id_rfid=?, tag_rfid=? where inside_code=?", car.getIdRfid(),car.getTagRfid(),car.getNbbm()); | |
| 104 | + } | |
| 132 | 105 | |
| 133 | 106 | tran.commit(status); |
| 134 | 107 | }catch (Exception e){ | ... | ... |