| | |
| | | List<Map<String, Object>> delUserDataList = null; |
| | | UserMergeLogItem dUserLog = null; |
| | | for (MerUserFileDto merUserFileDto : merUserFileUtilList) { |
| | | logger.info("扫描注解处理,表{},字段{}",merUserFileDto.getTableName(),merUserFileDto.getFileName()); |
| | | //获取旧用户数据 |
| | | if (sql.length() > 0){ |
| | | sql.delete(0,sql.length()); |
| | | } |
| | | sql.append(" SELECT * FROM ").append(merUserFileDto.getTableName()).append(" WHERE isDel = #{m.isDel} "); |
| | | sql.append(" AND ").append(merUserFileDto.getFileName()).append(" = #{m.delUserId} "); |
| | | sqlSentence.sqlSentence(sql.toString(), sqlMap); |
| | | delUserDataList = userMergeCommonMapper.selectListMap(sqlSentence); |
| | | if (delUserDataList == null || delUserDataList.size() < 1){ |
| | | logger.info("作废用户无数据,表{},字段{}",merUserFileDto.getTableName(),merUserFileDto.getFileName()); |
| | | continue; |
| | | } |
| | | List<String> fileNameList = merUserFileDto.getFileNameList(); |
| | | logger.info("扫描注解处理,表{},字段列表{}",merUserFileDto.getTableName(),JSON.toJSONString(fileNameList)); |
| | | if (fileNameList != null && fileNameList.size() > 0){ |
| | | for (String fileName : fileNameList) { |
| | | //获取旧用户数据 |
| | | if (sql.length() > 0){ |
| | | sql.delete(0,sql.length()); |
| | | } |
| | | sql.append(" SELECT * FROM ").append(merUserFileDto.getTableName()).append(" WHERE isDel = #{m.isDel} "); |
| | | sql.append(" AND ").append(fileName).append(" = #{m.delUserId} "); |
| | | sqlSentence.sqlSentence(sql.toString(), sqlMap); |
| | | delUserDataList = userMergeCommonMapper.selectListMap(sqlSentence); |
| | | if (delUserDataList == null || delUserDataList.size() < 1){ |
| | | logger.info("作废用户无数据,表{},字段{}",merUserFileDto.getTableName(),fileName); |
| | | continue; |
| | | } |
| | | |
| | | int sortNum = 0; |
| | | dUserLog = new UserMergeLogItem(); |
| | | dUserLog.setMergeLogId(userMergeLog.getId()); |
| | | dUserLog.setMergeLogNo(userMergeLog.getMergeNo()); |
| | | dUserLog.setPersistUserId(userMergeLog.getPersistUserId()); |
| | | dUserLog.setRepealUserId(userMergeLog.getRepealUserId()); |
| | | int sortNum = 0; |
| | | dUserLog = new UserMergeLogItem(); |
| | | dUserLog.setMergeLogId(userMergeLog.getId()); |
| | | dUserLog.setMergeLogNo(userMergeLog.getMergeNo()); |
| | | dUserLog.setPersistUserId(userMergeLog.getPersistUserId()); |
| | | dUserLog.setRepealUserId(userMergeLog.getRepealUserId()); |
| | | |
| | | dUserLog.setIsHaveOther(0); |
| | | dUserLog.setOpManType(UserMergeLogItem.OP_MAN_TYPE_DEL); |
| | | dUserLog.setOpType(UserMergeLogItem.OP_TYPE_UPDATE); |
| | | dUserLog.setIsHaveOther(0); |
| | | dUserLog.setOpManType(UserMergeLogItem.OP_MAN_TYPE_DEL); |
| | | dUserLog.setOpType(UserMergeLogItem.OP_TYPE_UPDATE); |
| | | |
| | | dUserLog.setType(merUserFileDto.getType()); |
| | | dUserLog.setTableName(merUserFileDto.getTableName()); |
| | | dUserLog.setFieldId(merUserFileDto.getFileName()); |
| | | dUserLog.setFieldName("用户标识"); |
| | | dUserLog.setBeforeValue(delUser.getId()); |
| | | dUserLog.setAfterValue(user.getId()); |
| | | for (Map<String, Object> map : delUserDataList) { |
| | | logger.info("当前处理,表{},字段{},记录标识{}",merUserFileDto.getTableName(),merUserFileDto.getFileName(),map.get("id")); |
| | | dUserLog.setSortNum(sortNum); |
| | | dUserLog.setOpContent(JSON.toJSONString(map)); |
| | | dUserLog.setType(merUserFileDto.getType()); |
| | | dUserLog.setTableName(merUserFileDto.getTableName()); |
| | | dUserLog.setFieldId(fileName); |
| | | dUserLog.setFieldName("用户标识"); |
| | | dUserLog.setBeforeValue(delUser.getId()); |
| | | dUserLog.setAfterValue(user.getId()); |
| | | for (Map<String, Object> map : delUserDataList) { |
| | | logger.info("当前表{},字段{},记录标识{}",merUserFileDto.getTableName(),fileName,map.get("id")); |
| | | dUserLog.setSortNum(sortNum); |
| | | dUserLog.setOpContent(JSON.toJSONString(map)); |
| | | |
| | | sqlMap.put("id", map.get("id")); |
| | | if (sql.length() > 0){ |
| | | sql.delete(0,sql.length()); |
| | | sqlMap.put("id", map.get("id")); |
| | | if (sql.length() > 0){ |
| | | sql.delete(0,sql.length()); |
| | | } |
| | | sql.append(" UPDATE ").append(merUserFileDto.getTableName()).append(" SET "); |
| | | sql.append(fileName).append(" = #{m.userId} WHERE id = #{m.id} "); |
| | | sqlSentence.sqlUpdate(sql.toString(), sqlMap); |
| | | if (userMergeCommonMapper.updateWhere(sqlSentence) != 1) { |
| | | logger.info("合并失败,当前表{},字段{},记录标识{}",merUserFileDto.getTableName(),fileName,map.get("id")); |
| | | dUserLog.setStatus(0); |
| | | otherService.logAdd(dUserLog); |
| | | otherService.logStatusUpdate(userMergeLog.getId(),0); |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "合并失败!"); |
| | | } |
| | | dUserLog.setStatus(1); |
| | | otherService.logAdd(dUserLog); |
| | | sortNum = sortNum + 1; |
| | | } |
| | | } |
| | | sql.append(" UPDATE ").append(merUserFileDto.getTableName()).append(" SET "); |
| | | sql.append(merUserFileDto.getFileName()).append(" = #{m.userId} WHERE id = #{m.id} "); |
| | | sqlSentence.sqlUpdate(sql.toString(), sqlMap); |
| | | if (userMergeCommonMapper.updateWhere(sqlSentence) != 1) { |
| | | logger.info("合并失败,当前处理,表{},字段{},记录标识{}",merUserFileDto.getTableName(),merUserFileDto.getFileName(),map.get("id")); |
| | | dUserLog.setStatus(0); |
| | | otherService.logAdd(dUserLog); |
| | | otherService.logStatusUpdate(userMergeLog.getId(),0); |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "合并失败!"); |
| | | } |
| | | dUserLog.setStatus(1); |
| | | otherService.logAdd(dUserLog); |
| | | sortNum = sortNum + 1; |
| | | } |
| | | } |
| | | logger.info("<-扫描含注解的表合并结束->"); |