Commit fbc69fec authored by Rensq's avatar Rensq

优化租赁库同步

parent 486fb0d4
...@@ -45,6 +45,7 @@ import org.apache.poi.ss.usermodel.Workbook; ...@@ -45,6 +45,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -357,12 +358,22 @@ public class DepositoryManageBaseServiceImpl extends ServiceImpl<DepositoryManag ...@@ -357,12 +358,22 @@ public class DepositoryManageBaseServiceImpl extends ServiceImpl<DepositoryManag
sysOrg.setCounty(depositoryInfo.getDepositoryCountyName()); sysOrg.setCounty(depositoryInfo.getDepositoryCountyName());
sysOrg.setAddress(depositoryInfo.getDepositoryAddress()); sysOrg.setAddress(depositoryInfo.getDepositoryAddress());
TSysOrg byId = tHireOrgService.getById(vo.getId()); //检查记录是否存在
if (byId == null) { TSysOrg existing = tHireOrgService.getById(vo.getId());
try {
if (existing == null) {
// 新增逻辑
sysOrg.setCreateDate(new Date()); sysOrg.setCreateDate(new Date());
sysOrg.setUpdateDate(new Date()); sysOrg.setUpdateDate(new Date());
tHireOrgService.save(sysOrg); tHireOrgService.save(sysOrg);
} else { } else {
// 更新逻辑
sysOrg.setUpdateDate(new Date());
tHireOrgService.updateById(sysOrg);
}
} catch (DataIntegrityViolationException e) {
// 捕获主键冲突(可能在高并发时发生)
log.error("主键冲突,自动转为更新模式: {}", vo.getId());
sysOrg.setUpdateDate(new Date()); sysOrg.setUpdateDate(new Date());
tHireOrgService.updateById(sysOrg); tHireOrgService.updateById(sysOrg);
} }
......
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