|
@@ -3,11 +3,18 @@ package com.shkpr.service.alambizplugin.dbdao.services;
|
|
|
import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
|
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyJobInfoMapper;
|
|
|
import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyMapper;
|
|
|
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyThirdCopyMapper;
|
|
|
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
|
|
|
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyPropertyValueMapper;
|
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
|
|
|
import org.apache.ibatis.cursor.Cursor;
|
|
|
+import org.apache.ibatis.session.SqlSession;
|
|
|
+import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -23,18 +30,21 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyService {
|
|
|
- final
|
|
|
- GisSurveyLayerApplyMapper gisSurveyLayerApplyMapper;
|
|
|
/**
|
|
|
* log
|
|
|
*/
|
|
|
private final String mStrClassName;
|
|
|
private final String mBizType;
|
|
|
|
|
|
- public GisSurveyLayerApplyServiceImpl(GisSurveyLayerApplyMapper gisSurveyLayerApplyMapper) {
|
|
|
+ private final SqlSessionFactory sqlSessionFactory;
|
|
|
+ private final GisSurveyLayerApplyMapper layerApplyMapper;
|
|
|
+
|
|
|
+ public GisSurveyLayerApplyServiceImpl(@Qualifier("mainSqlSessionFactory") SqlSessionFactory sqlSessionFactory
|
|
|
+ , GisSurveyLayerApplyMapper layerApplyMapper) {
|
|
|
mStrClassName = "GisSurveyLayerApplyServiceImpl";
|
|
|
mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
|
- this.gisSurveyLayerApplyMapper = gisSurveyLayerApplyMapper;
|
|
|
+ this.sqlSessionFactory = sqlSessionFactory;
|
|
|
+ this.layerApplyMapper = layerApplyMapper;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -56,7 +66,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
|
);
|
|
|
long begin = System.currentTimeMillis();
|
|
|
//获取游标
|
|
|
- try (Cursor<GisSurveyLayerApplyPoint> cursor = gisSurveyLayerApplyMapper.findAddPointByProjId(projId)) {
|
|
|
+ try (Cursor<GisSurveyLayerApplyPoint> cursor = layerApplyMapper.findAddPointByProjId(projId)) {
|
|
|
//迭代游标
|
|
|
for (GisSurveyLayerApplyPoint point : cursor) {
|
|
|
//检查线程中断,并响应
|
|
@@ -103,7 +113,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
|
);
|
|
|
long begin = System.currentTimeMillis();
|
|
|
//获取游标
|
|
|
- try (Cursor<GisSurveyLayerApplyLine> cursor = gisSurveyLayerApplyMapper.findAddLineByProjId(projId)) {
|
|
|
+ try (Cursor<GisSurveyLayerApplyLine> cursor = layerApplyMapper.findAddLineByProjId(projId)) {
|
|
|
//迭代游标
|
|
|
for (GisSurveyLayerApplyLine point : cursor) {
|
|
|
//检查线程中断,并响应
|
|
@@ -150,7 +160,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
|
);
|
|
|
long begin = System.currentTimeMillis();
|
|
|
//获取游标
|
|
|
- try (Cursor<GisSurveyLayerApplyPoint> cursor = gisSurveyLayerApplyMapper.findAddPointByJobId(jobId)) {
|
|
|
+ try (Cursor<GisSurveyLayerApplyPoint> cursor = layerApplyMapper.findAddPointByJobId(jobId)) {
|
|
|
//迭代游标
|
|
|
for (GisSurveyLayerApplyPoint gisSurveyLayerApplyPoint : cursor) {
|
|
|
//检查线程中断,并响应
|
|
@@ -197,7 +207,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
|
);
|
|
|
long begin = System.currentTimeMillis();
|
|
|
//获取游标
|
|
|
- try (Cursor<GisSurveyLayerApplyLine> cursor = gisSurveyLayerApplyMapper.findAddLineByJobId(jobId)) {
|
|
|
+ try (Cursor<GisSurveyLayerApplyLine> cursor = layerApplyMapper.findAddLineByJobId(jobId)) {
|
|
|
//迭代游标
|
|
|
for (GisSurveyLayerApplyLine line : cursor) {
|
|
|
//检查线程中断,并响应
|
|
@@ -225,4 +235,74 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
|
|
|
}
|
|
|
return lines;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合并副表
|
|
|
+ *
|
|
|
+ * @param jobId 任务id
|
|
|
+ * @return 合并结果
|
|
|
+ */
|
|
|
+ public Boolean mergeCopy(String jobId) {
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
|
+ , String.format(
|
|
|
+ "开始合并副表,开启session和事务 任务ID:%s"
|
|
|
+ , jobId
|
|
|
+ )
|
|
|
+ );
|
|
|
+ long begin = System.currentTimeMillis();
|
|
|
+ //开启session
|
|
|
+ try (SqlSession session = sqlSessionFactory.openSession(false)) {
|
|
|
+ try {
|
|
|
+ //获取需要的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);
|
|
|
+
|
|
|
+ //需要合并的数量
|
|
|
+ int mergeCount = layerApplyThirdCopyMapper.countByJobId(jobId);
|
|
|
+
|
|
|
+ //合并属性
|
|
|
+ propertyValueMapper.mergeCopyByJobId(jobId);
|
|
|
+ //合并元素
|
|
|
+ int layerApply = layerApplyMapper.mergeCopyByJobId(jobId);
|
|
|
+
|
|
|
+ //检查合并数量
|
|
|
+ if (mergeCount != layerApply) {
|
|
|
+ session.rollback();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新刷新时间
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ System.out.println(timestamp);
|
|
|
+ projectInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
|
|
|
+ jobInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
|
|
|
+
|
|
|
+ long end = System.currentTimeMillis();
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
|
+ , String.format(
|
|
|
+ "合并副表成功,提交事务 任务ID:%s 用时(毫秒):%d"
|
|
|
+ , jobId
|
|
|
+ , (end - begin)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ //提交
|
|
|
+ session.commit();
|
|
|
+ return true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
|
+ , String.format(
|
|
|
+ "合并副表失败 开始回滚操作 任务id:%s error:%s"
|
|
|
+ , jobId
|
|
|
+ , e
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ session.rollback();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|