Commit f89308cd authored by frank.xa.zhang's avatar frank.xa.zhang

fixed copy report template issue

parent ba31817d
......@@ -390,12 +390,14 @@ public class TemplateGroupServiceImpl extends AbstractService implements Templat
templateGroup.setId(newGroupID);
templateGroup.setCreateTime(now);
templateGroup.setUpdateTime(now);
templateGroup.setName(templateGroupDto.getName());
templateGroupMapper.insertSelective(templateGroup);
List<Template> templateList = templateDao.getByGroupID(groupID);
templateList.stream().forEach(item -> {
Long itemID = item.getId();
Long newItemID = distributedIDService.nextId();
item.setId(newItemID);
item.setTemplateGroupId(newGroupID);
item.setCreateTime(now);
item.setUpdateTime(now);
templateMapper.insertSelective(item);
......@@ -412,7 +414,7 @@ public class TemplateGroupServiceImpl extends AbstractService implements Templat
idMapper.put(cellID, newCellID);
return cell;
}).collect(Collectors.toList()), CommonUtils.BATCH_NUM);
tmpList.forEach(list -> cellTemplateMapper.batchInsert(list));
tmpList.forEach(list -> cellTemplateMapper.batchInsert2(list));
List<CellTemplateConfig> configList = cellTemplateConfigDao.getByTemplateID(itemID);
List<List<CellTemplateConfig>> tmpConfigList = CommonUtils.subListWithLen(configList.stream().map(cell -> {
......
......@@ -21,8 +21,6 @@ public class DataMigration extends CommonIT {
@Autowired
private JdbcTemplate jdbcTemplate;
private List<Map<String, Object>> template20180622List;
private List<Map<String, Object>> templateList;
......@@ -33,12 +31,18 @@ public class DataMigration extends CommonIT {
private List<Map<String, Object>> cellTemplate20180622List;
//1. 这个是原本的id
String templateGroupId = "'FA37FBE3-31D0-4A5C-9356-CF66FE8CE76D'";
//2.这个是新的templategroupid
Long templateGroupIdLong = 15081298737631232L;
@Test
public void doMigrationTemplateGroup() {
String sql = "Select * from TemplateGroup_20180622";
String sql = "Select * from TemplateGroup_20180622 where id=" + templateGroupId;
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
sql = "DELETE FROM template_group";
jdbcTemplate.execute(sql);
// sql = "DELETE FROM template_group";
// jdbcTemplate.execute(sql);
TemplateGroup templateGroup;
for (Map<String, Object> item : queryForList) {
templateGroup = new TemplateGroup();
......@@ -60,10 +64,10 @@ public class DataMigration extends CommonIT {
@Test
public void doMigrationTemplate() {
String sql = "Select * from Template_20180622";
String sql = "Select * from Template_20180622 where TemplateGroupID=" + templateGroupId;
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
sql = "DELETE FROM template";
jdbcTemplate.execute(sql);
// sql = "DELETE FROM template";
// jdbcTemplate.execute(sql);
Template template;
for (Map<String, Object> item : queryForList) {
template = new Template();
......@@ -103,18 +107,19 @@ public class DataMigration extends CommonIT {
} catch (Exception e) {
return 0L;
}
}
//todo:cell_template --220081
@Test
public void doMigrationCellTemplate() {
String sql = "SELECT * FROM CellTemplate_20180622 WHERE ReportTemplateID IN (SELECT ID FROM Template_20180622 WHERE TemplateGroupID IN('1E741076-2CBF-448A-A31C-B92C9ECB29D3','04B3B25D-131F-4214-9EDE-3B3858BE196A') AND path LIKE '%VatTemplate/DefaultVersion/%')";
String sql = "SELECT * FROM CellTemplate_20180622 WHERE ReportTemplateID IN " +
"(SELECT ID FROM Template_20180622 WHERE TemplateGroupID IN(" + templateGroupId + ") " +
" AND path LIKE '%VatTemplate/DefaultVersion/%')";
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
System.out.println(sql);
sql = "DELETE FROM cell_template";
System.out.println(sql);
jdbcTemplate.execute(sql);
// sql = "DELETE FROM cell_template";
// System.out.println(sql);
// jdbcTemplate.execute(sql);
CellTemplate cellTemplate;
cellTemplates = new ArrayList<>();
List<CellTemplate> cellTemplateList = new ArrayList<>();
......@@ -188,13 +193,13 @@ public class DataMigration extends CommonIT {
// && MapUtils.getString(a, "create_time").equals(createTime))
// .findFirst().get();
Template template = templates.stream()
.filter(a->a.getName().equals(name)&&a.getCode().equals(code)&&a.getCreateTime().equals(DateUtils.strToDateLong(createTime)))
Template template = templates.stream()
.filter(a -> a.getName().equals(name) && a.getCode().equals(code) && a.getCreateTime().equals(DateUtils.strToDateLong(createTime)) && a.getTemplateGroupId().equals(templateGroupIdLong))
.findFirst().get();
//sql = "SELECT id from template a WHERE create_time='" + createTime + "' AND `name`='" + name + "' AND code='" + code + "'";
//System.out.println(sql);
//result = jdbcTemplate.queryForMap(sql);
Long newId =template.getId();
Long newId = template.getId();
//templateList.remove(item);
return newId;
} catch (Exception e) {
......@@ -289,7 +294,7 @@ public class DataMigration extends CommonIT {
"WHERE ReportTemplateID IN(SELECT\n" +
" ID\n" +
" FROM Template_20180622\n" +
" WHERE TemplateGroupID IN('1E741076-2CBF-448A-A31C-B92C9ECB29D3','04B3B25D-131F-4214-9EDE-3B3858BE196A')\n" +
" WHERE TemplateGroupID IN(" + templateGroupId + ")\n" +
" AND path LIKE '%VatTemplate/DefaultVersion/%')\n" +
" AND celltemplateid IN(SELECT\n" +
" id\n" +
......@@ -297,19 +302,21 @@ public class DataMigration extends CommonIT {
" WHERE ReportTemplateID IN(SELECT\n" +
" ID\n" +
" FROM Template_20180622\n" +
" WHERE TemplateGroupID IN('1E741076-2CBF-448A-A31C-B92C9ECB29D3','04B3B25D-131F-4214-9EDE-3B3858BE196A')\n" +
" WHERE TemplateGroupID IN(" + templateGroupId + ")\n" +
" AND path LIKE '%VatTemplate/DefaultVersion/%'))";
System.out.println(sql);
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
sql = "DELETE FROM cell_template_config";
System.out.println(sql);
jdbcTemplate.execute(sql);
// sql = "DELETE FROM cell_template_config";
// System.out.println(sql);
// jdbcTemplate.execute(sql);
sql = "SELECT ID,`Name`,Code,CreateTime from Template_20180622 ";
template20180622List = jdbcTemplate.queryForList(sql);
templates = templateMapper.selectByExample(new TemplateExample());
cellTemplates = cellTemplateMapper.selectByExample(new CellTemplateExample());
sql = "SELECT ID,ReportTemplateID,RowIndex,ColumnIndex from CellTemplate_20180622 WHERE ReportTemplateID IN (SELECT ID FROM Template_20180622 WHERE TemplateGroupID IN('1E741076-2CBF-448A-A31C-B92C9ECB29D3','04B3B25D-131F-4214-9EDE-3B3858BE196A') AND path LIKE '%VatTemplate/DefaultVersion/%')";
sql = "SELECT ID,ReportTemplateID,RowIndex,ColumnIndex from CellTemplate_20180622 WHERE ReportTemplateID IN " +
"(SELECT ID FROM Template_20180622 WHERE TemplateGroupID IN" +
"(" + templateGroupId + ") AND path LIKE '%VatTemplate/DefaultVersion/%')";
cellTemplate20180622List = jdbcTemplate.queryForList(sql);
List<CellTemplateConfig> cellTemplateConfigList = new ArrayList<>();
......@@ -323,22 +330,22 @@ public class DataMigration extends CommonIT {
cellTemplateConfig.setCellTemplateId(getIdFromExistTable3(MapUtils.getString(item, "CellTemplateID"), MapUtils.getString(item, "ReportTemplateID")));
cellTemplateConfig.setReportTemplateId(getIdFromExistTable2(MapUtils.getString(item, "ReportTemplateID")));
cellTemplateConfig.setDataSourceType(MapUtils.getInteger(item, "DataSourceType"));
cellTemplateConfig.setFormula(MapUtils.getString(item, "Formula")!=null?MapUtils.getString(item, "Formula"):"");
cellTemplateConfig.setFormulaDescription(MapUtils.getString(item, "FormulaDescription")!=null?MapUtils.getString(item, "FormulaDescription"):"");
cellTemplateConfig.setAccountCodes(MapUtils.getString(item, "AccountCodes")!=null?MapUtils.getString(item, "AccountCodes"):"");
cellTemplateConfig.setInvoiceType(MapUtils.getInteger(item, "InvoiceType")!=null?MapUtils.getInteger(item, "InvoiceType"):0);
cellTemplateConfig.setTaxRate(MapUtils.getString(item, "TaxRate")!=null?MapUtils.getString(item, "TaxRate"):"");
cellTemplateConfig.setInvoiceAmountType(MapUtils.getInteger(item, "InvoiceAmountType")!=null?MapUtils.getInteger(item, "InvoiceAmountType"):0);
cellTemplateConfig.setModelIds(MapUtils.getString(item, "ModelIDs")!=null?MapUtils.getString(item, "ModelIDs"):"");
cellTemplateConfig.setCreateBy(MapUtils.getString(item, "Creator")!=null?MapUtils.getString(item, "Creator"):"");
cellTemplateConfig.setFormula(MapUtils.getString(item, "Formula") != null ? MapUtils.getString(item, "Formula") : "");
cellTemplateConfig.setFormulaDescription(MapUtils.getString(item, "FormulaDescription") != null ? MapUtils.getString(item, "FormulaDescription") : "");
cellTemplateConfig.setAccountCodes(MapUtils.getString(item, "AccountCodes") != null ? MapUtils.getString(item, "AccountCodes") : "");
cellTemplateConfig.setInvoiceType(MapUtils.getInteger(item, "InvoiceType") != null ? MapUtils.getInteger(item, "InvoiceType") : 0);
cellTemplateConfig.setTaxRate(MapUtils.getString(item, "TaxRate") != null ? MapUtils.getString(item, "TaxRate") : "");
cellTemplateConfig.setInvoiceAmountType(MapUtils.getInteger(item, "InvoiceAmountType") != null ? MapUtils.getInteger(item, "InvoiceAmountType") : 0);
cellTemplateConfig.setModelIds(MapUtils.getString(item, "ModelIDs") != null ? MapUtils.getString(item, "ModelIDs") : "");
cellTemplateConfig.setCreateBy(MapUtils.getString(item, "Creator") != null ? MapUtils.getString(item, "Creator") : "");
cellTemplateConfig.setCreateTime(DateUtils.strToDateLong(MapUtils.getString(item, "CreateTime")));
cellTemplateConfig.setUpdateBy(MapUtils.getString(item, "Updater")!=null?MapUtils.getString(item, "Updater"):"");
cellTemplateConfig.setUpdateBy(MapUtils.getString(item, "Updater") != null ? MapUtils.getString(item, "Updater") : "");
cellTemplateConfig.setUpdateTime(DateUtils.strToDateLong(MapUtils.getString(item, "UpdateTime")));
cellTemplateConfig.setInvoiceCategory(MapUtils.getString(item, "InvoiceCategory")!=null?MapUtils.getString(item, "InvoiceCategory"):"");
cellTemplateConfig.setFormulaDataSource(MapUtils.getString(item, "FormulaDataSource")!=null?MapUtils.getString(item, "FormulaDataSource"):"");
cellTemplateConfig.setValidation(MapUtils.getString(item, "Validation")!=null?MapUtils.getString(item, "Validation"):"");
cellTemplateConfig.setValidationDescription(MapUtils.getString(item, "ValidationDescription")!=null?MapUtils.getString(item, "ValidationDescription"):"");
cellTemplateConfig.setVoucherKeyword(MapUtils.getString(item, "VoucherKeyword")!=null?MapUtils.getString(item, "VoucherKeyword"):"");
cellTemplateConfig.setInvoiceCategory(MapUtils.getString(item, "InvoiceCategory") != null ? MapUtils.getString(item, "InvoiceCategory") : "");
cellTemplateConfig.setFormulaDataSource(MapUtils.getString(item, "FormulaDataSource") != null ? MapUtils.getString(item, "FormulaDataSource") : "");
cellTemplateConfig.setValidation(MapUtils.getString(item, "Validation") != null ? MapUtils.getString(item, "Validation") : "");
cellTemplateConfig.setValidationDescription(MapUtils.getString(item, "ValidationDescription") != null ? MapUtils.getString(item, "ValidationDescription") : "");
cellTemplateConfig.setVoucherKeyword(MapUtils.getString(item, "VoucherKeyword") != null ? MapUtils.getString(item, "VoucherKeyword") : "");
System.out.println("i=" + i);
System.out.println("j=" + j);
cellTemplateConfigList.add(cellTemplateConfig);
......@@ -483,10 +490,10 @@ public class DataMigration extends CommonIT {
for (Map<String, Object> item : queryForList) {
taxRuleSettingOrganization = new TaxRuleSettingOrganization();
taxRuleSettingOrganization.setId(distributedIDService.nextId());
taxRuleSettingOrganization.setTaxSettingId(getIdFromExistTable4(MapUtils.getString(item,"TaxSettingID")));
taxRuleSettingOrganization.setOrganizationId(MapUtils.getString(item,"OrganizationID"));
taxRuleSettingOrganization.setCreateTime(DateUtils.strToDateLong(MapUtils.getString(item,"CreateTime")));
taxRuleSettingOrganization.setUpdateTime(DateUtils.strToDateLong(MapUtils.getString(item,"UpdateTime")));
taxRuleSettingOrganization.setTaxSettingId(getIdFromExistTable4(MapUtils.getString(item, "TaxSettingID")));
taxRuleSettingOrganization.setOrganizationId(MapUtils.getString(item, "OrganizationID"));
taxRuleSettingOrganization.setCreateTime(DateUtils.strToDateLong(MapUtils.getString(item, "CreateTime")));
taxRuleSettingOrganization.setUpdateTime(DateUtils.strToDateLong(MapUtils.getString(item, "UpdateTime")));
taxRuleSettingOrganization.setCreateBy(StringUtils.EMPTY);
taxRuleSettingOrganization.setUpdateBy(StringUtils.EMPTY);
taxRuleSettingOrganizationMapper.insert(taxRuleSettingOrganization);
......@@ -495,10 +502,11 @@ public class DataMigration extends CommonIT {
/**
* 获取taxSetting 新表ID
*
* @param id 旧表ID
* @return 新表ID
*/
private Long getIdFromExistTable4(String id){
private Long getIdFromExistTable4(String id) {
try {
Map<String, Object> item = taxRuleSetting20180622List.stream()
.filter(a -> MapUtils.getString(a, "ID").equals(id))
......@@ -518,10 +526,8 @@ public class DataMigration extends CommonIT {
}
//todo: ProjectServiceType_20180622 --40
@Test
public void insertChieseCharacter(){
public void insertChieseCharacter() {
ShardingContextHolder.setDataSourceKey("a1800010");
PeriodTemplate periodTemplate = new PeriodTemplate();
......
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