| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.mybatis.spring.SqlSessionTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.sql.DataSource; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.text.MessageFormat; |
| | |
| | | IMaintainDetailService maintainDetailService; |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | |
| | | @Resource |
| | | protected SqlSessionTemplate sqlSessionTemplate; |
| | | protected DataSource dataSource; |
| | | |
| | | @Override |
| | | public Result selectById(String tableName, String id) { |
| | | try{ |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Long getCountByVersion (String maintainId, String tableName,String tableTempName,Integer fromOrderNo, Integer toOrderNo, String whereSegment) { |
| | | try{ |
| | | Maintain maintain = maintainService.selectById(maintainId); |
| | |
| | | |
| | | @Override |
| | | public String getFields(String tableName) { |
| | | return getFields(tableName, Constant.EMPTY); |
| | | return getFields(tableName, Constant.EMPTY_Str); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public String getTempFields(String tableName) { |
| | | return getTempFields(tableName, Constant.EMPTY); |
| | | return getTempFields(tableName, Constant.EMPTY_Str); |
| | | } |
| | | @Override |
| | | public String getTempFields(String tableName, String alias) { |
| | |
| | | |
| | | @Override |
| | | public Maintain uploadedData(String tableName, SysAssembleUpdateType uploadType, String userId) { |
| | | |
| | | MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("table_name",tableName)); |
| | | SysOperateLog operateLog = new SysOperateLog(); |
| | | |
| | |
| | | maintain.setTableName(tableName); |
| | | maintain.setCreateTime(new Date()); |
| | | |
| | | Connection connection = sqlSessionTemplate.getConnection(); |
| | | Connection connection; |
| | | try { |
| | | connection = dataSource.getConnection(); |
| | | connection.setAutoCommit(false); |
| | | mapper.insertMatintainDetailFromTemp(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD , DbUtils.quotedStr(Operate.create.toString())); |
| | | connection.commit(); |
| | | mapper.updateStdId( maintain.getTableName() + Constant.RECORD); |
| | | connection.commit(); |
| | | Integer aLong = mapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId())); |
| | | connection.commit(); |
| | | if (aLong == null) { |
| | | maintain.setDesp("上传数据"); |
| | | }else { |
| | | maintain.setDesp(MessageFormat.format("上传数据{0}条", aLong)); |
| | | } |
| | | maintain.setDesp(MessageFormat.format("上传数据{0}条", aLong)); |
| | | |
| | | if (uploadType.equals(SysAssembleUpdateType.All)) { |
| | | List<TableSchemaResult> tableField = mapper.getTableField(tableName); |
| | |
| | | .map(s -> s.equalsIgnoreCase(Constant.STD_ID) ? MessageFormat.format(Constant.FieldAsAlias, Constant.ID, Constant.STD_ID) : s).collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | mapper.insertRecordFromStandrad(maintain.getTableName(), maintain.getTableName() + Constant.RECORD, collect); |
| | | connection.commit(); |
| | | mapper.insertMatintainDetailFromStandrad(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD); |
| | | connection.commit(); |
| | | Integer standradCnt = mapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId())); |
| | | connection.commit(); |
| | | |
| | | if (standradCnt != null) { |
| | | maintain.setDesp(maintain.getDesp() + MessageFormat.format("删除原数据{0}条", standradCnt)); |
| | | }else { |
| | | maintain.setDesp(maintain.getDesp() + "删除原数据"); |
| | | } |
| | | maintain.setDesp(maintain.getDesp() + MessageFormat.format("删除原数据{0}条", standradCnt)); |
| | | |
| | | } |
| | | |
| | | operateLog.setCreateTime(new Date()) |
| | |
| | | .setId(DbUtils.getUUID()) |
| | | .setMaintainId(menuMapping.getId()) |
| | | .setOperate("open") |
| | | .setDesp(MessageFormat.format("上传数据{0}条", aLong)); |
| | | .setDesp("批量上传数据"); |
| | | |
| | | maintain.insert(); |
| | | connection.commit(); |
| | |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | | } |
| | | |
| | | } |
| | | finally { |
| | | if (connection != null) { |
| | | try { |
| | | connection.commit(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return maintain; |
| | | } |
| | | |