|
@@ -2,13 +2,16 @@ package com.shkpr.service.alambizplugin.dbdao.services;
|
|
|
|
|
|
import com.global.base.log.LogLevelFlag;
|
|
import com.global.base.log.LogLevelFlag;
|
|
import com.global.base.log.LogPrintMgr;
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
|
+import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyJobInfoMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyJobInfoMapper;
|
|
|
|
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyJobStatusTrackMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyThirdCopyMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyThirdCopyMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyPropertyValueMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyPropertyValueMapper;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveyJobStatusTrack;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
|
|
import org.apache.ibatis.cursor.Cursor;
|
|
import org.apache.ibatis.cursor.Cursor;
|
|
@@ -19,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.sql.Connection;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -239,10 +243,11 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
/**
|
|
/**
|
|
* 合并副表
|
|
* 合并副表
|
|
*
|
|
*
|
|
- * @param jobId 任务id
|
|
|
|
|
|
+ * @param jobId 任务id
|
|
|
|
+ * @param operator 操作人
|
|
* @return 合并结果
|
|
* @return 合并结果
|
|
*/
|
|
*/
|
|
- public Boolean mergeCopy(String jobId) {
|
|
|
|
|
|
+ public Boolean mergeCopy(String jobId, String operator) {
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
, String.format(
|
|
, String.format(
|
|
"开始合并副表,开启session和事务 任务ID:%s"
|
|
"开始合并副表,开启session和事务 任务ID:%s"
|
|
@@ -251,14 +256,19 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
);
|
|
);
|
|
long begin = System.currentTimeMillis();
|
|
long begin = System.currentTimeMillis();
|
|
//开启session
|
|
//开启session
|
|
- try (SqlSession session = sqlSessionFactory.openSession(false)) {
|
|
|
|
|
|
+ try (SqlSession sqlSession = sqlSessionFactory.openSession(false)) {
|
|
try {
|
|
try {
|
|
|
|
+ //设置手动提交
|
|
|
|
+ Connection conn = sqlSession.getConnection();
|
|
|
|
+ conn.setAutoCommit(false);
|
|
|
|
+
|
|
//获取需要的mapper
|
|
//获取需要的mapper
|
|
- GisSurveyLayerApplyMapper layerApplyMapper = session.getMapper(GisSurveyLayerApplyMapper.class);
|
|
|
|
- GisSurveyLayerApplyThirdCopyMapper layerApplyThirdCopyMapper = session.getMapper(GisSurveyLayerApplyThirdCopyMapper.class);
|
|
|
|
- GisSurveyPropertyValueMapper propertyValueMapper = session.getMapper(GisSurveyPropertyValueMapper.class);
|
|
|
|
- GisSurveyProjectInfoMapper projectInfoMapper = session.getMapper(GisSurveyProjectInfoMapper.class);
|
|
|
|
- GisSurveyJobInfoMapper jobInfoMapper = session.getMapper(GisSurveyJobInfoMapper.class);
|
|
|
|
|
|
+ GisSurveyLayerApplyMapper layerApplyMapper = sqlSession.getMapper(GisSurveyLayerApplyMapper.class);
|
|
|
|
+ GisSurveyLayerApplyThirdCopyMapper layerApplyThirdCopyMapper = sqlSession.getMapper(GisSurveyLayerApplyThirdCopyMapper.class);
|
|
|
|
+ GisSurveyPropertyValueMapper propertyValueMapper = sqlSession.getMapper(GisSurveyPropertyValueMapper.class);
|
|
|
|
+ GisSurveyProjectInfoMapper projectInfoMapper = sqlSession.getMapper(GisSurveyProjectInfoMapper.class);
|
|
|
|
+ GisSurveyJobInfoMapper jobInfoMapper = sqlSession.getMapper(GisSurveyJobInfoMapper.class);
|
|
|
|
+ GisSurveyJobStatusTrackMapper jobStatusTrackMapper = sqlSession.getMapper(GisSurveyJobStatusTrackMapper.class);
|
|
|
|
|
|
//需要合并的数量
|
|
//需要合并的数量
|
|
long mergeCount = layerApplyThirdCopyMapper.countByJobId(jobId);
|
|
long mergeCount = layerApplyThirdCopyMapper.countByJobId(jobId);
|
|
@@ -270,14 +280,47 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
|
|
|
|
//检查合并数量
|
|
//检查合并数量
|
|
if (mergeCount != layerApply) {
|
|
if (mergeCount != layerApply) {
|
|
- session.rollback();
|
|
|
|
|
|
+ sqlSession.rollback();
|
|
|
|
+ conn.rollback();
|
|
|
|
+
|
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
|
|
+ , String.format(
|
|
|
|
+ "合并副表条数错误 开始回滚操作 任务id:%s"
|
|
|
|
+ , jobId
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
//更新刷新时间
|
|
//更新刷新时间
|
|
long timestamp = System.currentTimeMillis();
|
|
long timestamp = System.currentTimeMillis();
|
|
- projectInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
|
|
|
|
- jobInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
|
|
|
|
|
|
+ int projectUpdated = projectInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
|
|
|
|
+ int jobUpdated = jobInfoMapper.updateRefreshTimeActionStatusByUid(jobId, timestamp,
|
|
|
|
+ GisSurveyImportDefine.DEFAULT_VALUE.ACTION, GisSurveyImportDefine.DEFAULT_VALUE.STATUS);
|
|
|
|
+ //写入任务状态
|
|
|
|
+ int jobStatusTrackSave = jobStatusTrackMapper.save(new GisSurveyJobStatusTrack(
|
|
|
|
+ jobId, operator,
|
|
|
|
+ GisSurveyImportDefine.DEFAULT_VALUE.ACTION, GisSurveyImportDefine.DEFAULT_VALUE.STATUS,
|
|
|
|
+ operator, timestamp));
|
|
|
|
+ //检查更新和写入
|
|
|
|
+ if (projectUpdated <= 0 || jobUpdated <= 0 || jobStatusTrackSave <= 0) {
|
|
|
|
+ sqlSession.rollback();
|
|
|
|
+ conn.rollback();
|
|
|
|
+
|
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
|
|
+ , String.format(
|
|
|
|
+ "合并副表更新任务/项目状态失败 开始回滚操作 任务id:%s"
|
|
|
|
+ , jobId
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //提交
|
|
|
|
+ sqlSession.commit();
|
|
|
|
+ conn.commit();
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
long end = System.currentTimeMillis();
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
@@ -287,10 +330,12 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
, (end - begin)
|
|
, (end - begin)
|
|
)
|
|
)
|
|
);
|
|
);
|
|
- //提交
|
|
|
|
- session.commit();
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
+ //回滚
|
|
|
|
+ sqlSession.rollback();
|
|
|
|
+
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
, String.format(
|
|
, String.format(
|
|
"合并副表失败 开始回滚操作 任务id:%s error:%s"
|
|
"合并副表失败 开始回滚操作 任务id:%s error:%s"
|
|
@@ -299,7 +344,6 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
)
|
|
)
|
|
);
|
|
);
|
|
|
|
|
|
- session.rollback();
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|