Commit 61f16ac2 by zhangkb

判断报表3数据是否存在地方加同步锁机制,防止重复数据插入。

parent 6a786477
...@@ -130,11 +130,9 @@ public class BeforeCompareUnitCalActor extends AbstractActor{ ...@@ -130,11 +130,9 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
indicatorsReportService.deleteReportThreeDataByParam(currentDate, indicatorsReportService.deleteReportThreeDataByParam(currentDate,
new ArrayList<String>(compareObjMap.keySet()),code); new ArrayList<String>(compareObjMap.keySet()),code);
for(CompareUnitDef unitDef : currentCompareUnitDef) { for(CompareUnitDef unitDef : currentCompareUnitDef) {
synchronized(this){
indicatorsReportService.dealDriveIndReportThreeData( indicatorsReportService.dealDriveIndReportThreeData(
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")), unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
unitDef.getDate(),code); unitDef.getDate(),code);
}
} }
} }
if("0".equals(isTest)) { if("0".equals(isTest)) {
......
...@@ -153,9 +153,13 @@ public class IndicatorsReportService { ...@@ -153,9 +153,13 @@ public class IndicatorsReportService {
findByIndIdAndDateAndCompareIdAndSort(indId, date, compareId,code); findByIndIdAndDateAndCompareIdAndSort(indId, date, compareId,code);
if(!calResults.isEmpty()) { if(!calResults.isEmpty()) {
for(DriveIndCalResultDef calResult : calResults) { for(DriveIndCalResultDef calResult : calResults) {
//判断是否存在 IndicatorsReportThree indReportData = null;
IndicatorsReportThree indReportData = reportThreeMapper.getByParam( //多线程查询会导致重复数据插入问题
calResult.getCompareObj(), date, type, code); synchronized(this){
//判断是否存在
indReportData = reportThreeMapper.getByParam(
calResult.getCompareObj(), date, type, code);
}
if(indReportData == null) { if(indReportData == null) {
indReportData = new IndicatorsReportThree(); indReportData = new IndicatorsReportThree();
} }
......
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