Commit 941754b0 authored by tianbo's avatar tianbo

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

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