| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.MatCode; |
| | | import com.zy.asrs.service.MatCodeService; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | |
| | | MatCodeService matCodeService = SpringUtils.getBean(MatCodeService.class); |
| | | if (matCodeService.selectById(data.getMatNo()) == null) { |
| | | MatCode matCode = new MatCode(); |
| | | matCode.setMatNo(data.getMatNo()); |
| | | matCode.setMatName(data.getMatName()); |
| | | matCode.setBarcode(data.getBarcode()); |
| | | matCode.setStr1(data.getStr1()); |
| | | VersionUtils.setMatCode(matCode, data); |
| | | matCode.setModiTime(new Date()); |
| | | matCode.setModiUser(this.userId); |
| | | matCode.setAppeTime(new Date()); |
| | | matCode.setAppeUser(this.userId); |
| | | list.add(matCode); |
| | | if (!matCodeService.insert(matCode)) { |
| | | throw new CoolException("导入数据异常"); |
| | | } |
| | | total ++; |
| | | } |
| | | // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM |
| | | if (list.size() >= BATCH_COUNT) { |
| | | if (!matCodeService.insertBatch(list)) { |
| | | throw new CoolException("导入数据异常"); |
| | | } |
| | | // 存储完成清理 list |
| | | list.clear(); |
| | | } |
| | | // if (list.size() >= BATCH_COUNT) { |
| | | // |
| | | // // 存储完成清理 list |
| | | // list.clear(); |
| | | // } |
| | | } |
| | | |
| | | /** |