Commit 941754b0 authored by tianbo's avatar tianbo

refactor(tcm): 重构企业信息同步功能

- 修改 CompanyLevelEnum,增加 COMPANY 枚举项 - 重命名 refreshCompanyOrgCode 方法为 refreshSupervisionOrgCode
parent f7e4f655
...@@ -19,24 +19,17 @@ public enum CompanyLevelEnum { ...@@ -19,24 +19,17 @@ public enum CompanyLevelEnum {
HEADQUARTER("headquarter", "省级"), HEADQUARTER("headquarter", "省级"),
PREFECTURE_LEVEL("prefecture-level", "地市级"), PREFECTURE_LEVEL("prefecture-level", "地市级"),
COUNTY("county", "区县级"), COUNTY("county", "区县级"),
ORGANIZATION("organization", "基层机构"); ORGANIZATION("organization", "基层机构"),
COMPANY("company", "企业");
private String code; private String code;
private String name; private String name;
public String getCode() {
return code;
}
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
public String getName() {
return name;
}
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
......
...@@ -97,7 +97,7 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -97,7 +97,7 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
List<String> selectCompanyBySupervisionOrgCode(String oldOrgCode); List<String> selectCompanyBySupervisionOrgCode(String oldOrgCode);
void updateRedundantSupervisionOrgCodeUnit(String companyLevel, String newOrgName, String newOrgCode, String oldOrgCode); void updateRedundantSupervisionOrgCodeUnit(String newOrgName, String newOrgCode, String oldOrgCode);
void updateRedundantSupervisionOrgCodeStatistics(String newOrgCode, String oldOrgCode); void updateRedundantSupervisionOrgCodeStatistics(String newOrgCode, String oldOrgCode);
......
...@@ -61,6 +61,6 @@ public interface ITzBaseEnterpriseInfoService extends IService<TzBaseEnterpriseI ...@@ -61,6 +61,6 @@ public interface ITzBaseEnterpriseInfoService extends IService<TzBaseEnterpriseI
void refreshCompanyInfo(JSONObject dataResult, String method); void refreshCompanyInfo(JSONObject dataResult, String method);
void refreshCompanyOrgCode(JSONObject dataResult, String newOrgCode, String oldOrgCode); void refreshSupervisionOrgCode(JSONObject dataResult, String newOrgCode, String oldOrgCode);
} }
...@@ -293,11 +293,9 @@ ...@@ -293,11 +293,9 @@
update tz_base_enterprise_info update tz_base_enterprise_info
set supervise_org_code = replace(supervise_org_code, #{oldOrgCode}, #{newOrgCode}) set supervise_org_code = replace(supervise_org_code, #{oldOrgCode}, #{newOrgCode})
where supervise_org_code like concat(#{oldOrgCode}, '%'); where supervise_org_code like concat(#{oldOrgCode}, '%');
<if test="companyLevel != null and companyLevel != 'company'"> update tz_base_enterprise_info
update tz_base_enterprise_info set org_code = replace(org_code, #{oldOrgCode}, #{newOrgCode})
set org_code = replace(org_code, #{oldOrgCode}, #{newOrgCode}) where org_code like concat(#{oldOrgCode}, '%');
where org_code like concat(#{oldOrgCode}, '%');
</if>
update tzs_jg_vehicle_information update tzs_jg_vehicle_information
set org_branch_code = replace(org_branch_code, #{oldOrgCode}, #{newOrgCode}) set org_branch_code = replace(org_branch_code, #{oldOrgCode}, #{newOrgCode})
......
...@@ -87,7 +87,7 @@ public class PlatformUserTopicMessage extends EmqxListener { ...@@ -87,7 +87,7 @@ public class PlatformUserTopicMessage extends EmqxListener {
JSONObject jsonObject = JSON.parseObject(message.toString()); JSONObject jsonObject = JSON.parseObject(message.toString());
String newOrgCode = jsonObject.getString("newOrgCode"); String newOrgCode = jsonObject.getString("newOrgCode");
String oldOrgCode = jsonObject.getString("oldOrgCode"); String oldOrgCode = jsonObject.getString("oldOrgCode");
tzBaseEnterpriseInfoService.refreshCompanyOrgCode(jsonObject, newOrgCode, oldOrgCode); tzBaseEnterpriseInfoService.refreshSupervisionOrgCode(jsonObject, newOrgCode, oldOrgCode);
} catch (Exception e) { } catch (Exception e) {
log.info("处理平台推送组织架构层级变动消息失败:{}", e.getMessage()); log.info("处理平台推送组织架构层级变动消息失败:{}", e.getMessage());
e.printStackTrace(); e.printStackTrace();
......
...@@ -158,7 +158,7 @@ public class HistoryDataDealServiceImpl { ...@@ -158,7 +158,7 @@ public class HistoryDataDealServiceImpl {
JSONObject modelMap = new JSONObject(); JSONObject modelMap = new JSONObject();
modelMap.put("newModel", JSON.toJSON(parentModel)); modelMap.put("newModel", JSON.toJSON(parentModel));
//2. 处理业务表旧orgCode错误数据 //2. 处理业务表旧orgCode错误数据
baseEnterpriseInfoService.refreshCompanyOrgCode(modelMap, newOrgCode, oldOrgCode); baseEnterpriseInfoService.refreshSupervisionOrgCode(modelMap, newOrgCode, oldOrgCode);
}); });
return "success"; return "success";
} }
......
...@@ -1466,34 +1466,37 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1466,34 +1466,37 @@ public class TzBaseEnterpriseInfoServiceImpl
@Override @Override
@Transactional @Transactional
@Async @Async
public void refreshCompanyOrgCode(JSONObject dataResult, String newOrgCode, String oldOrgCode) { public void refreshSupervisionOrgCode(JSONObject dataResult, String newOrgCode, String oldOrgCode) {
log.info("开始刷新单位orgCode:{}", dataResult); log.info("开始刷新监管单位orgCode:{}", dataResult);
try { try {
if (!ValidationUtil.isEmpty(newOrgCode) && !ValidationUtil.isEmpty(oldOrgCode) && !newOrgCode.equals(oldOrgCode)) { if (!ValidationUtil.isEmpty(newOrgCode) && !ValidationUtil.isEmpty(oldOrgCode) && !newOrgCode.equals(oldOrgCode)) {
JSONObject newModel = (JSONObject) dataResult.get("newModel"); JSONObject newModel = (JSONObject) dataResult.get("newModel");
String companyLevel = newModel.getString("level"); String companyLevel = newModel.getString("level");
// 1. 查询旧属地监管部门orgCode对应所有的公司 log.info("监管单位信息:{}", newModel);
List<String> companySeqList = tzBaseEnterpriseInfoMapper.selectCompanyBySupervisionOrgCode(oldOrgCode); if (!CompanyLevelEnum.COMPANY.getCode().equals(companyLevel)) {// 只处理监管单位,企业的orgCode变更在refreshCompanyInfo中处理
// 2. 查询旧属地监管部门orgCode对应的所有设备 // 1. 查询旧属地监管部门orgCode对应所有的公司
List<String> equipmentRecordList = tzBaseEnterpriseInfoMapper.selectEquipmentBySupervisionOrgCode(oldOrgCode); List<String> companySeqList = tzBaseEnterpriseInfoMapper.selectCompanyBySupervisionOrgCode(oldOrgCode);
log.info("start-查询旧属地监管部门orgCode对应的所有设备equipmentRecordList:{},companySeqList:{}", equipmentRecordList.size(), companySeqList.size()); // 2. 查询旧属地监管部门orgCode对应的所有设备
// 3. 3.1 更新单位及业务表的监管单位orgCode List<String> equipmentRecordList = tzBaseEnterpriseInfoMapper.selectEquipmentBySupervisionOrgCode(oldOrgCode);
tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCodeUnit(companyLevel, newModel.getString("companyName"), newOrgCode, oldOrgCode); log.info("start-查询旧属地监管部门orgCode对应的所有设备equipmentRecordList:{},companySeqList:{}", equipmentRecordList.size(), companySeqList.size());
// 3.2 更新业务表统计表冗余的监管单位orgCode // 3. 3.1 更新单位及业务表的监管单位orgCode
tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCodeStatistics(newOrgCode, oldOrgCode); tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCodeUnit(newModel.getString("companyName"), newOrgCode, oldOrgCode);
log.info("end-查询旧属地监管部门orgCode对应的所有设备equipmentRecordList:{},companySeqList:{}", equipmentRecordList.size(), companySeqList.size()); // 3.2 更新业务表统计表冗余的监管单位orgCode
// 4. 更新idx_biz_view_jg_all es设备信息 tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCodeStatistics(newOrgCode, oldOrgCode);
updateEquipmentJgAllEs(newOrgCode, oldOrgCode, equipmentRecordList, newModel.getString("companyName")); log.info("end-查询旧属地监管部门orgCode对应的所有设备equipmentRecordList:{},companySeqList:{}", equipmentRecordList.size(), companySeqList.size());
// 5. 更新idx_biz_enterprise_info es企业信息 // 4. 更新idx_biz_view_jg_all es设备信息
updateEnterpriseInfoEs(newOrgCode, oldOrgCode, companySeqList); updateEquipmentJgAllEs(newOrgCode, oldOrgCode, equipmentRecordList, newModel.getString("companyName"));
// 6. 更新idx_biz_equipment_info es设备信息 // 5. 更新idx_biz_enterprise_info es企业信息
updateEquipmentInfoEs(newOrgCode, oldOrgCode, equipmentRecordList); updateEnterpriseInfoEs(newOrgCode, oldOrgCode, companySeqList);
// 6. 更新idx_biz_equipment_info es设备信息
updateEquipmentInfoEs(newOrgCode, oldOrgCode, equipmentRecordList);
}
} }
} catch (Exception e) { } catch (Exception e) {
willInfo("refreshCompanyOrgCode", dataResult, "orgCodeUpdate", e); willInfo("refreshSupervisionOrgCode", dataResult, "orgCodeUpdate", e);
log.error("刷新单位orgCode发生异常", e); log.error("刷新监管单位orgCode发生异常", e);
} }
log.info("刷新单位orgCode结束"); log.info("刷新监管单位orgCode结束");
} }
private void updateEquipmentInfoEs(String newOrgCode, String oldOrgCode, List<String> equipmentRecordList) { private void updateEquipmentInfoEs(String newOrgCode, String oldOrgCode, List<String> equipmentRecordList) {
......
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