12 changed files with 1 additions and 464 deletions
			
			
		@ -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("更新失败");
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
//	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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{ | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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 { | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -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; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue