diff --git a/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java b/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java index de04e43..ae075d4 100644 --- a/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java +++ b/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java @@ -3,6 +3,8 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; import com.casic.missiles.modular.system.handler.EtlCustomHandler; +import com.casic.missiles.modular.system.model.BusSyncOrgRelation; +import com.casic.missiles.modular.system.service.IBusSyncOrgRelationService; import com.casic.missiles.modular.system.service.ISyncWellInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -28,7 +30,19 @@ */ @Autowired private EtlCustomHandler etlCustomHandler; + @Autowired + private IBusSyncOrgRelationService syncOrgRelationService; + /** + * 数据同步回调 + * + * @return 回调处理结果 + */ + @RequestMapping(value = "/sync/well") + public Object well(String orgId, Integer type) { + BusSyncOrgRelation busSyncOrgRelation = syncOrgRelationService.findRecursionPids(orgId, type); + return ResponseData.success(busSyncOrgRelation); + } /** * 数据同步回调 diff --git a/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java b/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java index de04e43..ae075d4 100644 --- a/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java +++ b/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/controller/SyncWellInfoController.java @@ -3,6 +3,8 @@ import com.casic.missiles.core.base.controller.BaseController; import com.casic.missiles.core.base.response.ResponseData; import com.casic.missiles.modular.system.handler.EtlCustomHandler; +import com.casic.missiles.modular.system.model.BusSyncOrgRelation; +import com.casic.missiles.modular.system.service.IBusSyncOrgRelationService; import com.casic.missiles.modular.system.service.ISyncWellInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -28,7 +30,19 @@ */ @Autowired private EtlCustomHandler etlCustomHandler; + @Autowired + private IBusSyncOrgRelationService syncOrgRelationService; + /** + * 数据同步回调 + * + * @return 回调处理结果 + */ + @RequestMapping(value = "/sync/well") + public Object well(String orgId, Integer type) { + BusSyncOrgRelation busSyncOrgRelation = syncOrgRelationService.findRecursionPids(orgId, type); + return ResponseData.success(busSyncOrgRelation); + } /** * 数据同步回调 diff --git a/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/service/impl/SyncWellInfoServiceImpl.java b/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/service/impl/SyncWellInfoServiceImpl.java index 0d6e19b..13be5ec 100644 --- a/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/service/impl/SyncWellInfoServiceImpl.java +++ b/casic-platform-sync/src/main/java/com/casic/missiles/modular/system/service/impl/SyncWellInfoServiceImpl.java @@ -16,6 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,6 +43,9 @@ @Autowired private IExpandComponentService expandComponentService; + @Autowired + private JdbcTemplate jdbcTemplate; + @Transactional(rollbackFor = Exception.class) @Override public void syncDepts(EtlCustomHandler etlCustomHandler, String batchId) { @@ -132,16 +136,23 @@ public void syncWells(String batchId) { //更新用户井信息 List busWellInfoList = new ArrayList<>(); + List list = getWellsByBatchId(batchId); List wellCodeList = busWellInfoService.getAllWellCode(); + //同步表中不存在井则进行废除 + + jdbcTemplate.update("UPDATE bus_well_info SET VALID = '0' WHERE WELL_CODE NOT IN (SELECT WELL_CODE from bus_sync_well_info)"); + for (BusSyncWellInfo busSyncWellInfo : list) { + //查询井信息所属运行所及所属公司 BusWellInfo busWellInfo = new BusWellInfo(); if (wellCodeList.contains(busSyncWellInfo.getWellCode().trim().toUpperCase())) { -// EntityWrapper query = new EntityWrapper(); -// query.eq("WELL_CODE", busSyncWellInfo.getWellCode().trim().toUpperCase()); - busWellInfo = busWellInfoService.selectByCode(busSyncWellInfo.getWellCode().trim().toUpperCase(),null); +// EntityWrapper query = new EntityWrapper(); +// query.eq("WELL_CODE", busSyncWellInfo.getWellCode().trim().toUpperCase()); + busWellInfo = busWellInfoService.selectByCode(busSyncWellInfo.getWellCode().trim().toUpperCase(), null); } + //井对应orgcode为空 if (ToolUtil.isEmpty(busSyncWellInfo.getResponsibleDept())) { continue; @@ -149,6 +160,7 @@ EntityWrapper codeQuery = new EntityWrapper(); codeQuery.eq("ORG_CODE", busSyncWellInfo.getResponsibleDept()); + //井对应orgcode不存在 BusSyncOrgRelation orgRelation = syncOrgRelationService.selectOne(codeQuery); if (orgRelation == null) { @@ -175,6 +187,7 @@ busWellInfo.setLngGaode(busSyncWellInfo.getLngGaode()); busWellInfo.setPosition(busSyncWellInfo.getPosition()); busWellInfo.setWellType("3"); + busWellInfo.setValid("1"); busWellInfoList.add(busWellInfo); } catch (Exception e) { e.printStackTrace(); @@ -187,4 +200,4 @@ } } -} +} \ No newline at end of file