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