Browse Source

删除无用功能,2021年机构ID进行转换的代码

zhongwei
Jone 4 months ago
parent
commit
86d9ac606f
  1. 190
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java
  2. 16
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java
  3. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java
  4. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java
  5. 16
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java
  6. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java
  7. 10
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java
  8. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java
  9. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java
  10. 10
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java
  11. 164
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java
  12. 14
      hzims-service/equipment/src/main/resources/template/template.yml

190
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java

@ -1,190 +0,0 @@
package com.hnac.hzims.equipment.controller;
import com.hnac.hzims.equipment.service.IUpdateDeptIdService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@AllArgsConstructor
@RequestMapping("/db/dataUpdate")
@Api(value = "更新所有业务数据机构ID和租户ID字段", tags = "更新所有业务数据机构ID和租户ID字段")
public class UpdateDeptIdController {
@Resource(name="equipmentUpdateDeptIdService")
private IUpdateDeptIdService equipmentUpdateDeptIdService;
@Resource(name="inspectUpdateDeptIdService")
private IUpdateDeptIdService inspectUpdateDeptIdService;
@Resource(name="operationUpdateDeptIdService")
private IUpdateDeptIdService operationUpdateDeptIdService;
@Resource(name="hzimsUpdateDeptIdService")
private IUpdateDeptIdService hzimsUpdateDeptIdService;
@Resource(name="dutyUpdateDeptIdService")
private IUpdateDeptIdService dutyUpdateDeptIdService;
@Resource(name="messageUpdateDeptIdService")
private IUpdateDeptIdService messageUpdateDeptIdService;
@Resource(name="realMonitorUpdateDeptIdService")
private IUpdateDeptIdService realMonitorUpdateDeptIdService;
@Resource(name="bladexUpdateDataService")
private IUpdateDeptIdService bladexUpdateDataService;
// @PostMapping("/updateDeptId")
// @ApiOperationSupport(order = 4)
// @ApiOperation(value = "更新所有业务数据部门机构字段", notes = "传入数据库相关信息")
// public R updateDeptId(@RequestBody UpdateDeptVo updateDeptVo) {
// if(StringUtils.isBlank(updateDeptVo.getDbName())) {
// return R.fail("请输入数据库名");
// }
// if(null == updateDeptVo.getDataMappingList() || updateDeptVo.getDataMappingList().isEmpty()) {
// return R.fail("请输入机构ID映射信息");
// }
// boolean result = false;
// switch (updateDeptVo.getDbName()) {
// case "equipment" :
// // 设备管理
// result = equipmentUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "hzims_inspect":
// // 巡检管理
// result = inspectUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "hzims_operation":
// result = operationUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "hzims":
// result = hzimsUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "duty":
// result = dutyUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "message":
// result = messageUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "realmonitor":
// result = realMonitorUpdateDeptIdService.updateDeptId(updateDeptVo);
// break;
// case "bladex":
// result = bladexUpdateDataService.updateDeptId(updateDeptVo);
// break;
// default:
// break;
//
// }
// if(result) {
// return R.success("成功");
// } else {
// return R.fail("更新失败");
// }
// }
//
// @PostMapping("/updateTenantId")
// @ApiOperationSupport(order = 5)
// @ApiOperation(value = "更新所有业务数据租户ID字段", notes = "传入数据库相关信息")
// public R updateTenantId(@RequestBody UpdateTenantVo updateTenantVo) {
// if(StringUtils.isBlank(updateTenantVo.getDbName())) {
// return R.fail("请输入数据库名");
// }
// if(null == updateTenantVo.getDataMappingList() || updateTenantVo.getDataMappingList().isEmpty()) {
// return R.fail("请输入机构ID映射信息");
// }
// boolean result = false;
// switch (updateTenantVo.getDbName()) {
// case "equipment" :
// // 设备管理
// result = equipmentUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "hzims_inspect":
// // 巡检管理
// result = inspectUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "hzims_operation":
// result = operationUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "hzims":
// result = hzimsUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "duty":
// result = dutyUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "message":
// result = messageUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "realmonitor":
// result = realMonitorUpdateDeptIdService.updateTenantId(updateTenantVo);
// break;
// case "bladex" :
// result = bladexUpdateDataService.updateTenantId(updateTenantVo);
// break;
// default:
// break;
//
// }
// if(result) {
// return R.success("成功");
// } else {
// return R.fail("更新失败");
// }
// }
//
// @PostMapping("/updateDeptIdByTenantId")
// @ApiOperationSupport(order = 5)
// @ApiOperation(value = "根据租户ID更新机构ID", notes = "传入数据库相关信息")
// public R updateDeptIdByTenantId(@RequestBody UpdateDeptIdByTenantIdVO updateDeptIdByTenantIdVO) {
// if(StringUtils.isBlank(updateDeptIdByTenantIdVO.getDbName())) {
// return R.fail("请输入数据库名");
// }
// if(null == updateDeptIdByTenantIdVO.getDeptAndTenantIdList() || updateDeptIdByTenantIdVO.getDeptAndTenantIdList().isEmpty()) {
// return R.fail("请输入机构ID映射信息");
// }
// boolean result = false;
//
// switch (updateDeptIdByTenantIdVO.getDbName()) {
// case "equipment" :
// // 设备管理
// result = equipmentUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "hzims_inspect":
// // 巡检管理
// result = inspectUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "hzims_operation":
// result = operationUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "hzims":
// result = hzimsUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "duty":
// result = dutyUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "message":
// result = messageUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "realmonitor":
// result = realMonitorUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// case "bladex" :
// result = bladexUpdateDataService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO);
// break;
// default:
// break;
//
// }
// if(result) {
// return R.success("成功");
// } else {
// return R.fail("更新失败");
// }
// }
}

16
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java

@ -1,16 +0,0 @@
package com.hnac.hzims.equipment.service;
import com.hnac.hzims.equipment.vo.UpdateDeptIdByTenantIdVO;
import com.hnac.hzims.equipment.vo.UpdateDeptVo;
import com.hnac.hzims.equipment.vo.UpdateTenantVo;
import java.util.List;
public interface IUpdateDeptIdService {
boolean updateDeptId(UpdateDeptVo updateDeptVo);
boolean updateTenantId(UpdateTenantVo updateTenantVo);
boolean updateDeptIdByTenantId(UpdateDeptIdByTenantIdVO updateDeptIdByTenantIdVO);
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java

@ -1,9 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Service;
@Service("bladexUpdateDataService")
@DS("bladex")
public class BladexUpdateDataServiceImpl extends UpdateDeptIdServiceImpl {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java

@ -1,9 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Service;
@Service("dutyUpdateDeptIdService")
@DS("duty")
public class DutyUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl {
}

16
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java

@ -1,16 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.mapper.UpdateDeptIdMapper;
import com.hnac.hzims.equipment.service.IUpdateDeptIdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@Service("equipmentUpdateDeptIdService")
@Primary
@DS("equipment")
public class EquipmentUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java

@ -1,9 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Service;
@Service("hzimsUpdateDeptIdService")
@DS("hzims")
public class HzimsUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl{
}

10
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java

@ -1,10 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Service;
@Service("inspectUpdateDeptIdService")
@DS("inspect")
public class InspectUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java

@ -1,9 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Service;
@Service("messageUpdateDeptIdService")
@DS("message")
public class MessageUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java

@ -1,9 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Service;
@Service("operationUpdateDeptIdService")
@DS("operation")
public class OperationUpdateIdServiceImpl extends UpdateDeptIdServiceImpl {
}

10
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java

@ -1,10 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@Service("realMonitorUpdateDeptIdService")
@DS("realMonitor")
public class RealMonitorUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl {
}

164
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java

@ -1,164 +0,0 @@
package com.hnac.hzims.equipment.service.impl;
import com.google.common.base.Joiner;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.mapper.UpdateDeptIdMapper;
import com.hnac.hzims.equipment.service.IUpdateDeptIdService;
import com.hnac.hzims.equipment.vo.DataMappingVo;
import com.hnac.hzims.equipment.vo.UpdateDeptIdByTenantIdVO;
import com.hnac.hzims.equipment.vo.UpdateDeptVo;
import com.hnac.hzims.equipment.vo.UpdateTenantVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
public class UpdateDeptIdServiceImpl extends ServiceImpl<UpdateDeptIdMapper, EmInfoEntity> implements IUpdateDeptIdService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateDeptId(UpdateDeptVo updateDeptVo) {
Map<String, Object> map = new HashMap<>();
if(StringUtils.isNotBlank(updateDeptVo.getTableName())) {
// 更新具体的表的字段
if("blade_user".equals(updateDeptVo.getTableName())){
List<Map<String, Object>> list = baseMapper.getBladeUserList();
if(null != list && !list.isEmpty()) {
for(Map<String, Object> mapTemp : list) {
String deptIds = (String)mapTemp.get("dept_ids");
deptIds = searchDeptId(deptIds, updateDeptVo.getDataMappingList());
mapTemp.put("dept_ids", deptIds);
String deptId = (String)mapTemp.get("dept_id");
deptId = searchDeptId(deptId, updateDeptVo.getDataMappingList());
map.put("dept_id", deptId);
baseMapper.updateBladeUserDeptIds(mapTemp);
}
}
} else {
map.put("tableName", updateDeptVo.getTableName());
map.put("columnName", updateDeptVo.getColumnName());
updateDeptVo.getDataMappingList().stream().forEach(item -> {
map.put("oldDeptId", item.getOldId());
map.put("newDeptId", item.getNewId());
baseMapper.updateTableDeptId(map);
});
}
} else {
// 更新整个库的create_dept字段
List<Map<String, Object>> tableList = baseMapper.getTablesList();
if(null != tableList && !tableList.isEmpty()) {
for(Map<String, Object> item : tableList) {
map.put("tableName", item.get("TABLE_NAME"));
map.put("columnName", "create_dept");
if(item.get("TABLE_NAME").toString().toLowerCase().indexOf("log") >= 0 || item.get("TABLE_NAME").toString().toLowerCase().indexOf("copy1") >= 0) {
continue;
}
List<Map<String, Object>> tableColumns = baseMapper.getTableColumnList(item);
boolean flag = false;
if(null != tableColumns && !tableColumns.isEmpty()) {
for(Map<String, Object> columnMap : tableColumns) {
if("create_dept".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) {
flag = true;
break;
}
}
}
if(flag) {
updateDeptVo.getDataMappingList().stream().forEach(item1 -> {
map.put("oldDeptId", item1.getOldId());
map.put("newDeptId", item1.getNewId());
baseMapper.updateTableDeptId(map);
});
}
}
}
}
return true;
}
private String searchDeptId(String deptIds, List<DataMappingVo> dataMappingList) {
if(StringUtils.isNotBlank(deptIds)) {
String[] deptIdsArr =deptIds.split(",");
for(int i = 0; i< deptIdsArr.length; i++) {
for(DataMappingVo dataMappingVo : dataMappingList) {
if(deptIdsArr[i].equals(dataMappingVo.getOldId().toString())) {
deptIdsArr[i] = dataMappingVo.getNewId().toString();
break;
}
}
}
return Joiner.on(',').join(deptIdsArr);
}
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateTenantId(UpdateTenantVo updateTenantVo) {
Map<String, Object> map = new HashMap<>();
List<Map<String, Object>> tableList = baseMapper.getTablesList();
if(null != tableList && !tableList.isEmpty()) {
for(Map<String, Object> item : tableList) {
if(item.get("TABLE_NAME").toString().toLowerCase().indexOf("log") >= 0 || item.get("TABLE_NAME").toString().toLowerCase().indexOf("copy1") >= 0) {
continue;
}
map.put("tableName", item.get("TABLE_NAME"));
map.put("columnName", "tenant_id");
List<Map<String, Object>> tableColumns = baseMapper.getTableColumnList(item);
boolean flag = false;
if(null != tableColumns && !tableColumns.isEmpty()) {
for(Map<String, Object> columnMap : tableColumns) {
if("tenant_id".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) {
flag = true;
break;
}
}
}
if(flag) {
updateTenantVo.getDataMappingList().stream().forEach(item1 -> {
map.put("oldTenantId", item1.getOldId());
map.put("newTenantId", item1.getNewId());
baseMapper.updateTableTenantId(map);
});
}
}
}
return true;
}
@Override
public boolean updateDeptIdByTenantId(UpdateDeptIdByTenantIdVO updateDeptIdByTenantIdVO) {
Map<String, Object> map = new HashMap<>();
List<Map<String, Object>> tableList = baseMapper.getTablesList();
if(null != tableList && !tableList.isEmpty()) {
for(Map<String, Object> item : tableList) {
if(item.get("TABLE_NAME").toString().toLowerCase().indexOf("log") >= 0 || item.get("TABLE_NAME").toString().toLowerCase().indexOf("copy1") >= 0) {
continue;
}
map.put("tableName", item.get("TABLE_NAME"));
List<Map<String, Object>> tableColumns = baseMapper.getTableColumnList(item);
int hasColumnCount = 0;
if(null != tableColumns && !tableColumns.isEmpty()) {
for(Map<String, Object> columnMap : tableColumns) {
if("tenant_id".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) {
hasColumnCount++;
}
if("create_dept".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) {
hasColumnCount++;
}
}
}
if(hasColumnCount == 2) {
updateDeptIdByTenantIdVO.getDeptAndTenantIdList().stream().forEach(item1 -> {
map.put("tenantId", item1.getTenantId());
map.put("deptId", item1.getDeptId());
baseMapper.updateDeptIdByTenantId(map);
});
}
}
}
return true;
}
}

14
hzims-service/equipment/src/main/resources/template/template.yml

@ -19,18 +19,6 @@ spring:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} password: ${hzinfo.db.busines.password}
inspect:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password}
hzims:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password}
bladex:
url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password}
#oss配置 #oss配置
oss: oss:
@ -159,4 +147,4 @@ url:
deLianUrl: http://iot.delianfa.com:8081/api/Docking/DockingData deLianUrl: http://iot.delianfa.com:8081/api/Docking/DockingData
deLian: deLian:
hostId: 400184 hostId: 400184
passWord: 654321 passWord: 654321

Loading…
Cancel
Save